| 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_X11_H | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H |
| 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_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" | |
| 14 #include "base/message_loop/message_pump_glib.h" | 13 #include "base/message_loop/message_pump_glib.h" |
| 15 #include "base/message_loop/message_pump_observer.h" | |
| 16 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 17 | 15 |
| 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 | |
| 20 // chrome includes us through base/message_loop/message_loop.h, and X11's crappy | |
| 21 // #define heavy headers muck up half of chrome. | |
| 22 | |
| 23 typedef struct _GPollFD GPollFD; | |
| 24 typedef struct _GSource GSource; | |
| 25 typedef struct _XDisplay Display; | 16 typedef struct _XDisplay Display; |
| 26 | 17 |
| 27 namespace base { | 18 namespace base { |
| 28 | 19 |
| 29 // This class implements a message-pump for dispatching X events. | 20 // This class implements a message-pump for dispatching X events. |
| 30 // | |
| 31 // If there's a current dispatcher given through RunWithDispatcher(), that | |
| 32 // dispatcher receives events. Otherwise, we route to messages to dispatchers | |
| 33 // who have subscribed to messages from a specific X11 window. | |
| 34 class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib { | 21 class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib { |
| 35 public: | 22 public: |
| 36 MessagePumpX11(); | 23 MessagePumpX11(); |
| 37 virtual ~MessagePumpX11(); | 24 virtual ~MessagePumpX11(); |
| 38 | 25 |
| 39 // Returns default X Display. | 26 // Returns default X Display. |
| 40 static Display* GetDefaultXDisplay(); | 27 static Display* GetDefaultXDisplay(); |
| 41 | 28 |
| 42 // Returns the UI or GPU message pump. | 29 // Returns the UI or GPU message pump. |
| 43 static MessagePumpX11* Current(); | 30 static MessagePumpX11* Current(); |
| 44 | 31 |
| 45 // Adds an Observer, which will start receiving notifications immediately. | |
| 46 void AddObserver(MessagePumpObserver* observer); | |
| 47 | |
| 48 // Removes an Observer. It is safe to call this method while an Observer is | |
| 49 // receiving a notification callback. | |
| 50 void RemoveObserver(MessagePumpObserver* observer); | |
| 51 | |
| 52 // Sends the event to the observers. | |
| 53 void WillProcessXEvent(XEvent* xevent); | |
| 54 void DidProcessXEvent(XEvent* xevent); | |
| 55 | |
| 56 private: | 32 private: |
| 57 // List of observers. | |
| 58 ObserverList<MessagePumpObserver> observers_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(MessagePumpX11); | 33 DISALLOW_COPY_AND_ASSIGN(MessagePumpX11); |
| 61 }; | 34 }; |
| 62 | 35 |
| 63 #if !defined(TOOLKIT_GTK) | 36 #if !defined(TOOLKIT_GTK) |
| 64 typedef MessagePumpX11 MessagePumpForUI; | 37 typedef MessagePumpX11 MessagePumpForUI; |
| 65 #endif | 38 #endif |
| 66 | 39 |
| 67 } // namespace base | 40 } // namespace base |
| 68 | 41 |
| 69 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H | 42 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H |
| OLD | NEW |