| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_MESSAGE_PUMP_X_H | |
| 6 #define BASE_MESSAGE_PUMP_X_H | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/message_pump.h" | |
| 10 #include "base/message_pump_glib.h" | |
| 11 #include "base/message_pump_dispatcher.h" | |
| 12 #include "base/message_pump_observer.h" | |
| 13 | |
| 14 #include <bitset> | |
| 15 | |
| 16 #include <glib.h> | |
| 17 | |
| 18 typedef struct _XDisplay Display; | |
| 19 | |
| 20 namespace base { | |
| 21 | |
| 22 // This class implements a message-pump for dispatching X events. | |
| 23 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { | |
| 24 public: | |
| 25 MessagePumpX(); | |
| 26 | |
| 27 // Returns default X Display. | |
| 28 static Display* GetDefaultXDisplay(); | |
| 29 | |
| 30 // Returns true if the system supports XINPUT2. | |
| 31 static bool HasXInput2(); | |
| 32 | |
| 33 // Sets the default dispatcher to process native events. | |
| 34 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); | |
| 35 | |
| 36 // Internal function. Called by the glib source dispatch function. Processes | |
| 37 // all available X events. | |
| 38 gboolean DispatchXEvents(); | |
| 39 | |
| 40 protected: | |
| 41 virtual ~MessagePumpX(); | |
| 42 | |
| 43 private: | |
| 44 // Initializes the glib event source for X. | |
| 45 void InitXSource(); | |
| 46 | |
| 47 // Dispatches the XEvent and returns true if we should exit the current loop | |
| 48 // of message processing. | |
| 49 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); | |
| 50 | |
| 51 // 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 | |
| 53 // if no observer returns true. | |
| 54 bool WillProcessXEvent(XEvent* xevent); | |
| 55 void DidProcessXEvent(XEvent* xevent); | |
| 56 | |
| 57 // The event source for X events. | |
| 58 GSource* x_source_; | |
| 59 | |
| 60 // The poll attached to |x_source_|. | |
| 61 scoped_ptr<GPollFD> x_poll_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); | |
| 64 }; | |
| 65 | |
| 66 typedef MessagePumpX MessagePumpForUI; | |
| 67 | |
| 68 } // namespace base | |
| 69 | |
| 70 #endif // BASE_MESSAGE_PUMP_X_H | |
| OLD | NEW |