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
3 // found in the LICENSE file.
5 #ifndef BASE_MESSAGE_PUMP_GLIB_X_H
6 #define BASE_MESSAGE_PUMP_GLIB_X_H
8 #include "base/message_pump.h"
9 #include "base/message_pump_glib.h"
20 class MessagePumpGlibX
: public MessagePumpForUI
{
23 virtual ~MessagePumpGlibX();
25 // Indicates whether a GDK event was injected by chrome (when |true|) or if it
26 // was captured and being processed by GDK (when |false|).
27 bool IsDispatchingEvent(void) { return dispatching_event_
; }
29 #if defined(HAVE_XINPUT2)
30 // Setup an X Window for XInput2 events.
31 void SetupXInput2ForXWindow(Window xid
);
34 // Overridden from MessagePumpForUI:
35 virtual bool RunOnce(GMainContext
* context
, bool block
);
38 static void EventDispatcherX(GdkEvent
* event
, gpointer data
);
40 // Update the lookup table and flag the events that should be captured and
41 // processed so that GDK doesn't get to them.
42 void InitializeEventsToCapture(void);
44 #if defined(HAVE_XINPUT2)
45 // Initialize X2 input.
46 void InitializeXInput2(void);
48 // The opcode used for checking events.
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_
;
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_
;
60 // The event source for GDK events.
63 // The default GDK event dispatcher. This is stored so that it can be restored
64 // when necessary during nested event dispatching.
65 gboolean (*gdkdispatcher_
)(GSource
*, GSourceFunc
, void*);
67 // Indicates whether a GDK event was injected by chrome (when |true|) or if it
68 // was captured and being processed by GDK (when |false|).
69 bool dispatching_event_
;
71 #if ! GTK_CHECK_VERSION(2,18,0)
72 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a
73 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works
75 #define GDK_EVENT_LAST 37
78 // We do not want to process all the events ourselves. So we use a lookup
79 // table to quickly check if a particular event should be handled by us or if
80 // it should be passed on to the default GDK handler.
81 std::bitset
<LASTEvent
> capture_x_events_
;
82 std::bitset
<GDK_EVENT_LAST
> capture_gdk_events_
;
84 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX
);
89 #endif // BASE_MESSAGE_PUMP_GLIB_X_H