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

Side by Side Diff: ui/aura/ui_controls_x11.cc

Issue 10441028: aura/cros: Rename MessagePump{X => AuraX11} and move the atom cache into it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error in file added in the interim Created 8 years, 6 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
« no previous file with comments | « ui/aura/root_window_host_linux.cc ('k') | ui/aura/x11_atom_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <X11/keysym.h> 5 #include <X11/keysym.h>
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 7
8 // X macro fail. 8 // X macro fail.
9 #if defined(RootWindow) 9 #if defined(RootWindow)
10 #undef RootWindow 10 #undef RootWindow
11 #endif 11 #endif
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_pump_x.h" 14 #include "base/message_pump_aurax11.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/aura/ui_controls_aura.h" 16 #include "ui/aura/ui_controls_aura.h"
17 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 17 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
18 #include "ui/ui_controls/ui_controls_aura.h" 18 #include "ui/ui_controls/ui_controls_aura.h"
19 19
20 namespace aura { 20 namespace aura {
21 namespace { 21 namespace {
22 22
23 // Mask of the buttons currently down. 23 // Mask of the buttons currently down.
24 unsigned button_down_mask = 0; 24 unsigned button_down_mask = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 EventWaiterMatcher matcher_; 58 EventWaiterMatcher matcher_;
59 DISALLOW_COPY_AND_ASSIGN(EventWaiter); 59 DISALLOW_COPY_AND_ASSIGN(EventWaiter);
60 }; 60 };
61 61
62 // Latest mouse pointer location set by SendMouseMoveNotifyWhenDone. 62 // Latest mouse pointer location set by SendMouseMoveNotifyWhenDone.
63 int g_current_x = -1000; 63 int g_current_x = -1000;
64 int g_current_y = -1000; 64 int g_current_y = -1000;
65 65
66 // Returns atom that indidates that the XEvent is marker event. 66 // Returns atom that indidates that the XEvent is marker event.
67 Atom MarkerEventAtom() { 67 Atom MarkerEventAtom() {
68 return XInternAtom(base::MessagePumpX::GetDefaultXDisplay(), 68 return XInternAtom(base::MessagePumpAuraX11::GetDefaultXDisplay(),
69 "marker_event", 69 "marker_event",
70 False); 70 False);
71 } 71 }
72 72
73 // Returns true when the event is a marker event. 73 // Returns true when the event is a marker event.
74 bool Matcher(const base::NativeEvent& event) { 74 bool Matcher(const base::NativeEvent& event) {
75 return event->xany.type == ClientMessage && 75 return event->xany.type == ClientMessage &&
76 event->xclient.message_type == MarkerEventAtom(); 76 event->xclient.message_type == MarkerEventAtom();
77 } 77 }
78 78
(...skipping 22 matching lines...) Expand all
101 DCHECK(!command); // No command key on Aura 101 DCHECK(!command); // No command key on Aura
102 XEvent xevent = {0}; 102 XEvent xevent = {0};
103 xevent.xkey.type = KeyPress; 103 xevent.xkey.type = KeyPress;
104 if (control) 104 if (control)
105 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 105 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
106 if (shift) 106 if (shift)
107 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 107 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
108 if (alt) 108 if (alt)
109 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 109 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
110 xevent.xkey.keycode = 110 xevent.xkey.keycode =
111 XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), 111 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(),
112 ui::XKeysymForWindowsKeyCode(key, shift)); 112 ui::XKeysymForWindowsKeyCode(key, shift));
113 root_window_->PostNativeEvent(&xevent); 113 root_window_->PostNativeEvent(&xevent);
114 114
115 // Send key release events. 115 // Send key release events.
116 xevent.xkey.type = KeyRelease; 116 xevent.xkey.type = KeyRelease;
117 root_window_->PostNativeEvent(&xevent); 117 root_window_->PostNativeEvent(&xevent);
118 if (alt) 118 if (alt)
119 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 119 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
120 if (shift) 120 if (shift)
121 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 121 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 marker_event->xclient.message_type = MarkerEventAtom(); 203 marker_event->xclient.message_type = MarkerEventAtom();
204 root_window_->PostNativeEvent(marker_event); 204 root_window_->PostNativeEvent(marker_event);
205 new EventWaiter(closure, &Matcher); 205 new EventWaiter(closure, &Matcher);
206 } 206 }
207 private: 207 private:
208 void SetKeycodeAndSendThenMask(XEvent* xevent, 208 void SetKeycodeAndSendThenMask(XEvent* xevent,
209 KeySym keysym, 209 KeySym keysym,
210 unsigned int mask) { 210 unsigned int mask) {
211 xevent->xkey.keycode = 211 xevent->xkey.keycode =
212 XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), 212 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(),
213 keysym); 213 keysym);
214 root_window_->PostNativeEvent(xevent); 214 root_window_->PostNativeEvent(xevent);
215 xevent->xkey.state |= mask; 215 xevent->xkey.state |= mask;
216 } 216 }
217 217
218 void UnmaskAndSetKeycodeThenSend(XEvent* xevent, 218 void UnmaskAndSetKeycodeThenSend(XEvent* xevent,
219 unsigned int mask, 219 unsigned int mask,
220 KeySym keysym) { 220 KeySym keysym) {
221 xevent->xkey.state ^= mask; 221 xevent->xkey.state ^= mask;
222 xevent->xkey.keycode = 222 xevent->xkey.keycode =
223 XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), 223 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(),
224 keysym); 224 keysym);
225 root_window_->PostNativeEvent(xevent); 225 root_window_->PostNativeEvent(xevent);
226 } 226 }
227 227
228 RootWindow* root_window_; 228 RootWindow* root_window_;
229 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); 229 DISALLOW_COPY_AND_ASSIGN(UIControlsX11);
230 }; 230 };
231 231
232 } // namespace 232 } // namespace
233 233
234 ui_controls::UIControlsAura* CreateUIControlsAura(RootWindow* root_window) { 234 ui_controls::UIControlsAura* CreateUIControlsAura(RootWindow* root_window) {
235 return new UIControlsX11(root_window); 235 return new UIControlsX11(root_window);
236 } 236 }
237 237
238 } // namespace aura 238 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_linux.cc ('k') | ui/aura/x11_atom_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698