OLD | NEW |
---|---|
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 XEvent xevent = {0}; | 159 XEvent xevent = {0}; |
160 XButtonEvent* xbutton = &xevent.xbutton; | 160 XButtonEvent* xbutton = &xevent.xbutton; |
161 gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location(); | 161 gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location(); |
162 aura::client::ScreenPositionClient* screen_position_client = | 162 aura::client::ScreenPositionClient* screen_position_client = |
163 aura::client::GetScreenPositionClient(root_window_); | 163 aura::client::GetScreenPositionClient(root_window_); |
164 if (screen_position_client) | 164 if (screen_position_client) |
165 screen_position_client->ConvertPointFromScreen(root_window_, &mouse_loc); | 165 screen_position_client->ConvertPointFromScreen(root_window_, &mouse_loc); |
166 xbutton->x = mouse_loc.x(); | 166 xbutton->x = mouse_loc.x(); |
167 xbutton->y = mouse_loc.y(); | 167 xbutton->y = mouse_loc.y(); |
168 xbutton->same_screen = True; | 168 xbutton->same_screen = True; |
169 // According to http://tronche.com/gui/x/xlib/events/keyboard-pointer/ | |
dcheng
2013/04/18 21:10:34
Nit: Just looking at the diff, it's not 100% clear
| |
170 // keyboard-pointer.html#XButtonEvent, the state should be set to the | |
171 // button state just prior to the event. | |
172 xbutton->state = button_down_mask; | |
173 unsigned button = 0; | |
169 switch (type) { | 174 switch (type) { |
170 case LEFT: | 175 case LEFT: |
171 xbutton->button = Button1; | 176 xbutton->button = Button1; |
172 xbutton->state = Button1Mask; | 177 button = Button1Mask; |
173 break; | 178 break; |
174 case MIDDLE: | 179 case MIDDLE: |
175 xbutton->button = Button2; | 180 xbutton->button = Button2; |
176 xbutton->state = Button2Mask; | 181 button = Button2Mask; |
177 break; | 182 break; |
178 case RIGHT: | 183 case RIGHT: |
179 xbutton->button = Button3; | 184 xbutton->button = Button3; |
180 xbutton->state = Button3Mask; | 185 button = Button3Mask; |
181 break; | 186 break; |
182 } | 187 } |
183 // RootWindow will take care of other necessary fields. | 188 // RootWindow will take care of other necessary fields. |
184 if (state & DOWN) { | 189 if (state & DOWN) { |
185 xevent.xbutton.type = ButtonPress; | 190 xevent.xbutton.type = ButtonPress; |
186 root_window_->PostNativeEvent(&xevent); | 191 root_window_->PostNativeEvent(&xevent); |
187 button_down_mask |= xbutton->state; | 192 button_down_mask |= button; |
188 } | 193 } |
189 if (state & UP) { | 194 if (state & UP) { |
190 xevent.xbutton.type = ButtonRelease; | 195 xevent.xbutton.type = ButtonRelease; |
191 root_window_->PostNativeEvent(&xevent); | 196 root_window_->PostNativeEvent(&xevent); |
192 button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; | 197 button_down_mask &= ~button; |
193 } | 198 } |
194 RunClosureAfterAllPendingUIEvents(closure); | 199 RunClosureAfterAllPendingUIEvents(closure); |
195 return true; | 200 return true; |
196 } | 201 } |
197 virtual bool SendMouseClick(MouseButton type) OVERRIDE { | 202 virtual bool SendMouseClick(MouseButton type) OVERRIDE { |
198 return SendMouseEvents(type, UP | DOWN); | 203 return SendMouseEvents(type, UP | DOWN); |
199 } | 204 } |
200 virtual void RunClosureAfterAllPendingUIEvents( | 205 virtual void RunClosureAfterAllPendingUIEvents( |
201 const base::Closure& closure) OVERRIDE { | 206 const base::Closure& closure) OVERRIDE { |
202 if (closure.is_null()) | 207 if (closure.is_null()) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); | 244 DISALLOW_COPY_AND_ASSIGN(UIControlsX11); |
240 }; | 245 }; |
241 | 246 |
242 } // namespace | 247 } // namespace |
243 | 248 |
244 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { | 249 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { |
245 return new UIControlsX11(root_window); | 250 return new UIControlsX11(root_window); |
246 } | 251 } |
247 | 252 |
248 } // namespace ui_controls | 253 } // namespace ui_controls |
OLD | NEW |