| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/platform/x11/x11_event_source.h" | 5 #include "ui/events/platform/x11/x11_event_source.h" |
| 6 | 6 |
| 7 #include <glib.h> | 7 #include <glib.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/X.h> | 9 #include <X11/X.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| 11 #include <X11/XKBlib.h> | 11 #include <X11/XKBlib.h> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | |
| 15 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/platform/platform_event_dispatcher.h" | 15 #include "ui/events/platform/platform_event_dispatcher.h" |
| 17 #include "ui/gfx/x/x11_types.h" | 16 #include "ui/gfx/x/x11_types.h" |
| 18 | 17 |
| 19 namespace ui { | 18 namespace ui { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 struct GLibX11Source : public GSource { | 22 struct GLibX11Source : public GSource { |
| 24 // Note: The GLibX11Source is created and destroyed by GLib. So its | 23 // Note: The GLibX11Source is created and destroyed by GLib. So its |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 g_source_attach(x_source_, g_main_context_default()); | 187 g_source_attach(x_source_, g_main_context_default()); |
| 189 } | 188 } |
| 190 | 189 |
| 191 uint32_t X11EventSource::DispatchEvent(XEvent* xevent) { | 190 uint32_t X11EventSource::DispatchEvent(XEvent* xevent) { |
| 192 bool have_cookie = false; | 191 bool have_cookie = false; |
| 193 if (xevent->type == GenericEvent && | 192 if (xevent->type == GenericEvent && |
| 194 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { | 193 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { |
| 195 have_cookie = true; | 194 have_cookie = true; |
| 196 } | 195 } |
| 197 | 196 |
| 198 // TODO(sad): Remove this once all MessagePumpObservers are turned into | |
| 199 // PlatformEventObservers. | |
| 200 base::MessagePumpX11::Current()->WillProcessXEvent(xevent); | |
| 201 uint32_t action = PlatformEventSource::DispatchEvent(xevent); | 197 uint32_t action = PlatformEventSource::DispatchEvent(xevent); |
| 202 base::MessagePumpX11::Current()->DidProcessXEvent(xevent); | |
| 203 | |
| 204 if (xevent->type == GenericEvent && | 198 if (xevent->type == GenericEvent && |
| 205 xevent->xgeneric.evtype == XI_HierarchyChanged) { | 199 xevent->xgeneric.evtype == XI_HierarchyChanged) { |
| 206 ui::UpdateDeviceList(); | 200 ui::UpdateDeviceList(); |
| 207 } | 201 } |
| 208 | 202 |
| 209 if (have_cookie) | 203 if (have_cookie) |
| 210 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); | 204 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); |
| 211 return action; | 205 return action; |
| 212 } | 206 } |
| 213 | 207 |
| 214 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { | 208 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { |
| 215 return scoped_ptr<PlatformEventSource>( | 209 return scoped_ptr<PlatformEventSource>( |
| 216 new X11EventSource(gfx::GetXDisplay())); | 210 new X11EventSource(gfx::GetXDisplay())); |
| 217 } | 211 } |
| 218 | 212 |
| 219 } // namespace ui | 213 } // namespace ui |
| OLD | NEW |