OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_MESSAGE_PUMP_GLIB_X_H | |
6 #define BASE_MESSAGE_PUMP_GLIB_X_H | |
7 | |
8 #include "base/message_pump.h" | |
9 #include "base/message_pump_glib.h" | |
10 | |
11 #include <bitset> | |
12 | |
13 #include <glib.h> | |
14 #include <gtk/gtk.h> | |
15 #include <X11/X.h> | |
16 | |
17 namespace base { | |
18 | |
19 class MessagePumpGlibX : public MessagePumpForUI { | |
20 public: | |
21 MessagePumpGlibX(); | |
22 virtual ~MessagePumpGlibX(); | |
23 | |
24 // MessagePumpForUI implementation. | |
25 virtual bool RunOnce(GMainContext* context, bool block); | |
26 | |
27 // Indicates whether a GDK event was injected by chrome (when |true|) or if it | |
28 // was captured and being processed by GDK (when |false|). | |
29 bool IsDispatchingEvent(void) { return dispatching_event_; } | |
30 | |
31 private: | |
32 static void EventDispatcherX(GdkEvent* event, gpointer data); | |
33 | |
34 // Update the lookup table and flag the events that should be captured and | |
35 // processed so that GDK doesn't get to them. | |
36 void InitializeEventsToCapture(void); | |
37 | |
38 // The event source for GDK events. | |
39 GSource* gdksource_; | |
40 | |
41 // Indicates whether a GDK event was injected by chrome (when |true|) or if it | |
42 // was captured and being processed by GDK (when |false|). | |
43 bool dispatching_event_; | |
44 | |
45 #if ! GTK_CHECK_VERSION(2,18,0) | |
46 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a | |
47 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works | |
48 // for all versions. | |
49 #define GDK_EVENT_LAST 37 | |
50 #endif | |
51 | |
52 // We do not want to process all the events ourselves. So we use a lookup | |
53 // table to quickly check if a particular event should be handled by us or if | |
54 // it should be passed on to the default GDK handler. | |
55 std::bitset<LASTEvent> capture_x_events_; | |
56 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX); | |
59 }; | |
60 | |
61 } // namespace base | |
62 | |
63 #endif // BASE_MESSAGE_PUMP_GLIB_X_H | |
OLD | NEW |