OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/focus/accelerator_handler.h" | 5 #include "views/focus/accelerator_handler.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #if defined(HAVE_XINPUT2) | 9 #if defined(HAVE_XINPUT2) |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 #endif // HAVE_XINPUT2 | 138 #endif // HAVE_XINPUT2 |
139 | 139 |
140 bool DispatchXEvent(XEvent* xev) { | 140 bool DispatchXEvent(XEvent* xev) { |
141 GdkDisplay* gdisp = gdk_display_get_default(); | 141 GdkDisplay* gdisp = gdk_display_get_default(); |
142 XID xwindow = xev->xany.window; | 142 XID xwindow = xev->xany.window; |
143 | 143 |
144 #if defined(HAVE_XINPUT2) | 144 #if defined(HAVE_XINPUT2) |
145 if (xev->type == GenericEvent) { | 145 if (xev->type == GenericEvent) { |
146 if (XGetEventData(xev->xgeneric.display, &xev->xcookie)) { | 146 XGenericEventCookie* cookie = &xev->xcookie; |
147 XGenericEventCookie* cookie = &xev->xcookie; | 147 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data); |
148 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data); | 148 xwindow = xiev->event; |
149 xwindow = xiev->event; | |
150 } else { | |
151 DLOG(WARNING) << "Error fetching XGenericEventCookie for event."; | |
152 return false; | |
153 } | |
154 } | 149 } |
155 #endif | 150 #endif |
156 | 151 |
157 GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); | 152 GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); |
158 | 153 |
159 if (RootView* root = FindRootViewForGdkWindow(gwind)) { | 154 if (RootView* root = FindRootViewForGdkWindow(gwind)) { |
160 switch (xev->type) { | 155 switch (xev->type) { |
161 case KeyPress: | 156 case KeyPress: |
162 case KeyRelease: { | 157 case KeyRelease: { |
163 KeyEvent keyev(xev); | 158 KeyEvent keyev(xev); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) { | 190 if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) { |
196 return root->OnMouseDragged(mouseev); | 191 return root->OnMouseDragged(mouseev); |
197 } else { | 192 } else { |
198 root->OnMouseMoved(mouseev); | 193 root->OnMouseMoved(mouseev); |
199 return true; | 194 return true; |
200 } | 195 } |
201 } | 196 } |
202 | 197 |
203 #if defined(HAVE_XINPUT2) | 198 #if defined(HAVE_XINPUT2) |
204 case GenericEvent: { | 199 case GenericEvent: { |
205 bool ret = DispatchX2Event(root, xev); | 200 return DispatchX2Event(root, xev); |
206 XFreeEventData(xev->xgeneric.display, &xev->xcookie); | |
207 return ret; | |
208 } | 201 } |
209 #endif | 202 #endif |
210 } | 203 } |
211 } | 204 } |
212 | 205 |
213 return false; | 206 return false; |
214 } | 207 } |
215 | 208 |
216 #if defined(HAVE_XINPUT2) | 209 #if defined(HAVE_XINPUT2) |
217 void SetTouchDeviceList(std::vector<unsigned int>& devices) { | 210 void SetTouchDeviceList(std::vector<unsigned int>& devices) { |
218 TouchFactory::SetTouchDeviceListInternal(devices); | 211 TouchFactory::SetTouchDeviceListInternal(devices); |
219 } | 212 } |
220 #endif | 213 #endif |
221 | 214 |
222 AcceleratorHandler::AcceleratorHandler() {} | 215 AcceleratorHandler::AcceleratorHandler() {} |
223 | 216 |
224 bool AcceleratorHandler::Dispatch(GdkEvent* event) { | 217 bool AcceleratorHandler::Dispatch(GdkEvent* event) { |
225 gtk_main_do_event(event); | 218 gtk_main_do_event(event); |
226 return true; | 219 return true; |
227 } | 220 } |
228 | 221 |
229 bool AcceleratorHandler::Dispatch(XEvent* xev) { | 222 base::MessagePumpGlibXDispatcher::DispatchStatus AcceleratorHandler::Dispatch( |
230 return DispatchXEvent(xev); | 223 XEvent* xev) { |
| 224 return DispatchXEvent(xev) ? |
| 225 base::MessagePumpGlibXDispatcher::EVENT_PROCESSED : |
| 226 base::MessagePumpGlibXDispatcher::EVENT_IGNORED; |
231 } | 227 } |
232 | 228 |
233 } // namespace views | 229 } // namespace views |
OLD | NEW |