| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/wm/core/nested_accelerator_dispatcher.h" | 5 #include "ui/wm/core/nested_accelerator_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "ui/base/accelerators/accelerator.h" |
| 9 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| 10 #include "ui/events/platform/platform_event_dispatcher.h" | 11 #include "ui/events/platform/platform_event_dispatcher.h" |
| 11 #include "ui/events/platform/platform_event_source.h" | 12 #include "ui/events/platform/platform_event_source.h" |
| 12 #include "ui/events/platform/scoped_event_dispatcher.h" | 13 #include "ui/events/platform/scoped_event_dispatcher.h" |
| 14 #include "ui/wm/core/accelerator_filter.h" |
| 13 #include "ui/wm/core/nested_accelerator_delegate.h" | 15 #include "ui/wm/core/nested_accelerator_delegate.h" |
| 14 | 16 |
| 15 #if defined(USE_X11) | 17 #if defined(USE_X11) |
| 16 #include <X11/Xlib.h> | 18 #include <X11/Xlib.h> |
| 17 #endif | 19 #endif |
| 18 | 20 |
| 19 namespace wm { | 21 namespace wm { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 60 } |
| 59 | 61 |
| 60 // ui::PlatformEventDispatcher: | 62 // ui::PlatformEventDispatcher: |
| 61 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE { | 63 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE { |
| 62 return true; | 64 return true; |
| 63 } | 65 } |
| 64 | 66 |
| 65 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { | 67 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { |
| 66 if (IsKeyEvent(event)) { | 68 if (IsKeyEvent(event)) { |
| 67 ui::KeyEvent key_event(event, false); | 69 ui::KeyEvent key_event(event, false); |
| 68 if (!delegate_->ShouldProcessEventNow(key_event)) { | 70 ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event); |
| 71 |
| 72 switch (delegate_->ProcessAccelerator(accelerator)) { |
| 73 case NestedAcceleratorDelegate::RESULT_PROCESS_LATER: |
| 69 #if defined(USE_X11) | 74 #if defined(USE_X11) |
| 70 XPutBackEvent(event->xany.display, event); | 75 XPutBackEvent(event->xany.display, event); |
| 71 #else | 76 #else |
| 72 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
| 73 #endif | 78 #endif |
| 74 return ui::POST_DISPATCH_NONE; | 79 return ui::POST_DISPATCH_NONE; |
| 80 case NestedAcceleratorDelegate::RESULT_PROCESSED: |
| 81 return ui::POST_DISPATCH_NONE; |
| 82 case NestedAcceleratorDelegate::RESULT_NOT_PROCESSED: |
| 83 break; |
| 75 } | 84 } |
| 76 | |
| 77 if (delegate_->ProcessEvent(key_event)) | |
| 78 return ui::POST_DISPATCH_NONE; | |
| 79 } | 85 } |
| 80 ui::PlatformEventDispatcher* prev = *restore_dispatcher_; | 86 ui::PlatformEventDispatcher* prev = *restore_dispatcher_; |
| 81 | 87 |
| 82 return prev ? prev->DispatchEvent(event) | 88 return prev ? prev->DispatchEvent(event) |
| 83 : ui::POST_DISPATCH_PERFORM_DEFAULT; | 89 : ui::POST_DISPATCH_PERFORM_DEFAULT; |
| 84 } | 90 } |
| 85 | 91 |
| 86 scoped_ptr<ui::ScopedEventDispatcher> restore_dispatcher_; | 92 scoped_ptr<ui::ScopedEventDispatcher> restore_dispatcher_; |
| 87 | 93 |
| 88 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherLinux); | 94 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherLinux); |
| 89 }; | 95 }; |
| 90 | 96 |
| 91 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( | 97 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( |
| 92 NestedAcceleratorDelegate* delegate, | 98 NestedAcceleratorDelegate* delegate, |
| 93 base::MessagePumpDispatcher* nested_dispatcher) { | 99 base::MessagePumpDispatcher* nested_dispatcher) { |
| 94 return scoped_ptr<NestedAcceleratorDispatcher>( | 100 return scoped_ptr<NestedAcceleratorDispatcher>( |
| 95 new NestedAcceleratorDispatcherLinux(delegate)); | 101 new NestedAcceleratorDispatcherLinux(delegate)); |
| 96 } | 102 } |
| 97 | 103 |
| 98 } // namespace wm | 104 } // namespace wm |
| OLD | NEW |