OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(yusukes): Remove the #if once the ARM bot (crbug.com/84694) is fixed. | 5 // TODO(yusukes): Remove the #if once the ARM bot (crbug.com/84694) is fixed. |
6 #if defined(HAVE_XINPUT2) | 6 #if defined(HAVE_XINPUT2) |
7 | 7 |
8 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" | 8 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" |
9 | 9 |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 #if defined(TOUCH_UI) | 90 #if defined(TOUCH_UI) |
91 MessageLoopForUI::current()->RemoveObserver(this); | 91 MessageLoopForUI::current()->RemoveObserver(this); |
92 #else | 92 #else |
93 gdk_window_remove_filter(NULL, GdkEventFilter, this); | 93 gdk_window_remove_filter(NULL, GdkEventFilter, this); |
94 #endif | 94 #endif |
95 stopped_ = true; | 95 stopped_ = true; |
96 xiopcode_ = -1; | 96 xiopcode_ = -1; |
97 } | 97 } |
98 | 98 |
| 99 #if defined(TOUCH_UI) |
| 100 base::MessagePumpObserver::EventStatus |
| 101 XInputHierarchyChangedEventListener::WillProcessXEvent(XEvent* xevent) { |
| 102 return ProcessedXEvent(xevent) ? EVENT_HANDLED : EVENT_CONTINUE; |
| 103 } |
| 104 #else // defined(TOUCH_UI) |
99 // static | 105 // static |
100 GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter( | 106 GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter( |
101 GdkXEvent* gxevent, GdkEvent* gevent, gpointer data) { | 107 GdkXEvent* gxevent, GdkEvent* gevent, gpointer data) { |
102 XInputHierarchyChangedEventListener* listener = | 108 XInputHierarchyChangedEventListener* listener = |
103 static_cast<XInputHierarchyChangedEventListener*>(data); | 109 static_cast<XInputHierarchyChangedEventListener*>(data); |
104 XEvent* xevent = static_cast<XEvent*>(gxevent); | 110 XEvent* xevent = static_cast<XEvent*>(gxevent); |
105 | 111 |
106 return listener->WillProcessXEvent(xevent) ? GDK_FILTER_REMOVE | 112 return listener->ProcessedXEvent(xevent) ? GDK_FILTER_REMOVE |
107 : GDK_FILTER_CONTINUE; | 113 : GDK_FILTER_CONTINUE; |
108 } | 114 } |
| 115 #endif // defined(TOUCH_UI) |
109 | 116 |
110 bool XInputHierarchyChangedEventListener::WillProcessXEvent(XEvent* xevent) { | 117 bool XInputHierarchyChangedEventListener::ProcessedXEvent(XEvent* xevent) { |
111 if ((xevent->xcookie.type != GenericEvent) || | 118 if ((xevent->xcookie.type != GenericEvent) || |
112 (xevent->xcookie.extension != xiopcode_)) { | 119 (xevent->xcookie.extension != xiopcode_)) { |
113 return false; | 120 return false; |
114 } | 121 } |
115 if (!XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { | 122 if (!XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { |
116 VLOG(1) << "XGetEventData failed"; | 123 VLOG(1) << "XGetEventData failed"; |
117 return false; | 124 return false; |
118 } | 125 } |
119 | 126 |
120 XGenericEventCookie* cookie = &(xevent->xcookie); | 127 XGenericEventCookie* cookie = &(xevent->xcookie); |
121 const bool should_consume = (cookie->evtype == XI_HierarchyChanged); | 128 const bool should_consume = (cookie->evtype == XI_HierarchyChanged); |
122 if (should_consume) { | 129 if (should_consume) { |
123 HandleHierarchyChangedEvent(static_cast<XIHierarchyEvent*>(cookie->data)); | 130 HandleHierarchyChangedEvent(static_cast<XIHierarchyEvent*>(cookie->data)); |
124 } | 131 } |
125 XFreeEventData(xevent->xgeneric.display, cookie); | 132 XFreeEventData(xevent->xgeneric.display, cookie); |
126 | 133 |
127 return should_consume; | 134 return should_consume; |
128 } | 135 } |
129 | 136 |
130 } // namespace chromeos | 137 } // namespace chromeos |
131 | 138 |
132 #endif | 139 #endif |
133 | 140 |
134 // TODO(yusukes): Remove this check when crbug.com/84694 is resolved. | 141 // TODO(yusukes): Remove this check when crbug.com/84694 is resolved. |
135 #if defined(ARCH_CPU_X86_FAMILY) && !defined(HAVE_XINPUT2) | 142 #if defined(ARCH_CPU_X86_FAMILY) && !defined(HAVE_XINPUT2) |
136 #error XINPUT2 should always be enabled on Chrome OS x86! | 143 #error XINPUT2 should always be enabled on Chrome OS x86! |
137 #endif | 144 #endif |
OLD | NEW |