| 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 #ifndef BASE_MESSAGE_PUMP_GLIB_X_H | 5 #ifndef BASE_MESSAGE_PUMP_GLIB_X_H |
| 6 #define BASE_MESSAGE_PUMP_GLIB_X_H | 6 #define BASE_MESSAGE_PUMP_GLIB_X_H |
| 7 | 7 |
| 8 #include "base/message_pump.h" | 8 #include "base/message_pump.h" |
| 9 #include "base/message_pump_glib.h" | 9 #include "base/message_pump_glib.h" |
| 10 | 10 |
| 11 #include <bitset> | 11 #include <bitset> |
| 12 #include <set> | |
| 13 | 12 |
| 14 #include <glib.h> | 13 #include <glib.h> |
| 15 #include <gtk/gtk.h> | 14 #include <gtk/gtk.h> |
| 16 #include <X11/X.h> | 15 #include <X11/X.h> |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 | 18 |
| 20 class MessagePumpGlibX : public MessagePumpForUI { | 19 class MessagePumpGlibX : public MessagePumpForUI { |
| 21 public: | 20 public: |
| 22 MessagePumpGlibX(); | 21 MessagePumpGlibX(); |
| 23 virtual ~MessagePumpGlibX(); | 22 virtual ~MessagePumpGlibX(); |
| 24 | 23 |
| 25 // MessagePumpForUI implementation. | 24 // MessagePumpForUI implementation. |
| 26 virtual bool RunOnce(GMainContext* context, bool block); | 25 virtual bool RunOnce(GMainContext* context, bool block); |
| 27 | 26 |
| 28 // Indicates whether a GDK event was injected by chrome (when |true|) or if it | 27 // Indicates whether a GDK event was injected by chrome (when |true|) or if it |
| 29 // was captured and being processed by GDK (when |false|). | 28 // was captured and being processed by GDK (when |false|). |
| 30 bool IsDispatchingEvent(void) { return dispatching_event_; } | 29 bool IsDispatchingEvent(void) { return dispatching_event_; } |
| 31 | 30 |
| 32 #if defined(HAVE_XINPUT2) | |
| 33 // Setup an X Window for XInput2 events. | |
| 34 void SetupXInput2ForXWindow(Window xid); | |
| 35 #endif | |
| 36 | |
| 37 private: | 31 private: |
| 38 static void EventDispatcherX(GdkEvent* event, gpointer data); | 32 static void EventDispatcherX(GdkEvent* event, gpointer data); |
| 39 | 33 |
| 40 // Update the lookup table and flag the events that should be captured and | 34 // Update the lookup table and flag the events that should be captured and |
| 41 // processed so that GDK doesn't get to them. | 35 // processed so that GDK doesn't get to them. |
| 42 void InitializeEventsToCapture(void); | 36 void InitializeEventsToCapture(void); |
| 43 | 37 |
| 44 #if defined(HAVE_XINPUT2) | |
| 45 // Initialize X2 input. | |
| 46 void InitializeXInput2(void); | |
| 47 | |
| 48 // The opcode used for checking events. | |
| 49 int xiopcode_; | |
| 50 | |
| 51 // The list of master pointer devices. We maintain this list so that it is not | |
| 52 // necessary to query X for the list of devices for each GdkWindow created. | |
| 53 std::set<int> masters_; | |
| 54 | |
| 55 // The list of slave (physical) pointer devices. | |
| 56 // TODO(sad): This is currently unused, and may be removed eventually. | |
| 57 std::set<int> slaves_; | |
| 58 #endif | |
| 59 | |
| 60 // The event source for GDK events. | 38 // The event source for GDK events. |
| 61 GSource* gdksource_; | 39 GSource* gdksource_; |
| 62 | 40 |
| 63 // Indicates whether a GDK event was injected by chrome (when |true|) or if it | 41 // Indicates whether a GDK event was injected by chrome (when |true|) or if it |
| 64 // was captured and being processed by GDK (when |false|). | 42 // was captured and being processed by GDK (when |false|). |
| 65 bool dispatching_event_; | 43 bool dispatching_event_; |
| 66 | 44 |
| 67 #if ! GTK_CHECK_VERSION(2,18,0) | 45 #if ! GTK_CHECK_VERSION(2,18,0) |
| 68 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a | 46 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a |
| 69 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works | 47 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works |
| 70 // for all versions. | 48 // for all versions. |
| 71 #define GDK_EVENT_LAST 37 | 49 #define GDK_EVENT_LAST 37 |
| 72 #endif | 50 #endif |
| 73 | 51 |
| 74 // We do not want to process all the events ourselves. So we use a lookup | 52 // We do not want to process all the events ourselves. So we use a lookup |
| 75 // table to quickly check if a particular event should be handled by us or if | 53 // table to quickly check if a particular event should be handled by us or if |
| 76 // it should be passed on to the default GDK handler. | 54 // it should be passed on to the default GDK handler. |
| 77 std::bitset<LASTEvent> capture_x_events_; | 55 std::bitset<LASTEvent> capture_x_events_; |
| 78 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; | 56 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; |
| 79 | 57 |
| 80 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX); | 58 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX); |
| 81 }; | 59 }; |
| 82 | 60 |
| 83 } // namespace base | 61 } // namespace base |
| 84 | 62 |
| 85 #endif // BASE_MESSAGE_PUMP_GLIB_X_H | 63 #endif // BASE_MESSAGE_PUMP_GLIB_X_H |
| OLD | NEW |