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

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

Issue 684483002: Standardize usage of virtual/override/final specifiers. (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/test/test_window_tree_client.h ('k') | ui/aura/window_delegate.h » ('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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 bool Matcher(const base::NativeEvent& event) { 43 bool Matcher(const base::NativeEvent& event) {
44 return event->xany.type == ClientMessage && 44 return event->xany.type == ClientMessage &&
45 event->xclient.message_type == MarkerEventAtom(); 45 event->xclient.message_type == MarkerEventAtom();
46 } 46 }
47 47
48 class UIControlsX11 : public UIControlsAura { 48 class UIControlsX11 : public UIControlsAura {
49 public: 49 public:
50 UIControlsX11(WindowTreeHost* host) : host_(host) { 50 UIControlsX11(WindowTreeHost* host) : host_(host) {
51 } 51 }
52 52
53 virtual bool SendKeyPress(gfx::NativeWindow window, 53 bool SendKeyPress(gfx::NativeWindow window,
54 ui::KeyboardCode key, 54 ui::KeyboardCode key,
55 bool control, 55 bool control,
56 bool shift, 56 bool shift,
57 bool alt, 57 bool alt,
58 bool command) override { 58 bool command) override {
59 return SendKeyPressNotifyWhenDone( 59 return SendKeyPressNotifyWhenDone(
60 window, key, control, shift, alt, command, base::Closure()); 60 window, key, control, shift, alt, command, base::Closure());
61 } 61 }
62 virtual bool SendKeyPressNotifyWhenDone( 62 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
63 gfx::NativeWindow window, 63 ui::KeyboardCode key,
64 ui::KeyboardCode key, 64 bool control,
65 bool control, 65 bool shift,
66 bool shift, 66 bool alt,
67 bool alt, 67 bool command,
68 bool command, 68 const base::Closure& closure) override {
69 const base::Closure& closure) override {
70 XEvent xevent = {0}; 69 XEvent xevent = {0};
71 xevent.xkey.type = KeyPress; 70 xevent.xkey.type = KeyPress;
72 if (control) 71 if (control)
73 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); 72 SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
74 if (shift) 73 if (shift)
75 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); 74 SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
76 if (alt) 75 if (alt)
77 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); 76 SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
78 if (command) 77 if (command)
79 SetKeycodeAndSendThenMask(&xevent, XK_Meta_L, Mod4Mask); 78 SetKeycodeAndSendThenMask(&xevent, XK_Meta_L, Mod4Mask);
(...skipping 11 matching lines...) Expand all
91 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 90 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
92 if (control) 91 if (control)
93 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); 92 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
94 if (command) 93 if (command)
95 UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Meta_L); 94 UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Meta_L);
96 DCHECK(!xevent.xkey.state); 95 DCHECK(!xevent.xkey.state);
97 RunClosureAfterAllPendingUIEvents(closure); 96 RunClosureAfterAllPendingUIEvents(closure);
98 return true; 97 return true;
99 } 98 }
100 99
101 virtual bool SendMouseMove(long screen_x, long screen_y) override { 100 bool SendMouseMove(long screen_x, long screen_y) override {
102 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); 101 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure());
103 } 102 }
104 virtual bool SendMouseMoveNotifyWhenDone( 103 bool SendMouseMoveNotifyWhenDone(long screen_x,
105 long screen_x, 104 long screen_y,
106 long screen_y, 105 const base::Closure& closure) override {
107 const base::Closure& closure) override {
108 gfx::Point root_location(screen_x, screen_y); 106 gfx::Point root_location(screen_x, screen_y);
109 aura::client::ScreenPositionClient* screen_position_client = 107 aura::client::ScreenPositionClient* screen_position_client =
110 aura::client::GetScreenPositionClient(host_->window()); 108 aura::client::GetScreenPositionClient(host_->window());
111 if (screen_position_client) { 109 if (screen_position_client) {
112 screen_position_client->ConvertPointFromScreen(host_->window(), 110 screen_position_client->ConvertPointFromScreen(host_->window(),
113 &root_location); 111 &root_location);
114 } 112 }
115 gfx::Point root_current_location = 113 gfx::Point root_current_location =
116 QueryLatestMousePositionRequestInHost(host_); 114 QueryLatestMousePositionRequestInHost(host_);
117 host_->ConvertPointFromHost(&root_current_location); 115 host_->ConvertPointFromHost(&root_current_location);
118 116
119 if (root_location != root_current_location && button_down_mask == 0) { 117 if (root_location != root_current_location && button_down_mask == 0) {
120 // Move the cursor because EnterNotify/LeaveNotify are generated with the 118 // Move the cursor because EnterNotify/LeaveNotify are generated with the
121 // current mouse position as a result of XGrabPointer() 119 // current mouse position as a result of XGrabPointer()
122 host_->window()->MoveCursorTo(root_location); 120 host_->window()->MoveCursorTo(root_location);
123 } else { 121 } else {
124 XEvent xevent = {0}; 122 XEvent xevent = {0};
125 XMotionEvent* xmotion = &xevent.xmotion; 123 XMotionEvent* xmotion = &xevent.xmotion;
126 xmotion->type = MotionNotify; 124 xmotion->type = MotionNotify;
127 xmotion->x = root_location.x(); 125 xmotion->x = root_location.x();
128 xmotion->y = root_location.y(); 126 xmotion->y = root_location.y();
129 xmotion->state = button_down_mask; 127 xmotion->state = button_down_mask;
130 xmotion->same_screen = True; 128 xmotion->same_screen = True;
131 // WindowTreeHost will take care of other necessary fields. 129 // WindowTreeHost will take care of other necessary fields.
132 host_->PostNativeEvent(&xevent); 130 host_->PostNativeEvent(&xevent);
133 } 131 }
134 RunClosureAfterAllPendingUIEvents(closure); 132 RunClosureAfterAllPendingUIEvents(closure);
135 return true; 133 return true;
136 } 134 }
137 virtual bool SendMouseEvents(MouseButton type, int state) override { 135 bool SendMouseEvents(MouseButton type, int state) override {
138 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); 136 return SendMouseEventsNotifyWhenDone(type, state, base::Closure());
139 } 137 }
140 virtual bool SendMouseEventsNotifyWhenDone( 138 bool SendMouseEventsNotifyWhenDone(MouseButton type,
141 MouseButton type, 139 int state,
142 int state, 140 const base::Closure& closure) override {
143 const base::Closure& closure) override {
144 XEvent xevent = {0}; 141 XEvent xevent = {0};
145 XButtonEvent* xbutton = &xevent.xbutton; 142 XButtonEvent* xbutton = &xevent.xbutton;
146 gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location(); 143 gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location();
147 aura::client::ScreenPositionClient* screen_position_client = 144 aura::client::ScreenPositionClient* screen_position_client =
148 aura::client::GetScreenPositionClient(host_->window()); 145 aura::client::GetScreenPositionClient(host_->window());
149 if (screen_position_client) { 146 if (screen_position_client) {
150 screen_position_client->ConvertPointFromScreen(host_->window(), 147 screen_position_client->ConvertPointFromScreen(host_->window(),
151 &mouse_loc); 148 &mouse_loc);
152 } 149 }
153 xbutton->x = mouse_loc.x(); 150 xbutton->x = mouse_loc.x();
(...skipping 20 matching lines...) Expand all
174 button_down_mask |= xbutton->state; 171 button_down_mask |= xbutton->state;
175 } 172 }
176 if (state & UP) { 173 if (state & UP) {
177 xevent.xbutton.type = ButtonRelease; 174 xevent.xbutton.type = ButtonRelease;
178 host_->PostNativeEvent(&xevent); 175 host_->PostNativeEvent(&xevent);
179 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; 176 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
180 } 177 }
181 RunClosureAfterAllPendingUIEvents(closure); 178 RunClosureAfterAllPendingUIEvents(closure);
182 return true; 179 return true;
183 } 180 }
184 virtual bool SendMouseClick(MouseButton type) override { 181 bool SendMouseClick(MouseButton type) override {
185 return SendMouseEvents(type, UP | DOWN); 182 return SendMouseEvents(type, UP | DOWN);
186 } 183 }
187 virtual void RunClosureAfterAllPendingUIEvents( 184 void RunClosureAfterAllPendingUIEvents(
188 const base::Closure& closure) override { 185 const base::Closure& closure) override {
189 if (closure.is_null()) 186 if (closure.is_null())
190 return; 187 return;
191 static XEvent* marker_event = NULL; 188 static XEvent* marker_event = NULL;
192 if (!marker_event) { 189 if (!marker_event) {
193 marker_event = new XEvent(); 190 marker_event = new XEvent();
194 marker_event->xclient.type = ClientMessage; 191 marker_event->xclient.type = ClientMessage;
195 marker_event->xclient.display = NULL; 192 marker_event->xclient.display = NULL;
196 marker_event->xclient.window = None; 193 marker_event->xclient.window = None;
197 marker_event->xclient.format = 8; 194 marker_event->xclient.format = 8;
(...skipping 27 matching lines...) Expand all
225 }; 222 };
226 223
227 } // namespace 224 } // namespace
228 225
229 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { 226 UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) {
230 return new UIControlsX11(host); 227 return new UIControlsX11(host);
231 } 228 }
232 229
233 } // namespace test 230 } // namespace test
234 } // namespace aura 231 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/test_window_tree_client.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698