forked from ~ljy/RK356X_SDK_RELEASE

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