| 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" | 7 #include "ash/shell.h" |
| 8 #include "components/exo/keyboard_delegate.h" | 8 #include "components/exo/keyboard_delegate.h" |
| 9 #include "components/exo/surface.h" | 9 #include "components/exo/surface.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 focus_->RemoveSurfaceObserver(this); | 29 focus_->RemoveSurfaceObserver(this); |
| 30 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()) | 30 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()) |
| 31 ->RemoveObserver(this); | 31 ->RemoveObserver(this); |
| 32 ash::Shell::GetInstance()->RemovePreTargetHandler(this); | 32 ash::Shell::GetInstance()->RemovePreTargetHandler(this); |
| 33 } | 33 } |
| 34 | 34 |
| 35 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
| 36 // ui::EventHandler overrides: | 36 // ui::EventHandler overrides: |
| 37 | 37 |
| 38 void Keyboard::OnKeyEvent(ui::KeyEvent* event) { | 38 void Keyboard::OnKeyEvent(ui::KeyEvent* event) { |
| 39 const int kModifierMask = ui::EF_CAPS_LOCK_DOWN | ui::EF_SHIFT_DOWN | | 39 const int kModifierMask = |
| 40 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | | 40 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | |
| 41 ui::EF_COMMAND_DOWN | ui::EF_ALTGR_DOWN | | 41 ui::EF_COMMAND_DOWN | ui::EF_ALTGR_DOWN | ui::EF_MOD3_DOWN | |
| 42 ui::EF_MOD3_DOWN | ui::EF_NUM_LOCK_DOWN; | 42 ui::EF_NUM_LOCK_ON | ui::EF_CAPS_LOCK_ON | ui::EF_SCROLL_LOCK_ON; |
| 43 int modifier_flags = event->flags() & kModifierMask; | 43 int modifier_flags = event->flags() & kModifierMask; |
| 44 if (modifier_flags != modifier_flags_) { | 44 if (modifier_flags != modifier_flags_) { |
| 45 modifier_flags_ = modifier_flags; | 45 modifier_flags_ = modifier_flags; |
| 46 if (focus_) | 46 if (focus_) |
| 47 delegate_->OnKeyboardModifiers(modifier_flags_); | 47 delegate_->OnKeyboardModifiers(modifier_flags_); |
| 48 } | 48 } |
| 49 | 49 |
| 50 switch (event->type()) { | 50 switch (event->type()) { |
| 51 case ui::ET_KEY_PRESSED: { | 51 case ui::ET_KEY_PRESSED: { |
| 52 auto it = | 52 auto it = |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 Surface* Keyboard::GetEffectiveFocus(aura::Window* window) const { | 111 Surface* Keyboard::GetEffectiveFocus(aura::Window* window) const { |
| 112 Surface* focus = Surface::AsSurface(window); | 112 Surface* focus = Surface::AsSurface(window); |
| 113 if (!focus) | 113 if (!focus) |
| 114 return nullptr; | 114 return nullptr; |
| 115 | 115 |
| 116 return delegate_->CanAcceptKeyboardEventsForSurface(focus) ? focus : nullptr; | 116 return delegate_->CanAcceptKeyboardEventsForSurface(focus) ? focus : nullptr; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace exo | 119 } // namespace exo |
| OLD | NEW |