Commit 28c33259 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

x11: Make PlatformEvent-related methods optional in XEventDispatcher interface

XEventDispatcher implementation *can* optionally be associated to a
PlatformEventDispatcher, however in most cases it is not the case and 3 methods
must be overridden with a empty/stub implementation. This CL changes
XEventDispatcher, adding default empty implementation for PlatformEvent-related
functions, making it easier and more intuitive implementing it.

Bug: 789065
Change-Id: Icdb501133817038a536b108f8a0d8556ff3389f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1710242
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680107}
parent c46bf7c0
......@@ -250,4 +250,12 @@ void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) {
NOTREACHED();
}
void XEventDispatcher::CheckCanDispatchNextPlatformEvent(XEvent* xev) {}
void XEventDispatcher::PlatformEventDispatchFinished() {}
PlatformEventDispatcher* XEventDispatcher::GetPlatformEventDispatcher() {
return nullptr;
}
} // namespace ui
......@@ -20,25 +20,25 @@ namespace ui {
// X11 currently.
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(XEvent* xevent) = 0;
// XEventDispatchers can be used to test if they are able to process next
// translated event sent by a PlatformEventSource. If so, they must make a
// promise internally to process next event sent by PlatformEventSource.
virtual void CheckCanDispatchNextPlatformEvent(XEvent* xev) = 0;
virtual void CheckCanDispatchNextPlatformEvent(XEvent* xev);
// Tells that an event has been dispatched and an event handling promise must
// be removed.
virtual void PlatformEventDispatchFinished() = 0;
virtual void PlatformEventDispatchFinished();
// Returns PlatformEventDispatcher if this XEventDispatcher is associated with
// a PlatformEventDispatcher as well. Used to explicitly add a
// PlatformEventDispatcher during a call from an XEventDispatcher to
// AddXEventDispatcher.
virtual PlatformEventDispatcher* GetPlatformEventDispatcher() = 0;
// 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(XEvent* xevent) = 0;
virtual PlatformEventDispatcher* GetPlatformEventDispatcher();
protected:
virtual ~XEventDispatcher() {}
......
......@@ -30,14 +30,6 @@ void GLSurfaceGLXOzone::UnregisterEvents() {
event_source->RemoveXEventDispatcher(this);
}
void GLSurfaceGLXOzone::CheckCanDispatchNextPlatformEvent(XEvent* xev) {}
void GLSurfaceGLXOzone::PlatformEventDispatchFinished() {}
PlatformEventDispatcher* GLSurfaceGLXOzone::GetPlatformEventDispatcher() {
return nullptr;
}
bool GLSurfaceGLXOzone::DispatchXEvent(XEvent* event) {
if (!CanHandleEvent(event))
return false;
......
......@@ -11,8 +11,6 @@
namespace ui {
class PlatformEventDispatcher;
// Ozone specific implementation of GLX surface. Registers as a XEventDispatcher
// to handle XEvents.
class GLSurfaceGLXOzone : public gl::NativeViewGLSurfaceGLX,
......@@ -28,9 +26,6 @@ class GLSurfaceGLXOzone : public gl::NativeViewGLSurfaceGLX,
void UnregisterEvents() override;
// XEventDispatcher:
void CheckCanDispatchNextPlatformEvent(XEvent* xev) override;
void PlatformEventDispatchFinished() override;
PlatformEventDispatcher* GetPlatformEventDispatcher() override;
bool DispatchXEvent(XEvent* xevent) override;
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment