| 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_X_H | 5 #ifndef BASE_MESSAGE_PUMP_AURAX11_H |
| 6 #define BASE_MESSAGE_PUMP_X_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 #include <glib.h> | 16 #include <glib.h> |
| 17 | 17 |
| 18 typedef unsigned long Atom; |
| 18 typedef struct _XDisplay Display; | 19 typedef struct _XDisplay Display; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 | 22 |
| 23 namespace atom { |
| 24 |
| 25 // Names of cached atoms that we fetch from X11AtomCache. Adding an entry here |
| 26 // also requires adding an entry in the cc file. |
| 27 enum Name { |
| 28 WM_DELETE_WINDOW = 0, |
| 29 _NET_WM_MOVERESIZE, |
| 30 _NET_WM_PING, |
| 31 _NET_WM_PID, |
| 32 WM_S0, |
| 33 _MOTIF_WM_HINTS, |
| 34 |
| 35 ATOM_COUNT |
| 36 }; |
| 37 |
| 38 } // namespace atom |
| 39 |
| 22 // This class implements a message-pump for dispatching X events. | 40 // This class implements a message-pump for dispatching X events. |
| 23 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { | 41 class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib { |
| 24 public: | 42 public: |
| 25 MessagePumpX(); | 43 MessagePumpAuraX11(); |
| 26 | 44 |
| 27 // Returns default X Display. | 45 // Returns default X Display. |
| 28 static Display* GetDefaultXDisplay(); | 46 static Display* GetDefaultXDisplay(); |
| 29 | 47 |
| 48 // Returns an atom on the default X Display. |
| 49 static ::Atom GetAtom(atom::Name name); |
| 50 |
| 30 // Returns true if the system supports XINPUT2. | 51 // Returns true if the system supports XINPUT2. |
| 31 static bool HasXInput2(); | 52 static bool HasXInput2(); |
| 32 | 53 |
| 33 // Sets the default dispatcher to process native events. | 54 // Sets the default dispatcher to process native events. |
| 34 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); | 55 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); |
| 35 | 56 |
| 36 // Internal function. Called by the glib source dispatch function. Processes | 57 // Internal function. Called by the glib source dispatch function. Processes |
| 37 // all available X events. | 58 // all available X events. |
| 38 gboolean DispatchXEvents(); | 59 gboolean DispatchXEvents(); |
| 39 | 60 |
| 40 protected: | 61 protected: |
| 41 virtual ~MessagePumpX(); | 62 virtual ~MessagePumpAuraX11(); |
| 42 | 63 |
| 43 private: | 64 private: |
| 44 // Initializes the glib event source for X. | 65 // Initializes the glib event source for X. |
| 45 void InitXSource(); | 66 void InitXSource(); |
| 46 | 67 |
| 47 // Dispatches the XEvent and returns true if we should exit the current loop | 68 // Dispatches the XEvent and returns true if we should exit the current loop |
| 48 // of message processing. | 69 // of message processing. |
| 49 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); | 70 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); |
| 50 | 71 |
| 51 // Sends the event to the observers. If an observer returns true, then it does | 72 // Sends the event to the observers. If an observer returns true, then it does |
| 52 // not send the event to any other observers and returns true. Returns false | 73 // not send the event to any other observers and returns true. Returns false |
| 53 // if no observer returns true. | 74 // if no observer returns true. |
| 54 bool WillProcessXEvent(XEvent* xevent); | 75 bool WillProcessXEvent(XEvent* xevent); |
| 55 void DidProcessXEvent(XEvent* xevent); | 76 void DidProcessXEvent(XEvent* xevent); |
| 56 | 77 |
| 57 // The event source for X events. | 78 // The event source for X events. |
| 58 GSource* x_source_; | 79 GSource* x_source_; |
| 59 | 80 |
| 60 // The poll attached to |x_source_|. | 81 // The poll attached to |x_source_|. |
| 61 scoped_ptr<GPollFD> x_poll_; | 82 scoped_ptr<GPollFD> x_poll_; |
| 62 | 83 |
| 63 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); | 84 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); |
| 64 }; | 85 }; |
| 65 | 86 |
| 66 typedef MessagePumpX MessagePumpForUI; | 87 typedef MessagePumpAuraX11 MessagePumpForUI; |
| 67 | 88 |
| 68 } // namespace base | 89 } // namespace base |
| 69 | 90 |
| 70 #endif // BASE_MESSAGE_PUMP_X_H | 91 #endif // BASE_MESSAGE_PUMP_AURAX11_H |
| OLD | NEW |