OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ | 5 #ifndef UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ | 6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/events/events_export.h" | 9 #include "ui/events/events_export.h" |
10 #include "ui/events/platform/platform_event_source.h" | 10 #include "ui/events/platform/platform_event_source.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // A PlatformEventSource implementation for reading events from X11 server and | 22 // A PlatformEventSource implementation for reading events from X11 server and |
23 // dispatching the events to the appropriate dispatcher. | 23 // dispatching the events to the appropriate dispatcher. |
24 class EVENTS_EXPORT X11EventSource : public PlatformEventSource { | 24 class EVENTS_EXPORT X11EventSource : public PlatformEventSource { |
25 public: | 25 public: |
26 explicit X11EventSource(XDisplay* display); | 26 explicit X11EventSource(XDisplay* display); |
27 ~X11EventSource() override; | 27 ~X11EventSource() override; |
28 | 28 |
29 static X11EventSource* GetInstance(); | 29 static X11EventSource* GetInstance(); |
30 | 30 |
31 // Called by the glib source dispatch function. Processes all (if any) | 31 // Processes pending X events. Returns true if any events were dispatched. |
32 // available X events. | 32 // This function should be called repeatedly until it returns false to |
33 void DispatchXEvents(); | 33 // ensure all events are processed. |
| 34 bool DispatchXEvents(); |
34 | 35 |
35 // Blocks on the X11 event queue until we receive notification from the | 36 // Blocks on the X11 event queue until we receive notification from the |
36 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are | 37 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are |
37 // pulled out from the queue and dispatched out of order. | 38 // pulled out from the queue and dispatched out of order. |
38 // | 39 // |
39 // For those that know X11, this is really a wrapper around XWindowEvent | 40 // For those that know X11, this is really a wrapper around XWindowEvent |
40 // which still makes sure the preempted event is dispatched instead of | 41 // which still makes sure the preempted event is dispatched instead of |
41 // dropped on the floor. This method exists because mapping a window is | 42 // dropped on the floor. This method exists because mapping a window is |
42 // asynchronous (and we receive an XEvent when mapped), while there are also | 43 // asynchronous (and we receive an XEvent when mapped), while there are also |
43 // functions which require a mapped window. | 44 // functions which require a mapped window. |
44 void BlockUntilWindowMapped(XID window); | 45 void BlockUntilWindowMapped(XID window); |
45 | 46 |
46 protected: | 47 protected: |
47 XDisplay* display() { return display_; } | 48 XDisplay* display() { return display_; } |
48 | 49 |
49 private: | 50 private: |
50 // PlatformEventSource: | 51 // PlatformEventSource: |
51 uint32_t DispatchEvent(XEvent* xevent) override; | 52 uint32_t DispatchEvent(XEvent* xevent) override; |
52 void StopCurrentEventStream() override; | 53 void StopCurrentEventStream() override; |
53 void OnDispatcherListChanged() override; | 54 void OnDispatcherListChanged() override; |
54 | 55 |
55 // The connection to the X11 server used to receive the events. | 56 // The connection to the X11 server used to receive the events. |
56 XDisplay* display_; | 57 XDisplay* display_; |
57 | 58 |
58 // Keeps track of whether this source should continue to dispatch all the | 59 // Keeps track of whether this source should continue to dispatch all the |
59 // available events. | 60 // available events. |
60 bool continue_stream_; | 61 bool continue_stream_; |
61 | 62 |
| 63 // Dispatch one event at a time. |
| 64 bool dispatch_one_event_per_loop_; |
| 65 |
62 scoped_ptr<X11HotplugEventHandler> hotplug_event_handler_; | 66 scoped_ptr<X11HotplugEventHandler> hotplug_event_handler_; |
63 | 67 |
64 DISALLOW_COPY_AND_ASSIGN(X11EventSource); | 68 DISALLOW_COPY_AND_ASSIGN(X11EventSource); |
65 }; | 69 }; |
66 | 70 |
67 } // namespace ui | 71 } // namespace ui |
68 | 72 |
69 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ | 73 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
OLD | NEW |