| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/keyboard.h" | 5 #include "components/exo/keyboard.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | |
| 8 #include "components/exo/keyboard_delegate.h" | 7 #include "components/exo/keyboard_delegate.h" |
| 9 #include "components/exo/shell_surface.h" | 8 #include "components/exo/shell_surface.h" |
| 10 #include "components/exo/surface.h" | 9 #include "components/exo/surface.h" |
| 11 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| 12 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 13 #include "ui/base/ime/input_method.h" | 12 #include "ui/base/ime/input_method.h" |
| 14 #include "ui/events/base_event_utils.h" | 13 #include "ui/events/base_event_utils.h" |
| 15 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 16 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 17 | 16 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 return false; | 69 return false; |
| 71 } | 70 } |
| 72 | 71 |
| 73 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
| 74 // Keyboard, public: | 73 // Keyboard, public: |
| 75 | 74 |
| 76 Keyboard::Keyboard(KeyboardDelegate* delegate) : delegate_(delegate) { | 75 Keyboard::Keyboard(KeyboardDelegate* delegate) : delegate_(delegate) { |
| 77 ash::Shell::GetInstance()->AddPostTargetHandler(this); | 76 auto* helper = WMHelper::GetInstance(); |
| 78 aura::client::FocusClient* focus_client = | 77 helper->AddPostTargetHandler(this); |
| 79 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 78 helper->AddFocusObserver(this); |
| 80 focus_client->AddObserver(this); | 79 OnWindowFocused(helper->GetFocusedWindow(), nullptr); |
| 81 OnWindowFocused(focus_client->GetFocusedWindow(), nullptr); | |
| 82 } | 80 } |
| 83 | 81 |
| 84 Keyboard::~Keyboard() { | 82 Keyboard::~Keyboard() { |
| 85 delegate_->OnKeyboardDestroying(this); | 83 delegate_->OnKeyboardDestroying(this); |
| 86 if (focus_) | 84 if (focus_) |
| 87 focus_->RemoveSurfaceObserver(this); | 85 focus_->RemoveSurfaceObserver(this); |
| 88 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()) | 86 auto* helper = WMHelper::GetInstance(); |
| 89 ->RemoveObserver(this); | 87 helper->RemoveFocusObserver(this); |
| 90 ash::Shell::GetInstance()->RemovePostTargetHandler(this); | 88 helper->RemovePostTargetHandler(this); |
| 91 } | 89 } |
| 92 | 90 |
| 93 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
| 94 // ui::EventHandler overrides: | 92 // ui::EventHandler overrides: |
| 95 | 93 |
| 96 void Keyboard::OnKeyEvent(ui::KeyEvent* event) { | 94 void Keyboard::OnKeyEvent(ui::KeyEvent* event) { |
| 97 // These modifiers reflect what Wayland is aware of. For example, | 95 // These modifiers reflect what Wayland is aware of. For example, |
| 98 // EF_SCROLL_LOCK_ON is missing because Wayland doesn't support scroll lock. | 96 // EF_SCROLL_LOCK_ON is missing because Wayland doesn't support scroll lock. |
| 99 const int kModifierMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | | 97 const int kModifierMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | |
| 100 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN | | 98 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN | |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 aura::Window* top_level_window = window->GetToplevelWindow(); | 179 aura::Window* top_level_window = window->GetToplevelWindow(); |
| 182 if (top_level_window) | 180 if (top_level_window) |
| 183 focus = ShellSurface::GetMainSurface(top_level_window); | 181 focus = ShellSurface::GetMainSurface(top_level_window); |
| 184 } | 182 } |
| 185 | 183 |
| 186 return focus && delegate_->CanAcceptKeyboardEventsForSurface(focus) ? focus | 184 return focus && delegate_->CanAcceptKeyboardEventsForSurface(focus) ? focus |
| 187 : nullptr; | 185 : nullptr; |
| 188 } | 186 } |
| 189 | 187 |
| 190 } // namespace exo | 188 } // namespace exo |
| OLD | NEW |