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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
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
Origin: https://gitlab.gnome.org/3v1n0/gnome-shell/-/commits/tray-offscreen-xwindows
Bug: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7613
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 e0ac102..6564149 100644
--- a/meson.build
+++ b/meson.build
@@ -93,6 +93,7 @@ have_x11 = mutter_dep.get_variable('have_x11') == 'true'
have_x11_client = mutter_dep.get_variable('have_x11_client') == 'true'
if have_x11_client or have_x11
x11_dep = dependency('x11')
+ xext_dep = dependency('xext')
xfixes_dep = dependency('xfixes')
endif
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 75af21a..1be1e9d 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;
|