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

Unified Diff: ui/events/platform/x11/x11_event_source.h

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: XEventDispatcher added. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/platform/x11/x11_event_source.h
diff --git a/ui/events/platform/x11/x11_event_source.h b/ui/events/platform/x11/x11_event_source.h
index 26d646016607273684183310df1a393d8e0d1558..472e89e1a3a8dd5e905c0eb57f2f419194a0c154 100644
--- a/ui/events/platform/x11/x11_event_source.h
+++ b/ui/events/platform/x11/x11_event_source.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
#include "ui/events/events_export.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11_types.h"
@@ -20,6 +21,20 @@ typedef unsigned long XID;
namespace ui {
+// Interface for classes that want to receive XEvent directly. Only used with
+// ozone_platform_x11 and only events that can't be translated into ui::Events
+// are sent via this path.
+class EVENTS_EXPORT XEventDispatcher {
+ public:
+ // Sends XEvent to XEventDispatcher for handling. Returns true if the XEvent
+ // was dispatched, otherwise false. After the first XEventDispatcher returns
+ // true XEvent dispatching stops.
+ virtual bool DispatchXEvent(const XEvent& event) = 0;
+
+ protected:
+ virtual ~XEventDispatcher() {}
+};
+
class X11HotplugEventHandler;
// A PlatformEventSource implementation for reading events from X11 server and
@@ -31,6 +46,12 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
static X11EventSource* GetInstance();
+ // Adds a XEvent dispatcher to the dispatcher list.
+ void AddXEventDispatcher(XEventDispatcher* dispatcher);
+
+ // Removes a XEvent dispatcher from the dispatcher list.
+ void RemoveXEventDispatcher(XEventDispatcher* dispatcher);
+
// Called by the glib source dispatch function. Processes all (if any)
// available X events.
void DispatchXEvents();
@@ -56,10 +77,16 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
uint32_t ExtractCookieDataDispatchEvent(XEvent* xevent);
// PlatformEventSource:
- uint32_t DispatchEvent(XEvent* xevent) override;
+ uint32_t DispatchEvent(base::NativeEvent native_event) override;
void StopCurrentEventStream() override;
void OnDispatcherListChanged() override;
+ // Sends XEvent to registered XEventDispatchers.
+ void DispatchXEventToXEventDispatchers(XEvent* xevent);
+
+ // Handles updates after event has been dispatched.
+ void PostDispatchEvent(XEvent* xevent);
+
// The connection to the X11 server used to receive the events.
XDisplay* display_;
@@ -69,6 +96,10 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
scoped_ptr<X11HotplugEventHandler> hotplug_event_handler_;
+ // Keep track of all XEventDispatcher to send XEvents directly to, only used
+ // with ozone.
spang 2016/01/26 21:37:40 Why "only used with ozone" ? I think anything tha
kylechar 2016/01/27 15:39:26 As long as there are no PlatformEventObservers in
kylechar 2016/02/01 16:44:27 After talking with Sadrul we decided that only X11
+ base::ObserverList<XEventDispatcher> x_dispatchers_;
+
DISALLOW_COPY_AND_ASSIGN(X11EventSource);
};

Powered by Google App Engine
This is Rietveld 408576698