1From 58b0b91db2a3ac7bb78894479e2da7238db814f6 Mon Sep 17 00:00:00 2001 2From: Takuro Ashie <ashie@clear-code.com> 3Date: Sun, 14 Jul 2019 14:26:44 +0900 4Subject: [PATCH] Bug 1451816 - Workarround for grabbing focus on weston 5 6See https://bugzilla.mozilla.org/show_bug.cgi?id=1451816 for more 7detail. 8 9Upstream-Status: Denied [Fixed by GTK-3.24's new feature] 10 11Signed-off-by: Takuro Ashie <ashie@clear-code.com> 12 13--- 14 widget/gtk/nsWindow.cpp | 17 +++++++++++++++++ 15 1 file changed, 17 insertions(+) 16 17diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp 18index b64fc87a94..8d661794db 100644 19--- a/widget/gtk/nsWindow.cpp 20+++ b/widget/gtk/nsWindow.cpp 21@@ -145,6 +145,10 @@ using namespace mozilla::layers; 22 using mozilla::gl::GLContext; 23 using mozilla::gl::GLContextGLX; 24 25+#ifdef MOZ_WAYLAND 26+static bool gPointerGrabbed = false; 27+#endif 28+ 29 // Don't put more than this many rects in the dirty region, just fluff 30 // out to the bounding-box if there are more 31 #define MAX_RECTS_IN_REGION 100 32@@ -2919,6 +2923,11 @@ void nsWindow::OnContainerFocusInEvent(GdkEventFocus* aEvent) { 33 void nsWindow::OnContainerFocusOutEvent(GdkEventFocus* aEvent) { 34 LOGFOCUS(("OnContainerFocusOutEvent [%p]\n", (void*)this)); 35 36+#ifdef MOZ_WAYLAND 37+ if (gtk_check_version(3, 24, 0) != nullptr && gPointerGrabbed) 38+ return; 39+#endif 40+ 41 if (mWindowType == eWindowType_toplevel || 42 mWindowType == eWindowType_dialog) { 43 nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID); 44@@ -4750,6 +4759,10 @@ void nsWindow::GrabPointer(guint32 aTime) { 45 if (!mIsX11Display) { 46 // Don't to the grab on Wayland as it causes a regression 47 // from Bug 1377084. 48+#ifdef MOZ_WAYLAND 49+ if (gtk_check_version(3, 24, 0) != nullptr) 50+ gPointerGrabbed = true; 51+#endif 52 return; 53 } 54 55@@ -4789,6 +4802,10 @@ void nsWindow::ReleaseGrabs(void) { 56 if (!mIsX11Display) { 57 // Don't to the ungrab on Wayland as it causes a regression 58 // from Bug 1377084. 59+#ifdef MOZ_WAYLAND 60+ if (gtk_check_version(3, 24, 0) != nullptr) 61+ gPointerGrabbed = false; 62+#endif 63 return; 64 } 65 66