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

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

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final fixes for comments + tests. Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 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_LIBEVENT_H_
6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_LIBEVENT_H_
7
8 #include "base/macros.h"
9 #include "base/message_loop/message_pump_libevent.h"
10 #include "ui/events/events_export.h"
11 #include "ui/events/platform/platform_event_source.h"
12 #include "ui/events/platform/x11/x11_event_source.h"
13
14 namespace ui {
15
16 // Interface for classes that want to receive XEvent directly. Only used with
17 // Ozone X11 currently and only events that can't be translated into ui::Events
18 // are sent via this path.
19 class EVENTS_EXPORT XEventDispatcher {
20 public:
21 // Sends XEvent to XEventDispatcher for handling. Returns true if the XEvent
22 // was dispatched, otherwise false. After the first XEventDispatcher returns
23 // true XEvent dispatching stops.
24 virtual bool DispatchXEvent(XEvent* xevent) = 0;
25
26 protected:
27 virtual ~XEventDispatcher() {}
28 };
29
30 // A PlatformEventSource implementation for Ozone X11. Converts XEvents to
31 // ui::Events before dispatching. For X11 specific events a separate list of
32 // XEventDispatchers is maintained. Uses Libevent to be notified for incoming
33 // XEvents.
34 class EVENTS_EXPORT X11EventSourceLibevent
35 : public X11EventSourceDelegate,
36 public PlatformEventSource,
37 public base::MessagePumpLibevent::Watcher {
38 public:
39 explicit X11EventSourceLibevent(XDisplay* display);
40 ~X11EventSourceLibevent() override;
41
42 // Adds a XEvent dispatcher to the XEvent dispatcher list.
43 void AddXEventDispatcher(XEventDispatcher* dispatcher);
44
45 // Removes a XEvent dispatcher fERrom the XEvent dispatcher list.
46 void RemoveXEventDispatcher(XEventDispatcher* dispatcher);
47
48 // X11EventSourceDelegate:
49 void ProcessXEvent(XEvent* xevent) override;
50
51 private:
52 // Registers event watcher with Libevent.
53 void AddEventWatcher();
54
55 // Sends XEvent to registered XEventDispatchers.
56 void DispatchXEventToXEventDispatchers(XEvent* xevent);
57
58 // PlatformEventSource:
59 void StopCurrentEventStream() override;
60 void OnDispatcherListChanged() override;
61
62 // base::MessagePumpLibevent::Watcher:
63 void OnFileCanReadWithoutBlocking(int fd) override;
64 void OnFileCanWriteWithoutBlocking(int fd) override;
65
66 X11EventSource event_source_;
67
68 // Keep track of all XEventDispatcher to send XEvents directly to.
69 base::ObserverList<XEventDispatcher> dispatchers_xevent_;
70
71 base::MessagePumpLibevent::FileDescriptorWatcher watcher_controller_;
72 bool initialized_ = false;
73
74 DISALLOW_COPY_AND_ASSIGN(X11EventSourceLibevent);
75 };
76
77 } // namespace ui
78
79 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_LIBEVENT_H_
OLDNEW
« no previous file with comments | « ui/events/platform/x11/x11_event_source_glib.cc ('k') | ui/events/platform/x11/x11_event_source_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698