Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: ui/views/controls/menu/menu_event_dispatcher_linux.cc

Issue 219743002: x11: Move X event handling out of the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r261267 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/views/controls/menu/menu_message_pump_dispatcher.h" 5 #include "ui/views/controls/menu/menu_event_dispatcher_linux.h"
6 6
7 #include "ui/events/event_utils.h" 7 #include "ui/events/event_utils.h"
8 #include "ui/events/keycodes/keyboard_code_conversion.h" 8 #include "ui/events/keycodes/keyboard_code_conversion.h"
9 #include "ui/events/keycodes/keyboard_codes.h" 9 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/views/controls/menu/menu_controller.h" 10 #include "ui/views/controls/menu/menu_controller.h"
11 11
12 namespace views { 12 namespace views {
13 namespace internal { 13 namespace internal {
14 14
15 uint32_t MenuMessagePumpDispatcher::Dispatch(const base::NativeEvent& event) { 15 MenuEventDispatcher::MenuEventDispatcher(MenuController* controller)
16 : menu_controller_(controller) {}
17
18 MenuEventDispatcher::~MenuEventDispatcher() {}
19
20 bool MenuEventDispatcher::CanDispatchEvent(const ui::PlatformEvent& event) {
21 return true;
22 }
23
24 uint32_t MenuEventDispatcher::DispatchEvent(const ui::PlatformEvent& event) {
16 if (menu_controller_->exit_type() == MenuController::EXIT_ALL || 25 if (menu_controller_->exit_type() == MenuController::EXIT_ALL ||
17 menu_controller_->exit_type() == MenuController::EXIT_DESTROYED) 26 menu_controller_->exit_type() == MenuController::EXIT_DESTROYED)
18 return (POST_DISPATCH_QUIT_LOOP | POST_DISPATCH_PERFORM_DEFAULT); 27 return (ui::POST_DISPATCH_QUIT_LOOP | ui::POST_DISPATCH_PERFORM_DEFAULT);
19 28
20 switch (ui::EventTypeFromNative(event)) { 29 switch (ui::EventTypeFromNative(event)) {
21 case ui::ET_KEY_PRESSED: { 30 case ui::ET_KEY_PRESSED: {
22 if (!menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(event))) 31 if (!menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(event)))
23 return POST_DISPATCH_QUIT_LOOP; 32 return ui::POST_DISPATCH_QUIT_LOOP;
24 33
25 // Do not check mnemonics if the Alt or Ctrl modifiers are pressed. 34 // Do not check mnemonics if the Alt or Ctrl modifiers are pressed.
26 int flags = ui::EventFlagsFromNative(event); 35 int flags = ui::EventFlagsFromNative(event);
27 if ((flags & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) == 0) { 36 if ((flags & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) == 0) {
28 char c = ui::GetCharacterFromKeyCode(ui::KeyboardCodeFromNative(event), 37 char c = ui::GetCharacterFromKeyCode(ui::KeyboardCodeFromNative(event),
29 flags); 38 flags);
30 if (menu_controller_->SelectByChar(c)) 39 if (menu_controller_->SelectByChar(c))
31 return POST_DISPATCH_QUIT_LOOP; 40 return ui::POST_DISPATCH_QUIT_LOOP;
32 } 41 }
33 return POST_DISPATCH_NONE; 42 return ui::POST_DISPATCH_NONE;
34 } 43 }
35 case ui::ET_KEY_RELEASED: 44 case ui::ET_KEY_RELEASED:
36 return POST_DISPATCH_NONE; 45 return ui::POST_DISPATCH_NONE;
37 default: 46 default:
38 break; 47 break;
39 } 48 }
40 49
41 return POST_DISPATCH_PERFORM_DEFAULT | 50 return ui::POST_DISPATCH_PERFORM_DEFAULT |
42 (menu_controller_->exit_type() == MenuController::EXIT_NONE 51 (menu_controller_->exit_type() == MenuController::EXIT_NONE
43 ? POST_DISPATCH_NONE 52 ? ui::POST_DISPATCH_NONE
44 : POST_DISPATCH_QUIT_LOOP); 53 : ui::POST_DISPATCH_QUIT_LOOP);
45 } 54 }
46 55
47 } // namespace internal 56 } // namespace internal
48 } // namespace views 57 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_event_dispatcher_linux.h ('k') | ui/views/controls/menu/menu_message_pump_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698