92 lines
3.7 KiB
Diff
92 lines
3.7 KiB
Diff
From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
|
|
Date: Wed, 1 May 2024 22:34:58 +0200
|
|
Subject: tray/na-xembed: Use XShape to remove input on socket window
|
|
|
|
We don't want this window to take any input as, a part from blocking the
|
|
events on the shell representation itself, they may potentially make the
|
|
plugged window to do anything with the event is processing (such as
|
|
showing tooltips). And we don't want this since we only want to send to
|
|
those windows only the synthetic events that we explicitly control.
|
|
|
|
This was already the case before of commit ab60902058 but a similar
|
|
approach was not replicated, leading to input events being fully
|
|
processed from tray icons plugs.
|
|
|
|
It requires adding an explicit build dependency on Xext, but this is
|
|
something that mutter already depends on so not really a new dependency
|
|
|
|
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7613
|
|
(cherry picked from commit 075f9d72459d08a711feca3dc3c51a14c5f73bdc)
|
|
|
|
Origin: https://gitlab.gnome.org/3v1n0/gnome-shell/-/commits/tray-offscreen-xwindows
|
|
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2012388
|
|
---
|
|
meson.build | 1 +
|
|
src/tray/meson.build | 2 +-
|
|
src/tray/na-xembed.c | 15 +++++++++++++++
|
|
3 files changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
index ac166d5..f85e358 100644
|
|
--- a/meson.build
|
|
+++ b/meson.build
|
|
@@ -91,6 +91,7 @@ polkit_dep = dependency('polkit-agent-1', version: polkit_req)
|
|
startup_dep = dependency('libstartup-notification-1.0', version: startup_req)
|
|
ibus_dep = dependency('ibus-1.0', version: ibus_req)
|
|
x11_dep = dependency('x11')
|
|
+xext_dep = dependency('xext')
|
|
xfixes_dep = dependency('xfixes')
|
|
schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_req)
|
|
gnome_desktop_dep = dependency('gnome-desktop-4', version: gnome_desktop_req)
|
|
diff --git a/src/tray/meson.build b/src/tray/meson.build
|
|
index 2fc73f3..c91e940 100644
|
|
--- a/src/tray/meson.build
|
|
+++ b/src/tray/meson.build
|
|
@@ -9,6 +9,6 @@ tray_sources = [
|
|
|
|
libtray = static_library('tray', tray_sources,
|
|
c_args: ['-DG_LOG_DOMAIN="notification_area"'],
|
|
- dependencies: [mutter_dep, mtk_dep, xfixes_dep],
|
|
+ dependencies: [mutter_dep, mtk_dep, xfixes_dep, xext_dep],
|
|
include_directories: conf_inc
|
|
)
|
|
diff --git a/src/tray/na-xembed.c b/src/tray/na-xembed.c
|
|
index 59b1071..69690f1 100644
|
|
--- a/src/tray/na-xembed.c
|
|
+++ b/src/tray/na-xembed.c
|
|
@@ -24,6 +24,7 @@
|
|
#include "na-xembed.h"
|
|
|
|
#include <mtk/mtk-x11.h>
|
|
+#include <X11/extensions/shape.h>
|
|
#include <X11/extensions/Xfixes.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
@@ -362,6 +363,7 @@ na_xembed_add_window (NaXembed *xembed,
|
|
{
|
|
XSetWindowAttributes socket_attrs;
|
|
XWindowAttributes plug_attrs;
|
|
+ int shape_major, shape_minor;
|
|
int result;
|
|
|
|
result = XGetWindowAttributes (xdisplay, priv->plug_window, &plug_attrs);
|
|
@@ -407,6 +409,19 @@ na_xembed_add_window (NaXembed *xembed,
|
|
priv->plug_window,
|
|
priv->socket_window,
|
|
0, 0);
|
|
+
|
|
+ /* Set an empty input shape on the window so that the socket does not
|
|
+ * get any input. Without this we the tray may still get events and for
|
|
+ * example show tooltips on hover which we don't want.
|
|
+ * This is the quickest way to achieve this, without having to deal these
|
|
+ * windows with specific code in mutter.
|
|
+ */
|
|
+ if (XShapeQueryExtension (xdisplay, &shape_major, &shape_minor))
|
|
+ {
|
|
+ XShapeSelectInput (xdisplay, priv->socket_window, NoEventMask);
|
|
+ XShapeCombineRectangles (xdisplay, priv->socket_window, ShapeInput,
|
|
+ 0, 0, NULL, 0, ShapeSet, 0);
|
|
+ }
|
|
}
|
|
|
|
priv->have_size = FALSE;
|