| 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_LOOP_MESSAGE_PUMP_AURAX11_H | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H |
| 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H | 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H |
| 7 | 7 |
| 8 #include <bitset> | 8 #include <bitset> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_pump.h" | 12 #include "base/message_loop/message_pump.h" |
| 13 #include "base/message_loop/message_pump_dispatcher.h" | 13 #include "base/message_loop/message_pump_dispatcher.h" |
| 14 #include "base/message_loop/message_pump_glib.h" | 14 #include "base/message_loop/message_pump_glib.h" |
| 15 #include "base/message_loop/message_pump_observer.h" | 15 #include "base/message_loop/message_pump_observer.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 | 17 |
| 18 // It would be nice to include the X11 headers here so that we use Window | 18 // It would be nice to include the X11 headers here so that we use Window |
| 19 // instead of its typedef of unsigned long, but we can't because everything in | 19 // instead of its typedef of unsigned long, but we can't because everything in |
| 20 // chrome includes us through base/message_loop/message_loop.h, and X11's crappy | 20 // chrome includes us through base/message_loop/message_loop.h, and X11's crappy |
| 21 // #define heavy headers muck up half of chrome. | 21 // #define heavy headers muck up half of chrome. |
| 22 | 22 |
| 23 typedef struct _GPollFD GPollFD; | 23 typedef struct _GPollFD GPollFD; |
| 24 typedef struct _GSource GSource; | 24 typedef struct _GSource GSource; |
| 25 typedef struct _XDisplay Display; | 25 typedef struct _XDisplay Display; |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 | 28 |
| 29 // This class implements a message-pump for dispatching X events. | 29 // This class implements a message-pump for dispatching X events. |
| 30 // | 30 // |
| 31 // If there's a current dispatcher given through RunWithDispatcher(), that | 31 // If there's a current dispatcher given through RunWithDispatcher(), that |
| 32 // dispatcher receives events. Otherwise, we route to messages to dispatchers | 32 // dispatcher receives events. Otherwise, we route to messages to dispatchers |
| 33 // who have subscribed to messages from a specific X11 window. | 33 // who have subscribed to messages from a specific X11 window. |
| 34 class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib, | 34 class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib, |
| 35 public MessagePumpDispatcher { | 35 public MessagePumpDispatcher { |
| 36 public: | 36 public: |
| 37 MessagePumpAuraX11(); | 37 MessagePumpX11(); |
| 38 virtual ~MessagePumpAuraX11(); | 38 virtual ~MessagePumpX11(); |
| 39 | 39 |
| 40 // Returns default X Display. | 40 // Returns default X Display. |
| 41 static Display* GetDefaultXDisplay(); | 41 static Display* GetDefaultXDisplay(); |
| 42 | 42 |
| 43 // Returns true if the system supports XINPUT2. | 43 // Returns true if the system supports XINPUT2. |
| 44 static bool HasXInput2(); | 44 static bool HasXInput2(); |
| 45 | 45 |
| 46 #if !defined(TOOLKIT_GTK) |
| 46 // Returns the UI message pump. | 47 // Returns the UI message pump. |
| 47 static MessagePumpAuraX11* Current(); | 48 static MessagePumpX11* Current(); |
| 49 #endif |
| 48 | 50 |
| 49 // Adds/Removes |dispatcher| for the |xid|. This will route all messages from | 51 // Adds/Removes |dispatcher| for the |xid|. This will route all messages from |
| 50 // the window |xid| to |dispatcher. | 52 // the window |xid| to |dispatcher. |
| 51 void AddDispatcherForWindow(MessagePumpDispatcher* dispatcher, | 53 void AddDispatcherForWindow(MessagePumpDispatcher* dispatcher, |
| 52 unsigned long xid); | 54 unsigned long xid); |
| 53 void RemoveDispatcherForWindow(unsigned long xid); | 55 void RemoveDispatcherForWindow(unsigned long xid); |
| 54 | 56 |
| 55 // Adds/Removes |dispatcher| to receive all events sent to the X root | 57 // Adds/Removes |dispatcher| to receive all events sent to the X root |
| 56 // window. A root window can have multiple dispatchers, and events on root | 58 // window. A root window can have multiple dispatchers, and events on root |
| 57 // windows will be dispatched to all. | 59 // windows will be dispatched to all. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Dispatch calls can cause addition of new dispatchers as we iterate | 117 // Dispatch calls can cause addition of new dispatchers as we iterate |
| 116 // through them. Use ObserverList to ensure the iterator remains valid across | 118 // through them. Use ObserverList to ensure the iterator remains valid across |
| 117 // additions. | 119 // additions. |
| 118 ObserverList<MessagePumpDispatcher> root_window_dispatchers_; | 120 ObserverList<MessagePumpDispatcher> root_window_dispatchers_; |
| 119 | 121 |
| 120 // List of observers. | 122 // List of observers. |
| 121 ObserverList<MessagePumpObserver> observers_; | 123 ObserverList<MessagePumpObserver> observers_; |
| 122 | 124 |
| 123 unsigned long x_root_window_; | 125 unsigned long x_root_window_; |
| 124 | 126 |
| 125 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); | 127 DISALLOW_COPY_AND_ASSIGN(MessagePumpX11); |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 typedef MessagePumpAuraX11 MessagePumpForUI; | 130 #if !defined(TOOLKIT_GTK) |
| 131 typedef MessagePumpX11 MessagePumpForUI; |
| 132 #endif |
| 129 | 133 |
| 130 } // namespace base | 134 } // namespace base |
| 131 | 135 |
| 132 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H | 136 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H |
| OLD | NEW |