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 #include <map> | 15 #include <map> |
16 #include <vector> | 16 #include <vector> |
willchan no longer on Chromium
2012/12/19 17:25:42
Can you get rid of this now?
| |
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.h, and X11's crappy #define | 20 // chrome includes us through base/message_loop.h, and X11's crappy #define |
21 // heavy headers muck up half of chrome. | 21 // 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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 // dropped on the floor. This method exists because mapping a window is | 70 // dropped on the floor. This method exists because mapping a window is |
71 // asynchronous (and we receive an XEvent when mapped), while there are also | 71 // asynchronous (and we receive an XEvent when mapped), while there are also |
72 // functions which require a mapped window. | 72 // functions which require a mapped window. |
73 void BlockUntilWindowMapped(unsigned long xid); | 73 void BlockUntilWindowMapped(unsigned long xid); |
74 | 74 |
75 protected: | 75 protected: |
76 virtual ~MessagePumpAuraX11(); | 76 virtual ~MessagePumpAuraX11(); |
77 | 77 |
78 private: | 78 private: |
79 typedef std::map<unsigned long, MessagePumpDispatcher*> DispatchersMap; | 79 typedef std::map<unsigned long, MessagePumpDispatcher*> DispatchersMap; |
80 typedef std::vector<MessagePumpDispatcher*> Dispatchers; | |
81 | 80 |
82 // Initializes the glib event source for X. | 81 // Initializes the glib event source for X. |
83 void InitXSource(); | 82 void InitXSource(); |
84 | 83 |
85 // Dispatches the XEvent and returns true if we should exit the current loop | 84 // Dispatches the XEvent and returns true if we should exit the current loop |
86 // of message processing. | 85 // of message processing. |
87 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); | 86 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); |
88 | 87 |
89 // Sends the event to the observers. If an observer returns true, then it does | 88 // Sends the event to the observers. If an observer returns true, then it does |
90 // not send the event to any other observers and returns true. Returns false | 89 // not send the event to any other observers and returns true. Returns false |
91 // if no observer returns true. | 90 // if no observer returns true. |
92 bool WillProcessXEvent(XEvent* xevent); | 91 bool WillProcessXEvent(XEvent* xevent); |
93 void DidProcessXEvent(XEvent* xevent); | 92 void DidProcessXEvent(XEvent* xevent); |
94 | 93 |
95 // Returns the Dispatcher based on the event's target window. | 94 // Returns the Dispatcher based on the event's target window. |
96 MessagePumpDispatcher* GetDispatcherForXEvent( | 95 MessagePumpDispatcher* GetDispatcherForXEvent( |
97 const base::NativeEvent& xev) const; | 96 const base::NativeEvent& xev) const; |
98 | 97 |
99 // Overridden from MessagePumpDispatcher: | 98 // Overridden from MessagePumpDispatcher: |
100 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; | 99 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
101 | 100 |
102 // The event source for X events. | 101 // The event source for X events. |
103 GSource* x_source_; | 102 GSource* x_source_; |
104 | 103 |
105 // The poll attached to |x_source_|. | 104 // The poll attached to |x_source_|. |
106 scoped_ptr<GPollFD> x_poll_; | 105 scoped_ptr<GPollFD> x_poll_; |
107 | 106 |
108 DispatchersMap dispatchers_; | 107 DispatchersMap dispatchers_; |
109 Dispatchers root_window_dispatchers_; | 108 |
109 // Dispatch calls can cause addition of new dispatchers as we iterate | |
110 // through them. Use ObserverList to ensure the iterator remains valid across | |
111 // additions. | |
112 ObserverList<MessagePumpDispatcher> root_window_dispatchers_; | |
willchan no longer on Chromium
2012/12/19 17:25:42
YOu need the #include for this.
| |
110 | 113 |
111 unsigned long x_root_window_; | 114 unsigned long x_root_window_; |
112 | 115 |
113 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); | 116 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); |
114 }; | 117 }; |
115 | 118 |
116 typedef MessagePumpAuraX11 MessagePumpForUI; | 119 typedef MessagePumpAuraX11 MessagePumpForUI; |
117 | 120 |
118 } // namespace base | 121 } // namespace base |
119 | 122 |
120 #endif // BASE_MESSAGE_PUMP_AURAX11_H | 123 #endif // BASE_MESSAGE_PUMP_AURAX11_H |
OLD | NEW |