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

Side by Side Diff: chrome/browser/extensions/global_shortcut_listener_x11.cc

Issue 64273008: [Windows] Finish global and non-global media keys support on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gclient sync. Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/global_shortcut_listener_x11.h" 5 #include "chrome/browser/extensions/global_shortcut_listener_x11.h"
6 6
7 #include "base/x11/x11_error_tracker.h" 7 #include "base/x11/x11_error_tracker.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "ui/base/accelerators/accelerator.h" 9 #include "ui/base/accelerators/accelerator.h"
10 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 10 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool GlobalShortcutListenerX11::Dispatch(const base::NativeEvent& event) { 103 bool GlobalShortcutListenerX11::Dispatch(const base::NativeEvent& event) {
104 if (event->type == KeyPress) 104 if (event->type == KeyPress)
105 OnXKeyPressEvent(event); 105 OnXKeyPressEvent(event);
106 106
107 return true; 107 return true;
108 } 108 }
109 109
110 void GlobalShortcutListenerX11::RegisterAccelerator( 110 void GlobalShortcutListenerX11::RegisterAccelerator(
111 const ui::Accelerator& accelerator, 111 const ui::Accelerator& accelerator,
112 GlobalShortcutListener::Observer* observer) { 112 GlobalShortcutListener::Observer* observer) {
113 if (registered_hot_keys_.find(accelerator) != registered_hot_keys_.end()) {
114 // The shortcut has already been registered. Some shortcuts, such as
115 // MediaKeys can have multiple targets, all keyed off of the same
116 // accelerator.
117 return;
118 }
119
113 int modifiers = GetNativeModifiers(accelerator); 120 int modifiers = GetNativeModifiers(accelerator);
114 KeyCode keycode = XKeysymToKeycode(x_display_, accelerator.key_code()); 121 KeyCode keycode = XKeysymToKeycode(x_display_, accelerator.key_code());
115 base::X11ErrorTracker err_tracker; 122 base::X11ErrorTracker err_tracker;
116 123
117 // Because XGrabKey only works on the exact modifiers mask, we should register 124 // Because XGrabKey only works on the exact modifiers mask, we should register
118 // our hot keys with modifiers that we want to ignore, including Num lock, 125 // our hot keys with modifiers that we want to ignore, including Num lock,
119 // Caps lock, Scroll lock. See comment about |kModifiersMasks|. 126 // Caps lock, Scroll lock. See comment about |kModifiersMasks|.
120 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) { 127 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
121 XGrabKey(x_display_, keycode, modifiers | kModifiersMasks[i], 128 XGrabKey(x_display_, keycode, modifiers | kModifiersMasks[i],
122 x_root_window_, False, GrabModeAsync, GrabModeAsync); 129 x_root_window_, False, GrabModeAsync, GrabModeAsync);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 modifiers |= (x_event->xkey.state & ControlMask) ? ui::EF_CONTROL_DOWN : 0; 179 modifiers |= (x_event->xkey.state & ControlMask) ? ui::EF_CONTROL_DOWN : 0;
173 modifiers |= (x_event->xkey.state & Mod1Mask) ? ui::EF_ALT_DOWN : 0; 180 modifiers |= (x_event->xkey.state & Mod1Mask) ? ui::EF_ALT_DOWN : 0;
174 181
175 ui::Accelerator accelerator( 182 ui::Accelerator accelerator(
176 ui::KeyboardCodeFromXKeyEvent(x_event), modifiers); 183 ui::KeyboardCodeFromXKeyEvent(x_event), modifiers);
177 if (registered_hot_keys_.find(accelerator) != registered_hot_keys_.end()) 184 if (registered_hot_keys_.find(accelerator) != registered_hot_keys_.end())
178 instance.Get().NotifyKeyPressed(accelerator); 185 instance.Get().NotifyKeyPressed(accelerator);
179 } 186 }
180 187
181 } // namespace extensions 188 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698