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

Side by Side Diff: ui/aura/test/ui_controls_factory_aurax11.cc

Issue 23880006: gtk: Allow building both the X11 and Gtk message-pumps for gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 7 years, 3 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_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.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 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 <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_loop/message_pump_aurax11.h" 14 #include "base/message_loop/message_pump_x11.h"
15 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
16 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
17 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
18 #include "ui/aura/test/ui_controls_factory_aura.h" 18 #include "ui/aura/test/ui_controls_factory_aura.h"
19 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 19 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
20 #include "ui/base/test/ui_controls_aura.h" 20 #include "ui/base/test/ui_controls_aura.h"
21 #include "ui/compositor/dip_util.h" 21 #include "ui/compositor/dip_util.h"
22 22
23 namespace aura { 23 namespace aura {
24 namespace test { 24 namespace test {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 private: 68 private:
69 base::Closure closure_; 69 base::Closure closure_;
70 EventWaiterMatcher matcher_; 70 EventWaiterMatcher matcher_;
71 DISALLOW_COPY_AND_ASSIGN(EventWaiter); 71 DISALLOW_COPY_AND_ASSIGN(EventWaiter);
72 }; 72 };
73 73
74 // Returns atom that indidates that the XEvent is marker event. 74 // Returns atom that indidates that the XEvent is marker event.
75 Atom MarkerEventAtom() { 75 Atom MarkerEventAtom() {
76 return XInternAtom(base::MessagePumpAuraX11::GetDefaultXDisplay(), 76 return XInternAtom(base::MessagePumpX11::GetDefaultXDisplay(),
77 "marker_event", 77 "marker_event",
78 False); 78 False);
79 } 79 }
80 80
81 // Returns true when the event is a marker event. 81 // Returns true when the event is a marker event.
82 bool Matcher(const base::NativeEvent& event) { 82 bool Matcher(const base::NativeEvent& event) {
83 return event->xany.type == ClientMessage && 83 return event->xany.type == ClientMessage &&
84 event->xclient.message_type == MarkerEventAtom(); 84 event->xclient.message_type == MarkerEventAtom();
85 } 85 }
86 86
(...skipping 23 matching lines...) Expand all
110 DCHECK(!command); // No command key on Aura 110 DCHECK(!command); // No command key on Aura
111 XEvent xevent = {0}; 111 XEvent xevent = {0};
112 xevent.xkey.type = KeyPress; 112 xevent.xkey.type = KeyPress;
113 if (control) 113 if (control)
114 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 114 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
115 if (shift) 115 if (shift)
116 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 116 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
117 if (alt) 117 if (alt)
118 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 118 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
119 xevent.xkey.keycode = 119 xevent.xkey.keycode =
120 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(), 120 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
121 ui::XKeysymForWindowsKeyCode(key, shift)); 121 ui::XKeysymForWindowsKeyCode(key, shift));
122 root_window_->PostNativeEvent(&xevent); 122 root_window_->PostNativeEvent(&xevent);
123 123
124 // Send key release events. 124 // Send key release events.
125 xevent.xkey.type = KeyRelease; 125 xevent.xkey.type = KeyRelease;
126 root_window_->PostNativeEvent(&xevent); 126 root_window_->PostNativeEvent(&xevent);
127 if (alt) 127 if (alt)
128 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 128 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
129 if (shift) 129 if (shift)
130 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 130 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 marker_event->xclient.message_type = MarkerEventAtom(); 221 marker_event->xclient.message_type = MarkerEventAtom();
222 root_window_->PostNativeEvent(marker_event); 222 root_window_->PostNativeEvent(marker_event);
223 new EventWaiter(closure, &Matcher); 223 new EventWaiter(closure, &Matcher);
224 } 224 }
225 private: 225 private:
226 void SetKeycodeAndSendThenMask(XEvent* xevent, 226 void SetKeycodeAndSendThenMask(XEvent* xevent,
227 KeySym keysym, 227 KeySym keysym,
228 unsigned int mask) { 228 unsigned int mask) {
229 xevent->xkey.keycode = 229 xevent->xkey.keycode =
230 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(), 230 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
231 keysym); 231 keysym);
232 root_window_->PostNativeEvent(xevent); 232 root_window_->PostNativeEvent(xevent);
233 xevent->xkey.state |= mask; 233 xevent->xkey.state |= mask;
234 } 234 }
235 235
236 void UnmaskAndSetKeycodeThenSend(XEvent* xevent, 236 void UnmaskAndSetKeycodeThenSend(XEvent* xevent,
237 unsigned int mask, 237 unsigned int mask,
238 KeySym keysym) { 238 KeySym keysym) {
239 xevent->xkey.state ^= mask; 239 xevent->xkey.state ^= mask;
240 xevent->xkey.keycode = 240 xevent->xkey.keycode =
241 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(), 241 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
242 keysym); 242 keysym);
243 root_window_->PostNativeEvent(xevent); 243 root_window_->PostNativeEvent(xevent);
244 } 244 }
245 245
246 aura::RootWindow* root_window_; 246 aura::RootWindow* root_window_;
247 247
248 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); 248 DISALLOW_COPY_AND_ASSIGN(UIControlsX11);
249 }; 249 };
250 250
251 } // namespace 251 } // namespace
252 252
253 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { 253 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) {
254 return new UIControlsX11(root_window); 254 return new UIControlsX11(root_window);
255 } 255 }
256 256
257 } // namespace test 257 } // namespace test
258 } // namespace aura 258 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698