summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-29 17:14:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-29 20:19:52 +0200
commit0f340ed4e814b445dbdd37b154015585769df589 (patch)
treea079753ef76d7dd2a4dea7550d4df98653cf7bbc
parentcc94c93bf2cf64ecbef835b1410ffc1a2bf40353 (diff)
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@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx31
1 files changed, 26 insertions, 5 deletions
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;
}