[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 29 18:20:27 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

New commits:
commit 0f340ed4e814b445dbdd37b154015585769df589
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 29 17:14:13 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jun 29 20:19:52 2021 +0200

    gtk[3|4] AnyInput wasn't doing anything useful under wayland
    
    which is going to be the case for all backends under gtk4
    
    at least detect if there is evidence that the VCL_INPUT_ANY
    condition is true to curtail the idle spellchecking (etc)
    writer loop in favor of user interaction
    
    Change-Id: Id1cefd720a921e3a0d1d403769c544c15c6360e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118126
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 2cba3cb6f10d..3b4f9afbf1b9 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -439,17 +439,37 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
 
     static constexpr VclInputFlags ANY_INPUT_EXCLUDING_TIMER = VCL_INPUT_ANY & ~VclInputFlags::TIMER;
 
+    const bool bCheckForAnyInput = nType == ANY_INPUT_EXCLUDING_TIMER;
+
+    bool bRet = false;
+
+#if defined(GDK_WINDOWING_WAYLAND)
+    if (bCheckForAnyInput)
+    {
+        GdkDisplay* pDisplay = gdk_display_get_default();
+        if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
+        {
+            wl_display* pWLDisplay = gdk_wayland_display_get_wl_display(pDisplay);
+            static auto wayland_display_get_fd = reinterpret_cast<int (*) (wl_display*)>(dlsym(nullptr, "wl_display_get_fd"));
+            if (wayland_display_get_fd)
+            {
+                GPollFD aPollFD;
+                aPollFD.fd = wayland_display_get_fd(pWLDisplay);
+                aPollFD.events = G_IO_IN | G_IO_ERR | G_IO_HUP;
+                bRet = g_poll(&aPollFD, 1, 0) > 0;
+            }
+        }
+    }
+#endif
+
 #if !GTK_CHECK_VERSION(4, 0, 0)
     GdkDisplay* pDisplay = gdk_display_get_default();
     if (!gdk_display_has_pending(pDisplay))
-        return false;
-#endif
+        return bRet;
 
-    if (nType == ANY_INPUT_EXCLUDING_TIMER)
+    if (bCheckForAnyInput)
         return true;
 
-    bool bRet = false;
-#if !GTK_CHECK_VERSION(4, 0, 0)
     std::deque<GdkEvent*> aEvents;
     GdkEvent *pEvent = nullptr;
     while ((pEvent = gdk_display_get_event(pDisplay)))
@@ -470,6 +490,7 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
         aEvents.pop_front();
     }
 #endif
+
     return bRet;
 }
 


More information about the Libreoffice-commits mailing list