Index: ui/ozone/platform/wayland/wayland_window.cc |
diff --git a/ui/ozone/platform/wayland/wayland_window.cc b/ui/ozone/platform/wayland/wayland_window.cc |
index b64f0bc732e32b595db2c82301f51734e7d4094a..46c639adc04d2de01395039909dd1bc055532a82 100644 |
--- a/ui/ozone/platform/wayland/wayland_window.cc |
+++ b/ui/ozone/platform/wayland/wayland_window.cc |
@@ -7,6 +7,8 @@ |
#include <xdg-shell-unstable-v5-client-protocol.h> |
#include "base/strings/utf_string_conversions.h" |
+#include "ui/events/event.h" |
+#include "ui/events/ozone/events_ozone.h" |
#include "ui/ozone/platform/wayland/wayland_display.h" |
#include "ui/platform_window/platform_window_delegate.h" |
@@ -19,10 +21,17 @@ WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate, |
WaylandWindow::~WaylandWindow() { |
if (xdg_surface_) { |
+ PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
display_->RemoveWindow(surface_.id()); |
} |
} |
+// static |
+WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) { |
+ return static_cast<WaylandWindow*>( |
+ wl_proxy_get_user_data(reinterpret_cast<wl_proxy*>(surface))); |
+} |
+ |
bool WaylandWindow::Initialize() { |
static const xdg_surface_listener xdg_surface_listener = { |
&WaylandWindow::Configure, &WaylandWindow::Close, |
@@ -44,6 +53,7 @@ bool WaylandWindow::Initialize() { |
display_->ScheduleFlush(); |
display_->AddWindow(surface_.id(), this); |
+ PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f); |
return true; |
@@ -134,6 +144,21 @@ PlatformImeController* WaylandWindow::GetPlatformImeController() { |
return nullptr; |
} |
+bool WaylandWindow::CanDispatchEvent(const PlatformEvent& native_event) { |
+ Event* event = static_cast<Event*>(native_event); |
+ if (event->IsMouseEvent()) |
+ return has_pointer_focus_; |
+ return false; |
+} |
+ |
+uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) { |
+ DispatchEventFromNativeUiEvent( |
+ native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
+ base::Unretained(delegate_))); |
+ return POST_DISPATCH_STOP_PROPAGATION; |
+} |
+ |
+// static |
void WaylandWindow::Configure(void* data, |
xdg_surface* obj, |
int32_t width, |
@@ -150,6 +175,7 @@ void WaylandWindow::Configure(void* data, |
window->pending_configure_serial_ = serial; |
} |
+// static |
void WaylandWindow::Close(void* data, xdg_surface* obj) { |
NOTIMPLEMENTED(); |
} |