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

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

Issue 710553002: aura: Remove WindowTreeHost::PostNativeEvent(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 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
« no previous file with comments | « ui/aura/remote_window_tree_host_win.cc ('k') | ui/aura/test/ui_controls_factory_ozone.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 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/client/screen_position_client.h" 10 #include "ui/aura/client/screen_position_client.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/test/aura_test_utils.h" 12 #include "ui/aura/test/aura_test_utils.h"
13 #include "ui/aura/test/ui_controls_factory_aura.h" 13 #include "ui/aura/test/ui_controls_factory_aura.h"
14 #include "ui/aura/test/x11_event_sender.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
16 #include "ui/base/test/ui_controls_aura.h" 17 #include "ui/base/test/ui_controls_aura.h"
17 #include "ui/base/x/x11_util.h" 18 #include "ui/base/x/x11_util.h"
18 #include "ui/compositor/dip_util.h" 19 #include "ui/compositor/dip_util.h"
19 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 20 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
20 #include "ui/events/test/platform_event_waiter.h" 21 #include "ui/events/test/platform_event_waiter.h"
21 22
22 namespace aura { 23 namespace aura {
23 namespace test { 24 namespace test {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 73 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
73 if (shift) 74 if (shift)
74 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 75 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
75 if (alt) 76 if (alt)
76 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 77 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
77 if (command) 78 if (command)
78 SetKeycodeAndSendThenMask(&xevent, XK_Meta_L, Mod4Mask); 79 SetKeycodeAndSendThenMask(&xevent, XK_Meta_L, Mod4Mask);
79 xevent.xkey.keycode = 80 xevent.xkey.keycode =
80 XKeysymToKeycode(gfx::GetXDisplay(), 81 XKeysymToKeycode(gfx::GetXDisplay(),
81 ui::XKeysymForWindowsKeyCode(key, shift)); 82 ui::XKeysymForWindowsKeyCode(key, shift));
82 host_->PostNativeEvent(&xevent); 83 PostEventToWindowTreeHost(xevent, host_);
83 84
84 // Send key release events. 85 // Send key release events.
85 xevent.xkey.type = KeyRelease; 86 xevent.xkey.type = KeyRelease;
86 host_->PostNativeEvent(&xevent); 87 PostEventToWindowTreeHost(xevent, host_);
87 if (alt) 88 if (alt)
88 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 89 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
89 if (shift) 90 if (shift)
90 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 91 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
91 if (control) 92 if (control)
92 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); 93 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
93 if (command) 94 if (command)
94 UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Meta_L); 95 UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Meta_L);
95 DCHECK(!xevent.xkey.state); 96 DCHECK(!xevent.xkey.state);
96 RunClosureAfterAllPendingUIEvents(closure); 97 RunClosureAfterAllPendingUIEvents(closure);
(...skipping 23 matching lines...) Expand all
120 host_->window()->MoveCursorTo(root_location); 121 host_->window()->MoveCursorTo(root_location);
121 } else { 122 } else {
122 XEvent xevent = {0}; 123 XEvent xevent = {0};
123 XMotionEvent* xmotion = &xevent.xmotion; 124 XMotionEvent* xmotion = &xevent.xmotion;
124 xmotion->type = MotionNotify; 125 xmotion->type = MotionNotify;
125 xmotion->x = root_location.x(); 126 xmotion->x = root_location.x();
126 xmotion->y = root_location.y(); 127 xmotion->y = root_location.y();
127 xmotion->state = button_down_mask; 128 xmotion->state = button_down_mask;
128 xmotion->same_screen = True; 129 xmotion->same_screen = True;
129 // WindowTreeHost will take care of other necessary fields. 130 // WindowTreeHost will take care of other necessary fields.
130 host_->PostNativeEvent(&xevent); 131 PostEventToWindowTreeHost(xevent, host_);
131 } 132 }
132 RunClosureAfterAllPendingUIEvents(closure); 133 RunClosureAfterAllPendingUIEvents(closure);
133 return true; 134 return true;
134 } 135 }
135 bool SendMouseEvents(MouseButton type, int state) override { 136 bool SendMouseEvents(MouseButton type, int state) override {
136 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); 137 return SendMouseEventsNotifyWhenDone(type, state, base::Closure());
137 } 138 }
138 bool SendMouseEventsNotifyWhenDone(MouseButton type, 139 bool SendMouseEventsNotifyWhenDone(MouseButton type,
139 int state, 140 int state,
140 const base::Closure& closure) override { 141 const base::Closure& closure) override {
(...skipping 19 matching lines...) Expand all
160 xbutton->state = Button2Mask; 161 xbutton->state = Button2Mask;
161 break; 162 break;
162 case RIGHT: 163 case RIGHT:
163 xbutton->button = Button3; 164 xbutton->button = Button3;
164 xbutton->state = Button3Mask; 165 xbutton->state = Button3Mask;
165 break; 166 break;
166 } 167 }
167 // WindowEventDispatcher will take care of other necessary fields. 168 // WindowEventDispatcher will take care of other necessary fields.
168 if (state & DOWN) { 169 if (state & DOWN) {
169 xevent.xbutton.type = ButtonPress; 170 xevent.xbutton.type = ButtonPress;
170 host_->PostNativeEvent(&xevent); 171 PostEventToWindowTreeHost(xevent, host_);
171 button_down_mask |= xbutton->state; 172 button_down_mask |= xbutton->state;
172 } 173 }
173 if (state & UP) { 174 if (state & UP) {
174 xevent.xbutton.type = ButtonRelease; 175 xevent.xbutton.type = ButtonRelease;
175 host_->PostNativeEvent(&xevent); 176 PostEventToWindowTreeHost(xevent, host_);
176 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; 177 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
177 } 178 }
178 RunClosureAfterAllPendingUIEvents(closure); 179 RunClosureAfterAllPendingUIEvents(closure);
179 return true; 180 return true;
180 } 181 }
181 bool SendMouseClick(MouseButton type) override { 182 bool SendMouseClick(MouseButton type) override {
182 return SendMouseEvents(type, UP | DOWN); 183 return SendMouseEvents(type, UP | DOWN);
183 } 184 }
184 void RunClosureAfterAllPendingUIEvents( 185 void RunClosureAfterAllPendingUIEvents(
185 const base::Closure& closure) override { 186 const base::Closure& closure) override {
186 if (closure.is_null()) 187 if (closure.is_null())
187 return; 188 return;
188 static XEvent* marker_event = NULL; 189 static XEvent* marker_event = NULL;
189 if (!marker_event) { 190 if (!marker_event) {
190 marker_event = new XEvent(); 191 marker_event = new XEvent();
191 marker_event->xclient.type = ClientMessage; 192 marker_event->xclient.type = ClientMessage;
192 marker_event->xclient.display = NULL; 193 marker_event->xclient.display = NULL;
193 marker_event->xclient.window = None; 194 marker_event->xclient.window = None;
194 marker_event->xclient.format = 8; 195 marker_event->xclient.format = 8;
195 } 196 }
196 marker_event->xclient.message_type = MarkerEventAtom(); 197 marker_event->xclient.message_type = MarkerEventAtom();
197 host_->PostNativeEvent(marker_event); 198 PostEventToWindowTreeHost(*marker_event, host_);
198 ui::PlatformEventWaiter::Create(closure, base::Bind(&Matcher)); 199 ui::PlatformEventWaiter::Create(closure, base::Bind(&Matcher));
199 } 200 }
200 private: 201 private:
201 void SetKeycodeAndSendThenMask(XEvent* xevent, 202 void SetKeycodeAndSendThenMask(XEvent* xevent,
202 KeySym keysym, 203 KeySym keysym,
203 unsigned int mask) { 204 unsigned int mask) {
204 xevent->xkey.keycode = 205 xevent->xkey.keycode =
205 XKeysymToKeycode(gfx::GetXDisplay(), keysym); 206 XKeysymToKeycode(gfx::GetXDisplay(), keysym);
206 host_->PostNativeEvent(xevent); 207 PostEventToWindowTreeHost(*xevent, host_);
207 xevent->xkey.state |= mask; 208 xevent->xkey.state |= mask;
208 } 209 }
209 210
210 void UnmaskAndSetKeycodeThenSend(XEvent* xevent, 211 void UnmaskAndSetKeycodeThenSend(XEvent* xevent,
211 unsigned int mask, 212 unsigned int mask,
212 KeySym keysym) { 213 KeySym keysym) {
213 xevent->xkey.state ^= mask; 214 xevent->xkey.state ^= mask;
214 xevent->xkey.keycode = 215 xevent->xkey.keycode =
215 XKeysymToKeycode(gfx::GetXDisplay(), keysym); 216 XKeysymToKeycode(gfx::GetXDisplay(), keysym);
216 host_->PostNativeEvent(xevent); 217 PostEventToWindowTreeHost(*xevent, host_);
217 } 218 }
218 219
219 WindowTreeHost* host_; 220 WindowTreeHost* host_;
220 221
221 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); 222 DISALLOW_COPY_AND_ASSIGN(UIControlsX11);
222 }; 223 };
223 224
224 } // namespace 225 } // namespace
225 226
226 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { 227 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
227 return new UIControlsX11(host); 228 return new UIControlsX11(host);
228 } 229 }
229 230
230 } // namespace test 231 } // namespace test
231 } // namespace aura 232 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/remote_window_tree_host_win.cc ('k') | ui/aura/test/ui_controls_factory_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698