summaryrefslogtreecommitdiff
path: root/chromium/ui/events/platform/x11/x11_event_source_default.h
diff options
context:
space:
mode:
authorNick Diego Yamane <nickdiego@igalia.com>2019-08-14 22:35:41 +0000
committerMichal Klocek <michal.klocek@qt.io>2019-10-11 12:28:29 +0000
commit580ffe2cb7500a210ec7e10ad312f45fb1152572 (patch)
treee7d338712ffde16cdd5f45160469bd8a869d6b90 /chromium/ui/events/platform/x11/x11_event_source_default.h
parent6a5dc3af353796d7075f0b41d611f88ba3c9f1c8 (diff)
downloadqtwebengine-chromium-580ffe2cb7500a210ec7e10ad312f45fb1152572.tar.gz
[Backport] Reintroduce glib event loop 2/3
Make it possible to use glib message pump in Ozone Ozone implementation assumes libevent MessagePump is used (more specifically, MessagePumpLibevent and X11EventSourceLibevent are directly referenced), which makes it impossible to build/run ozone-based builds with use_glib=true. This CL changes it, making use mainly of Message{Pump,Loop}CurrentFor{UI,IO} APIs. The main motivation for this is to bring up glib MessagePump/EventSource in ozone/x11 UI thread, which is part of the effort to migrate away from Aura/X11 to Ozone in Linux desktop. So, with this change, use_glib can be set to true when configuring ozone/linux builds. Additionally, X11EventSourceLibevent is renamed (as it is not libevent-specific anymore). Also, from now on it will be possible to start XEvent => ui::Event migration in Aura/X11, reducing even more the delta between ozone and non-ozone X11. A preliminary step towards that is done in this CL, which consists of moving XEventDispatcher API out of X11EventSourceDelegate into X11EventSource, so that its consumers should not use delegate implementation to register/unregister |XEventDispatcher|s anymore, thus making delegate implementation more like an internal detail, at some point it might makes sense to merge delegate impl into X11EventSource and even move it into ozone/x11 layer. Bug: 988094, 789065 Change-Id: I46c38aa26475ae8f3f89ef0c632d4c8ffb76fd7c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/events/platform/x11/x11_event_source_default.h')
-rw-r--r--chromium/ui/events/platform/x11/x11_event_source_default.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/chromium/ui/events/platform/x11/x11_event_source_default.h b/chromium/ui/events/platform/x11/x11_event_source_default.h
new file mode 100644
index 00000000000..58def8a3dea
--- /dev/null
+++ b/chromium/ui/events/platform/x11/x11_event_source_default.h
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_DEFAULT_H_
+#define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_DEFAULT_H_
+
+#include "base/macros.h"
+#include "base/message_loop/message_pump_for_ui.h"
+#include "ui/events/events_export.h"
+#include "ui/events/platform/platform_event_source.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+
+namespace ui {
+
+// PlatformEventSource implementation which uses MessagePumpForUI::FdWatcher to
+// be notified about incoming XEvents and converts XEvents to ui::Events before
+// dispatching. For X11 specific events a separate list of XEventDispatchers is
+// maintained.
+class EVENTS_EXPORT X11EventSourceDefault
+ : public X11EventSourceDelegate,
+ public PlatformEventSource,
+ public base::MessagePumpForUI::FdWatcher {
+ public:
+ explicit X11EventSourceDefault(XDisplay* display);
+ ~X11EventSourceDefault() override;
+
+ static X11EventSourceDefault* GetInstance();
+
+ // X11EventSourceDelegate:
+ void ProcessXEvent(XEvent* xevent) override;
+ void AddXEventDispatcher(XEventDispatcher* dispatcher) override;
+ void RemoveXEventDispatcher(XEventDispatcher* dispatcher) override;
+
+ private:
+ // Registers event watcher with Libevent.
+ void AddEventWatcher();
+
+ // Tells XEventDispatchers, which can also have PlatformEventDispatchers, that
+ // a translated event is going to be sent next, then dispatches the event and
+ // notifies XEventDispatchers the event has been sent out and, most probably,
+ // consumed.
+ void DispatchPlatformEvent(const PlatformEvent& event, XEvent* xevent);
+
+ // Sends XEvent to registered XEventDispatchers.
+ void DispatchXEventToXEventDispatchers(XEvent* xevent);
+
+ // PlatformEventSource:
+ void StopCurrentEventStream() override;
+ void OnDispatcherListChanged() override;
+
+ // base::MessagePumpForUI::FdWatcher:
+ void OnFileCanReadWithoutBlocking(int fd) override;
+ void OnFileCanWriteWithoutBlocking(int fd) override;
+
+ X11EventSource event_source_;
+
+ // Keep track of all XEventDispatcher to send XEvents directly to.
+ base::ObserverList<XEventDispatcher>::Unchecked dispatchers_xevent_;
+
+ base::MessagePumpForUI::FdWatchController watcher_controller_;
+ bool initialized_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(X11EventSourceDefault);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_DEFAULT_H_