diff options
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 35 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 16 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 2 | ||||
-rw-r--r-- | ash/extended_desktop_unittest.cc | 70 | ||||
-rw-r--r-- | ash/root_window_controller.cc | 4 | ||||
-rw-r--r-- | ash/root_window_controller.h | 3 | ||||
-rw-r--r-- | ash/shell.cc | 10 | ||||
-rw-r--r-- | ash/shell.h | 4 | ||||
-rw-r--r-- | ash/wm/event_client_impl.cc | 22 | ||||
-rw-r--r-- | ash/wm/event_client_impl.h | 4 | ||||
-rw-r--r-- | ash/wm/power_button_controller.cc | 11 |
11 files changed, 26 insertions, 155 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 2ac4e7e..bc742c7 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -33,7 +33,6 @@ #include "ash/system/tray/system_tray_delegate.h" #include "ash/volume_control_delegate.h" #include "ash/wm/partial_screenshot_view.h" -#include "ash/wm/power_button_controller.h" #include "ash/wm/property_util.h" #include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_util.h" @@ -58,7 +57,6 @@ #if defined(OS_CHROMEOS) #include "ash/display/output_configurator_animation.h" #include "base/chromeos/chromeos_version.h" -#include "base/time.h" #include "chromeos/display/output_configurator.h" #endif // defined(OS_CHROMEOS) @@ -765,35 +763,10 @@ bool AcceleratorController::PerformAction(int action, return HandleMediaPrevTrack(); case POWER_PRESSED: // fallthrough case POWER_RELEASED: -#if defined(OS_CHROMEOS) - if (!base::chromeos::IsRunningOnChromeOS()) { - // There is no powerd in linux desktop, so call the - // PowerButtonController here. - Shell::GetInstance()->power_button_controller()-> - OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); - } -#endif - // We don't do anything with these at present on the device, - // (power button evets are reported to us from powerm via - // D-BUS), but we consume them to prevent them from getting - // passed to apps -- see http://crbug.com/146609. - return true; - case LOCK_PRESSED: - case LOCK_RELEASED: -#if defined(OS_CHROMEOS) - if (!base::chromeos::IsRunningOnChromeOS()) { - // There is no powerd in linux desktop, so call the - // PowerButtonController here. - Shell::GetInstance()->power_button_controller()-> - OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks()); - return true; - } -#endif - // LOCK_PRESSED/RELEASED in debug only action that is meant for - // testing lock behavior on linux desktop. If we ever reached - // here (when you run a debug build on the device), pass it onto - // apps. - return false; + // We don't do anything with these at present, but we consume them to + // prevent them from getting passed to apps -- see + // http://crbug.com/146609. + return true; #if !defined(NDEBUG) case PRINT_LAYER_HIERARCHY: return HandlePrintLayerHierarchy(); diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index fe7db0d..ac40ab0 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -66,12 +66,6 @@ const AcceleratorData kAcceleratorData[] = { // Extra shortcut for display swaping as alt-f4 is taken on linux desktop. { true, ui::VKEY_F4, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN, SWAP_PRIMARY_DISPLAY }, - // Extra shortcut to exit on linux desktop. - { true, ui::VKEY_F11, ui::EF_NONE, POWER_PRESSED }, - { false, ui::VKEY_F11, ui::EF_NONE, POWER_RELEASED }, - // Extra shortcut to lock the screen on linux desktop. - { true, ui::VKEY_F12, ui::EF_NONE, LOCK_PRESSED }, - { false, ui::VKEY_F12, ui::EF_NONE, LOCK_RELEASED }, #endif { true, ui::VKEY_O, ui::EF_CONTROL_DOWN, OPEN_FILE_MANAGER_DIALOG }, { true, ui::VKEY_M, ui::EF_CONTROL_DOWN, OPEN_FILE_MANAGER_TAB }, @@ -199,8 +193,6 @@ const AcceleratorAction kReservedActions[] = { CYCLE_FORWARD_MRU_PRESSED, // Alt+Tab CYCLE_FORWARD_MRU_RELEASED, #if defined(OS_CHROMEOS) - LOCK_PRESSED, - LOCK_RELEASED, POWER_PRESSED, POWER_RELEASED, TOGGLE_MAXIMIZED_PRESSED, @@ -239,10 +231,6 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = { PRINT_WINDOW_HIERARCHY, ROTATE_SCREEN, #endif -#if defined(OS_CHROMEOS) && !defined(NDEBUG) - POWER_PRESSED, - POWER_RELEASED, -#endif }; const size_t kActionsAllowedAtLoginOrLockScreenLength = @@ -250,10 +238,6 @@ const size_t kActionsAllowedAtLoginOrLockScreenLength = const AcceleratorAction kActionsAllowedAtLockScreen[] = { EXIT, -#if defined(OS_CHROMEOS) && !defined(NDEBUG) - POWER_PRESSED, - POWER_RELEASED, -#endif }; const size_t kActionsAllowedAtLockScreenLength = diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index 14b4327..91442a4 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -32,8 +32,6 @@ enum AcceleratorAction { FOCUS_SYSTEM_TRAY, KEYBOARD_BRIGHTNESS_DOWN, KEYBOARD_BRIGHTNESS_UP, - LOCK_PRESSED, - LOCK_RELEASED, MAGNIFY_SCREEN_ZOOM_IN, MAGNIFY_SCREEN_ZOOM_OUT, MEDIA_NEXT_TRACK, diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 4cc75fa..5f4dd6c 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -4,9 +4,7 @@ #include "ash/display/display_controller.h" #include "ash/display/multi_display_manager.h" -#include "ash/screen_ash.h" #include "ash/shell.h" -#include "ash/shell_window_ids.h" #include "ash/system/tray/system_tray.h" #include "ash/test/ash_test_base.h" #include "ash/wm/coordinate_conversion.h" @@ -14,7 +12,6 @@ #include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" -#include "base/string_util.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/capture_client.h" #include "ui/aura/env.h" @@ -26,7 +23,6 @@ #include "ui/base/cursor/cursor.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" -#include "ui/views/controls/textfield/textfield.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" @@ -603,71 +599,5 @@ TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); } -TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { - UpdateDisplay("100x100,200x200"); - Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); - - // Create normal windows on both displays. - views::Widget* widget1 = CreateTestWidget( - gfx::Screen::GetPrimaryDisplay().bounds()); - widget1->Show(); - EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); - views::Widget* widget2 = CreateTestWidget( - ScreenAsh::GetSecondaryDisplay().bounds()); - widget2->Show(); - EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); - - // Create a LockScreen window. - views::Widget* lock_widget = CreateTestWidget( - gfx::Screen::GetPrimaryDisplay().bounds()); - views::Textfield* textfield = new views::Textfield; - lock_widget->SetContentsView(textfield); - - ash::Shell::GetContainer( - Shell::GetPrimaryRootWindow(), - ash::internal::kShellWindowId_LockScreenContainer)-> - AddChild(lock_widget->GetNativeView()); - lock_widget->Show(); - textfield->RequestFocus(); - - aura::FocusManager* focus_manager = root_windows[0]->GetFocusManager(); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - - // The lock window should get events on both root windows. - aura::test::EventGenerator generator1(root_windows[0]); - generator1.PressKey(ui::VKEY_A, 0); - generator1.ReleaseKey(ui::VKEY_A, 0); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - EXPECT_EQ("a", UTF16ToASCII(textfield->text())); - - aura::test::EventGenerator generator2(root_windows[1]); - generator2.PressKey(ui::VKEY_B, 0); - generator2.ReleaseKey(ui::VKEY_B, 0); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); - - // Deleting 2nd display. The lock window still should get the events. - UpdateDisplay("100x100"); - generator2.PressKey(ui::VKEY_C, 0); - generator2.ReleaseKey(ui::VKEY_C, 0); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); - - // Creating 2nd display again, and lock window still should get events - // on both root windows. - UpdateDisplay("100x100,200x200"); - root_windows = Shell::GetAllRootWindows(); - generator1.PressKey(ui::VKEY_D, 0); - generator1.ReleaseKey(ui::VKEY_D, 0); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); - - aura::test::EventGenerator generator22(root_windows[1]); - generator22.PressKey(ui::VKEY_E, 0); - generator22.ReleaseKey(ui::VKEY_E, 0); - EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); - EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); -} - } // namespace internal } // namespace ash diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index b0a5b92bb..1f08095 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -13,6 +13,7 @@ #include "ash/shell_factory.h" #include "ash/shell_window_ids.h" #include "ash/wm/base_layout_manager.h" +#include "ash/wm/event_client_impl.h" #include "ash/wm/property_util.h" #include "ash/wm/root_window_layout_manager.h" #include "ash/wm/screen_dimmer.h" @@ -143,6 +144,8 @@ namespace internal { RootWindowController::RootWindowController(aura::RootWindow* root_window) : root_window_(root_window) { SetRootWindowController(root_window, this); + + event_client_.reset(new EventClientImpl(root_window)); screen_dimmer_.reset(new ScreenDimmer(root_window)); } @@ -159,6 +162,7 @@ void RootWindowController::Shutdown() { NULL : Shell::GetPrimaryRootWindow()); } SetRootWindowController(root_window_.get(), NULL); + event_client_.reset(); screen_dimmer_.reset(); workspace_controller_.reset(); // Forget with the display ID so that display lookup diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index c88795d..e8f623d 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -25,6 +25,7 @@ namespace ash { class ToplevelWindowEventHandler; namespace internal { +class EventClientImpl; class RootWindowLayoutManager; class ScreenDimmer; class SystemBackgroundController; @@ -100,6 +101,8 @@ class ASH_EXPORT RootWindowController { // desktop background image when displaying the login screen. scoped_ptr<SystemBackgroundController> background_; + // An event filter that pre-handles all key events to send them to an IME. + scoped_ptr<EventClientImpl> event_client_; scoped_ptr<ScreenDimmer> screen_dimmer_; scoped_ptr<WorkspaceController> workspace_controller_; diff --git a/ash/shell.cc b/ash/shell.cc index 9de3e091..3627616 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -256,7 +256,6 @@ Shell::~Shell() { resize_shadow_controller_.reset(); shadow_controller_.reset(); tooltip_controller_.reset(); - event_client_.reset(); window_cycle_controller_.reset(); capture_controller_.reset(); nested_dispatcher_controller_.reset(); @@ -349,12 +348,6 @@ aura::Window* Shell::GetContainer(aura::RootWindow* root_window, } // static -const aura::Window* Shell::GetContainer(const aura::RootWindow* root_window, - int container_id) { - return root_window->GetChildById(container_id); -} - -// static std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { std::vector<aura::Window*> containers; aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id); @@ -455,8 +448,6 @@ void Shell::Init() { drag_drop_controller_.get())); AddEnvEventFilter(tooltip_controller_.get()); - event_client_.reset(new internal::EventClientImpl); - InitRootWindowController(root_window_controller); // This controller needs to be set before SetupManagedWindowMode. @@ -740,7 +731,6 @@ void Shell::InitRootWindowController( screen_position_controller_.get()); aura::client::SetCursorClient(root_window, &cursor_manager_); aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); - aura::client::SetEventClient(root_window, event_client_.get()); if (nested_dispatcher_controller_.get()) { aura::client::SetDispatcherClient(root_window, diff --git a/ash/shell.h b/ash/shell.h index 044ba06..ef869bf 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -83,7 +83,6 @@ class ActivationController; class AppListController; class CaptureController; class DragDropController; -class EventClientImpl; class EventRewriterEventFilter; class FocusCycler; class MagnificationController; @@ -176,8 +175,6 @@ class ASH_EXPORT Shell : CursorDelegate, static aura::Window* GetContainer(aura::RootWindow* root_window, int container_id); - static const aura::Window* GetContainer(const aura::RootWindow* root_window, - int container_id); // Returns the list of containers that match |container_id| in // all root windows. @@ -460,7 +457,6 @@ class ASH_EXPORT Shell : CursorDelegate, scoped_ptr<internal::MouseCursorEventFilter> mouse_cursor_filter_; scoped_ptr<internal::ScreenPositionController> screen_position_controller_; scoped_ptr<internal::SystemModalContainerEventFilter> modality_filter_; - scoped_ptr<internal::EventClientImpl> event_client_; // An event filter that rewrites or drops an event. scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_; diff --git a/ash/wm/event_client_impl.cc b/ash/wm/event_client_impl.cc index f7fc8b2..4482c11 100644 --- a/ash/wm/event_client_impl.cc +++ b/ash/wm/event_client_impl.cc @@ -6,30 +6,32 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" +#include "ui/aura/root_window.h" #include "ui/aura/window.h" namespace ash { namespace internal { -EventClientImpl::EventClientImpl() { +EventClientImpl::EventClientImpl(aura::RootWindow* root_window) + : root_window_(root_window) { + aura::client::SetEventClient(root_window_, this); } EventClientImpl::~EventClientImpl() { + aura::client::SetEventClient(root_window_, NULL); } bool EventClientImpl::CanProcessEventsWithinSubtree( const aura::Window* window) const { - const aura::RootWindow* root_window = - window ? window->GetRootWindow() : NULL; - if (Shell::GetInstance()->IsScreenLocked() && root_window) { - const aura::Window* lock_screen_containers = Shell::GetContainer( - root_window, + if (Shell::GetInstance()->IsScreenLocked()) { + aura::Window* lock_screen_containers = Shell::GetContainer( + root_window_, kShellWindowId_LockScreenContainersContainer); - const aura::Window* lock_background_containers = Shell::GetContainer( - root_window, + aura::Window* lock_background_containers = Shell::GetContainer( + root_window_, kShellWindowId_LockScreenBackgroundContainer); - const aura::Window* lock_screen_related_containers = Shell::GetContainer( - root_window, + aura::Window* lock_screen_related_containers = Shell::GetContainer( + root_window_, kShellWindowId_LockScreenRelatedContainersContainer); return lock_screen_containers->Contains(window) || lock_background_containers->Contains(window) || diff --git a/ash/wm/event_client_impl.h b/ash/wm/event_client_impl.h index 3702709..cf689ed 100644 --- a/ash/wm/event_client_impl.h +++ b/ash/wm/event_client_impl.h @@ -17,7 +17,7 @@ namespace internal { class EventClientImpl : public aura::client::EventClient { public: - EventClientImpl(); + explicit EventClientImpl(aura::RootWindow* root_window); virtual ~EventClientImpl(); private: @@ -25,6 +25,8 @@ class EventClientImpl : public aura::client::EventClient { virtual bool CanProcessEventsWithinSubtree( const aura::Window* window) const OVERRIDE; + aura::RootWindow* root_window_; + DISALLOW_COPY_AND_ASSIGN(EventClientImpl); }; diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index 4f05f1b..bd9bb91 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -13,10 +13,6 @@ #include "ui/aura/root_window.h" #include "ui/aura/shared/compound_event_filter.h" -#if defined(OS_CHROMEOS) -#include "base/chromeos/chromeos_version.h" -#endif - namespace ash { namespace { @@ -311,13 +307,6 @@ void PowerButtonController::OnShutdownTimeout() { void PowerButtonController::OnRealShutdownTimeout() { DCHECK(shutting_down_); -#if defined(OS_CHROMEOS) - if (!base::chromeos::IsRunningOnChromeOS()) { - ShellDelegate* delegate = Shell::GetInstance()->delegate(); - if (delegate) - delegate->Exit(); - } -#endif delegate_->RequestShutdown(); } |