Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: ui/events/platform/x11/x11_event_source.h

Issue 203483004: events: Introduce PlatformEventDispatcher and PlatformEventSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/events/events_export.h"
10 #include "ui/events/platform/platform_event_source.h"
11 #include "ui/gfx/x/x11_types.h"
12
13 typedef struct _GPollFD GPollFD;
14 typedef struct _GSource GSource;
15 typedef union _XEvent XEvent;
16 typedef unsigned long XID;
17
18 namespace ui {
19
20 // A PlatformEventSource implementation for reading events from X11 server and
21 // dispatching the events to the appropriate dispatcher.
22 class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
23 public:
24 explicit X11EventSource(XDisplay* display);
25 virtual ~X11EventSource();
26
27 static X11EventSource* GetInstance();
28
29 // Called by the glib source dispatch function. Processes all (if any)
30 // available X events.
31 void DispatchXEvents();
32
33 // Blocks on the X11 event queue until we receive notification from the
34 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are
35 // pulled out from the queue and dispatched out of order.
36 //
37 // For those that know X11, this is really a wrapper around XWindowEvent
38 // which still makes sure the preempted event is dispatched instead of
39 // dropped on the floor. This method exists because mapping a window is
40 // asynchronous (and we receive an XEvent when mapped), while there are also
41 // functions which require a mapped window.
42 void BlockUntilWindowMapped(XID window);
43
44 private:
45 // Initializes the glib event source for X.
46 void InitXSource();
47
48 // PlatformEventSource:
49 virtual uint32_t DispatchEvent(XEvent* xevent) OVERRIDE;
50
51 // The connection to the X11 server used to receive the events.
52 XDisplay* display_;
53
54 // The GLib event source for X events.
55 GSource* x_source_;
56
57 // The poll attached to |x_source_|.
58 scoped_ptr<GPollFD> x_poll_;
59
60 DISALLOW_COPY_AND_ASSIGN(X11EventSource);
61 };
62
63 } // namespace ui
64
65 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698