OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_AURAX11_H | 5 #ifndef BASE_MESSAGE_PUMP_AURAX11_H |
6 #define BASE_MESSAGE_PUMP_AURAX11_H | 6 #define BASE_MESSAGE_PUMP_AURAX11_H |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
10 #include "base/message_pump_glib.h" | 10 #include "base/message_pump_glib.h" |
11 #include "base/message_pump_dispatcher.h" | 11 #include "base/message_pump_dispatcher.h" |
12 #include "base/message_pump_observer.h" | 12 #include "base/message_pump_observer.h" |
13 | 13 |
14 #include <bitset> | 14 #include <bitset> |
15 | 15 |
| 16 // It would be nice to include the X11 headers here so that we use Window |
| 17 // instead of its typedef of unsigned long, but we can't because everything in |
| 18 // chrome includes us through base/message_loop.h, and X11's crappy #define |
| 19 // heavy headers muck up half of chrome. |
| 20 |
16 typedef struct _GPollFD GPollFD; | 21 typedef struct _GPollFD GPollFD; |
17 typedef struct _GSource GSource; | 22 typedef struct _GSource GSource; |
18 typedef struct _XDisplay Display; | 23 typedef struct _XDisplay Display; |
19 | 24 |
20 namespace base { | 25 namespace base { |
21 | 26 |
22 // This class implements a message-pump for dispatching X events. | 27 // This class implements a message-pump for dispatching X events. |
23 class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib { | 28 class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib { |
24 public: | 29 public: |
25 MessagePumpAuraX11(); | 30 MessagePumpAuraX11(); |
26 | 31 |
27 // Returns default X Display. | 32 // Returns default X Display. |
28 static Display* GetDefaultXDisplay(); | 33 static Display* GetDefaultXDisplay(); |
29 | 34 |
30 // Returns true if the system supports XINPUT2. | 35 // Returns true if the system supports XINPUT2. |
31 static bool HasXInput2(); | 36 static bool HasXInput2(); |
32 | 37 |
33 // Sets the default dispatcher to process native events. | 38 // Sets the default dispatcher to process native events. |
34 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); | 39 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); |
35 | 40 |
| 41 // Returns the UI message pump. |
| 42 static MessagePumpAuraX11* Current(); |
| 43 |
36 // Internal function. Called by the glib source dispatch function. Processes | 44 // Internal function. Called by the glib source dispatch function. Processes |
37 // all available X events. | 45 // all available X events. |
38 bool DispatchXEvents(); | 46 bool DispatchXEvents(); |
39 | 47 |
| 48 // Blocks on the X11 event queue until we receive notification from the |
| 49 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are |
| 50 // pulled out from the queue and dispatched out of order. |
| 51 // |
| 52 // For those that know X11, this is really a wrapper around XWindowEvent |
| 53 // which still makes sure the preempted event is dispatched instead of |
| 54 // dropped on the floor. This method exists because mapping a window is |
| 55 // asynchronous (and we receive an XEvent when mapped), while there are also |
| 56 // functions which require a mapped window. |
| 57 void BlockUntilWindowMapped(unsigned long window); |
| 58 |
40 protected: | 59 protected: |
41 virtual ~MessagePumpAuraX11(); | 60 virtual ~MessagePumpAuraX11(); |
42 | 61 |
43 private: | 62 private: |
44 // Initializes the glib event source for X. | 63 // Initializes the glib event source for X. |
45 void InitXSource(); | 64 void InitXSource(); |
46 | 65 |
47 // Dispatches the XEvent and returns true if we should exit the current loop | 66 // Dispatches the XEvent and returns true if we should exit the current loop |
48 // of message processing. | 67 // of message processing. |
49 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); | 68 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); |
(...skipping 11 matching lines...) Expand all Loading... |
61 scoped_ptr<GPollFD> x_poll_; | 80 scoped_ptr<GPollFD> x_poll_; |
62 | 81 |
63 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); | 82 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); |
64 }; | 83 }; |
65 | 84 |
66 typedef MessagePumpAuraX11 MessagePumpForUI; | 85 typedef MessagePumpAuraX11 MessagePumpForUI; |
67 | 86 |
68 } // namespace base | 87 } // namespace base |
69 | 88 |
70 #endif // BASE_MESSAGE_PUMP_AURAX11_H | 89 #endif // BASE_MESSAGE_PUMP_AURAX11_H |
OLD | NEW |