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

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: Fixes for comments. 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 static X11EventSourceLibevent* GetInstance();
sadrul 2016/02/08 17:28:32 Looks like we need this only from X11WindowOzone.
kylechar 2016/02/08 19:08:09 Done.
43
44 // X11EventSourceDelegate:
45 void ProcessXEvent(XEvent* xevent) override;
46
47 // Adds a XEvent dispatcher to the XEvent dispatcher list.
48 void AddXEventDispatcher(XEventDispatcher* dispatcher);
49
50 // Removes a XEvent dispatcher fERrom the XEvent dispatcher list.
51 void RemoveXEventDispatcher(XEventDispatcher* dispatcher);
sadrul 2016/02/08 17:28:32 These should go before the override. (make sure to
kylechar 2016/02/08 19:08:10 Done.
52
53 private:
54 // PlatformEventSource:
55 void StopCurrentEventStream() override;
56 void OnDispatcherListChanged() override;
57
58 // Registers event watcher with Libevent.
59 void AddEventWatcher();
60
61 // Sends XEvent to registered XEventDispatchers.
62 void DispatchXEventToXEventDispatchers(XEvent* xevent);
sadrul 2016/02/08 17:28:33 ditto
kylechar 2016/02/08 19:08:10 Done.
63
64 // base::MessagePumpLibevent::Watcher:
65 void OnFileCanReadWithoutBlocking(int fd) override;
66 void OnFileCanWriteWithoutBlocking(int fd) override;
67
68 scoped_ptr<X11EventSource> event_source_;
sadrul 2016/02/08 17:28:33 This doesn't need to be a scoped_ptr<>?
kylechar 2016/02/08 19:08:10 Done.
69
70 // Keep track of all XEventDispatcher to send XEvents directly to.
71 base::ObserverList<XEventDispatcher> dispatchers_xevent_;
72
73 base::MessagePumpLibevent::FileDescriptorWatcher watcher_controller_;
74 bool initialized_ = false;
75
76 DISALLOW_COPY_AND_ASSIGN(X11EventSourceLibevent);
77 };
78
79 } // namespace ui
80
81 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698