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

Side by Side Diff: chrome/test/base/ui_controls_aurax11.cc

Issue 12226045: Linux/ChromeOS Chromium style checker cleanup, chrome/ edition part 1. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/ui_test_utils.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
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 class UIControlsX11 : public UIControlsAura { 80 class UIControlsX11 : public UIControlsAura {
81 public: 81 public:
82 UIControlsX11(aura::RootWindow* root_window) : root_window_(root_window) { 82 UIControlsX11(aura::RootWindow* root_window) : root_window_(root_window) {
83 } 83 }
84 84
85 virtual bool SendKeyPress(gfx::NativeWindow window, 85 virtual bool SendKeyPress(gfx::NativeWindow window,
86 ui::KeyboardCode key, 86 ui::KeyboardCode key,
87 bool control, 87 bool control,
88 bool shift, 88 bool shift,
89 bool alt, 89 bool alt,
90 bool command) { 90 bool command) OVERRIDE {
91 DCHECK(!command); // No command key on Aura 91 DCHECK(!command); // No command key on Aura
92 return SendKeyPressNotifyWhenDone( 92 return SendKeyPressNotifyWhenDone(
93 window, key, control, shift, alt, command, base::Closure()); 93 window, key, control, shift, alt, command, base::Closure());
94 } 94 }
95 virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, 95 virtual bool SendKeyPressNotifyWhenDone(
96 ui::KeyboardCode key, 96 gfx::NativeWindow window,
97 bool control, 97 ui::KeyboardCode key,
98 bool shift, 98 bool control,
99 bool alt, 99 bool shift,
100 bool command, 100 bool alt,
101 const base::Closure& closure) { 101 bool command,
102 const base::Closure& closure) OVERRIDE {
102 DCHECK(!command); // No command key on Aura 103 DCHECK(!command); // No command key on Aura
103 XEvent xevent = {0}; 104 XEvent xevent = {0};
104 xevent.xkey.type = KeyPress; 105 xevent.xkey.type = KeyPress;
105 if (control) 106 if (control)
106 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 107 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
107 if (shift) 108 if (shift)
108 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 109 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
109 if (alt) 110 if (alt)
110 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 111 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
111 xevent.xkey.keycode = 112 xevent.xkey.keycode =
112 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(), 113 XKeysymToKeycode(base::MessagePumpAuraX11::GetDefaultXDisplay(),
113 ui::XKeysymForWindowsKeyCode(key, shift)); 114 ui::XKeysymForWindowsKeyCode(key, shift));
114 root_window_->PostNativeEvent(&xevent); 115 root_window_->PostNativeEvent(&xevent);
115 116
116 // Send key release events. 117 // Send key release events.
117 xevent.xkey.type = KeyRelease; 118 xevent.xkey.type = KeyRelease;
118 root_window_->PostNativeEvent(&xevent); 119 root_window_->PostNativeEvent(&xevent);
119 if (alt) 120 if (alt)
120 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 121 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
121 if (shift) 122 if (shift)
122 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 123 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
123 if (control) 124 if (control)
124 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); 125 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
125 DCHECK(!xevent.xkey.state); 126 DCHECK(!xevent.xkey.state);
126 RunClosureAfterAllPendingUIEvents(closure); 127 RunClosureAfterAllPendingUIEvents(closure);
127 return true; 128 return true;
128 } 129 }
129 130
130 // Simulate a mouse move. (x,y) are absolute screen coordinates. 131 // Simulate a mouse move. (x,y) are absolute screen coordinates.
131 virtual bool SendMouseMove(long x, long y) { 132 virtual bool SendMouseMove(long x, long y) OVERRIDE {
132 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); 133 return SendMouseMoveNotifyWhenDone(x, y, base::Closure());
133 } 134 }
134 virtual bool SendMouseMoveNotifyWhenDone(long x, 135 virtual bool SendMouseMoveNotifyWhenDone(
135 long y, 136 long x,
136 const base::Closure& closure) { 137 long y,
138 const base::Closure& closure) OVERRIDE {
137 XEvent xevent = {0}; 139 XEvent xevent = {0};
138 XMotionEvent* xmotion = &xevent.xmotion; 140 XMotionEvent* xmotion = &xevent.xmotion;
139 xmotion->type = MotionNotify; 141 xmotion->type = MotionNotify;
140 gfx::Point point = ui::ConvertPointToPixel( 142 gfx::Point point = ui::ConvertPointToPixel(
141 root_window_->layer(), 143 root_window_->layer(),
142 gfx::Point(static_cast<int>(x), static_cast<int>(y))); 144 gfx::Point(static_cast<int>(x), static_cast<int>(y)));
143 g_current_x = xmotion->x = point.x(); 145 g_current_x = xmotion->x = point.x();
144 g_current_y = xmotion->y = point.y(); 146 g_current_y = xmotion->y = point.y();
145 xmotion->state = button_down_mask; 147 xmotion->state = button_down_mask;
146 xmotion->same_screen = True; 148 xmotion->same_screen = True;
147 // RootWindow will take care of other necessary fields. 149 // RootWindow will take care of other necessary fields.
148 root_window_->PostNativeEvent(&xevent); 150 root_window_->PostNativeEvent(&xevent);
149 RunClosureAfterAllPendingUIEvents(closure); 151 RunClosureAfterAllPendingUIEvents(closure);
150 return true; 152 return true;
151 } 153 }
152 virtual bool SendMouseEvents(MouseButton type, int state) { 154 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE {
153 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); 155 return SendMouseEventsNotifyWhenDone(type, state, base::Closure());
154 } 156 }
155 virtual bool SendMouseEventsNotifyWhenDone(MouseButton type, 157 virtual bool SendMouseEventsNotifyWhenDone(
156 int state, 158 MouseButton type,
157 const base::Closure& closure) { 159 int state,
160 const base::Closure& closure) OVERRIDE {
158 XEvent xevent = {0}; 161 XEvent xevent = {0};
159 XButtonEvent* xbutton = &xevent.xbutton; 162 XButtonEvent* xbutton = &xevent.xbutton;
160 DCHECK_NE(g_current_x, -1000); 163 DCHECK_NE(g_current_x, -1000);
161 DCHECK_NE(g_current_y, -1000); 164 DCHECK_NE(g_current_y, -1000);
162 xbutton->x = g_current_x; 165 xbutton->x = g_current_x;
163 xbutton->y = g_current_y; 166 xbutton->y = g_current_y;
164 xbutton->same_screen = True; 167 xbutton->same_screen = True;
165 switch (type) { 168 switch (type) {
166 case LEFT: 169 case LEFT:
167 xbutton->button = Button1; 170 xbutton->button = Button1;
(...skipping 15 matching lines...) Expand all
183 button_down_mask |= xbutton->state; 186 button_down_mask |= xbutton->state;
184 } 187 }
185 if (state & UP) { 188 if (state & UP) {
186 xevent.xbutton.type = ButtonRelease; 189 xevent.xbutton.type = ButtonRelease;
187 root_window_->PostNativeEvent(&xevent); 190 root_window_->PostNativeEvent(&xevent);
188 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; 191 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
189 } 192 }
190 RunClosureAfterAllPendingUIEvents(closure); 193 RunClosureAfterAllPendingUIEvents(closure);
191 return true; 194 return true;
192 } 195 }
193 virtual bool SendMouseClick(MouseButton type) { 196 virtual bool SendMouseClick(MouseButton type) OVERRIDE {
194 return SendMouseEvents(type, UP | DOWN); 197 return SendMouseEvents(type, UP | DOWN);
195 } 198 }
196 virtual void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { 199 virtual void RunClosureAfterAllPendingUIEvents(
200 const base::Closure& closure) OVERRIDE {
197 if (closure.is_null()) 201 if (closure.is_null())
198 return; 202 return;
199 static XEvent* marker_event = NULL; 203 static XEvent* marker_event = NULL;
200 if (!marker_event) { 204 if (!marker_event) {
201 marker_event = new XEvent(); 205 marker_event = new XEvent();
202 marker_event->xclient.type = ClientMessage; 206 marker_event->xclient.type = ClientMessage;
203 marker_event->xclient.display = NULL; 207 marker_event->xclient.display = NULL;
204 marker_event->xclient.window = None; 208 marker_event->xclient.window = None;
205 marker_event->xclient.format = 8; 209 marker_event->xclient.format = 8;
206 } 210 }
(...skipping 27 matching lines...) Expand all
234 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); 238 DISALLOW_COPY_AND_ASSIGN(UIControlsX11);
235 }; 239 };
236 240
237 } // namespace 241 } // namespace
238 242
239 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { 243 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) {
240 return new UIControlsX11(root_window); 244 return new UIControlsX11(root_window);
241 } 245 }
242 246
243 } // namespace ui_controls 247 } // namespace ui_controls
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698