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

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

Issue 23943010: Revert 223621 "x11: Prefer using ui::GetXDisplay() over getting ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | « trunk/src/ui/aura/root_window_host_x11.cc ('k') | trunk/src/ui/base/x/events_x.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_x11.h"
14 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
15 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
16 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
17 #include "ui/aura/test/ui_controls_factory_aura.h" 18 #include "ui/aura/test/ui_controls_factory_aura.h"
18 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 19 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
19 #include "ui/base/test/ui_controls_aura.h" 20 #include "ui/base/test/ui_controls_aura.h"
20 #include "ui/base/x/x11_util.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 {
25 namespace { 25 namespace {
26 26
27 using ui_controls::DOWN; 27 using ui_controls::DOWN;
28 using ui_controls::LEFT; 28 using ui_controls::LEFT;
29 using ui_controls::MIDDLE; 29 using ui_controls::MIDDLE;
30 using ui_controls::MouseButton; 30 using ui_controls::MouseButton;
(...skipping 35 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(ui::GetXDisplay(), "marker_event", False); 76 return XInternAtom(base::MessagePumpX11::GetDefaultXDisplay(),
77 "marker_event",
78 False);
77 } 79 }
78 80
79 // Returns true when the event is a marker event. 81 // Returns true when the event is a marker event.
80 bool Matcher(const base::NativeEvent& event) { 82 bool Matcher(const base::NativeEvent& event) {
81 return event->xany.type == ClientMessage && 83 return event->xany.type == ClientMessage &&
82 event->xclient.message_type == MarkerEventAtom(); 84 event->xclient.message_type == MarkerEventAtom();
83 } 85 }
84 86
85 class UIControlsX11 : public UIControlsAura { 87 class UIControlsX11 : public UIControlsAura {
86 public: 88 public:
(...skipping 21 matching lines...) Expand all
108 DCHECK(!command); // No command key on Aura 110 DCHECK(!command); // No command key on Aura
109 XEvent xevent = {0}; 111 XEvent xevent = {0};
110 xevent.xkey.type = KeyPress; 112 xevent.xkey.type = KeyPress;
111 if (control) 113 if (control)
112 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 114 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
113 if (shift) 115 if (shift)
114 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 116 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
115 if (alt) 117 if (alt)
116 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 118 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
117 xevent.xkey.keycode = 119 xevent.xkey.keycode =
118 XKeysymToKeycode(ui::GetXDisplay(), 120 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
119 ui::XKeysymForWindowsKeyCode(key, shift)); 121 ui::XKeysymForWindowsKeyCode(key, shift));
120 root_window_->PostNativeEvent(&xevent); 122 root_window_->PostNativeEvent(&xevent);
121 123
122 // Send key release events. 124 // Send key release events.
123 xevent.xkey.type = KeyRelease; 125 xevent.xkey.type = KeyRelease;
124 root_window_->PostNativeEvent(&xevent); 126 root_window_->PostNativeEvent(&xevent);
125 if (alt) 127 if (alt)
126 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 128 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
127 if (shift) 129 if (shift)
128 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
218 } 220 }
219 marker_event->xclient.message_type = MarkerEventAtom(); 221 marker_event->xclient.message_type = MarkerEventAtom();
220 root_window_->PostNativeEvent(marker_event); 222 root_window_->PostNativeEvent(marker_event);
221 new EventWaiter(closure, &Matcher); 223 new EventWaiter(closure, &Matcher);
222 } 224 }
223 private: 225 private:
224 void SetKeycodeAndSendThenMask(XEvent* xevent, 226 void SetKeycodeAndSendThenMask(XEvent* xevent,
225 KeySym keysym, 227 KeySym keysym,
226 unsigned int mask) { 228 unsigned int mask) {
227 xevent->xkey.keycode = 229 xevent->xkey.keycode =
228 XKeysymToKeycode(ui::GetXDisplay(), keysym); 230 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
231 keysym);
229 root_window_->PostNativeEvent(xevent); 232 root_window_->PostNativeEvent(xevent);
230 xevent->xkey.state |= mask; 233 xevent->xkey.state |= mask;
231 } 234 }
232 235
233 void UnmaskAndSetKeycodeThenSend(XEvent* xevent, 236 void UnmaskAndSetKeycodeThenSend(XEvent* xevent,
234 unsigned int mask, 237 unsigned int mask,
235 KeySym keysym) { 238 KeySym keysym) {
236 xevent->xkey.state ^= mask; 239 xevent->xkey.state ^= mask;
237 xevent->xkey.keycode = 240 xevent->xkey.keycode =
238 XKeysymToKeycode(ui::GetXDisplay(), keysym); 241 XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
242 keysym);
239 root_window_->PostNativeEvent(xevent); 243 root_window_->PostNativeEvent(xevent);
240 } 244 }
241 245
242 aura::RootWindow* root_window_; 246 aura::RootWindow* root_window_;
243 247
244 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); 248 DISALLOW_COPY_AND_ASSIGN(UIControlsX11);
245 }; 249 };
246 250
247 } // namespace 251 } // namespace
248 252
249 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { 253 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) {
250 return new UIControlsX11(root_window); 254 return new UIControlsX11(root_window);
251 } 255 }
252 256
253 } // namespace test 257 } // namespace test
254 } // namespace aura 258 } // namespace aura
OLDNEW
« no previous file with comments | « trunk/src/ui/aura/root_window_host_x11.cc ('k') | trunk/src/ui/base/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698