From 49c1a33a4dfe15f312334584c22b4ec3ed792214 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan <fourdan@xfce.org> Date: Sat, 23 May 2020 10:47:13 +0200 Subject: [PATCH] client: Rely in XRes reported PID is available When xfwm4 needs to kill an unresponsive client, it will use the its PID is known. However, the _NET_WM_PID as defined in the extended window manager hint mechanism is unreliable when the client runs within a sandbox, as it is the client itself who sets that property using its own view of the PID. The Xserver can provide a more accurate value of the client PID using the XRes X11 extension, so use that protocol if available. Signed-off-by: Olivier Fourdan <fourdan@xfce.org> --- src/client.c | 7 +++---- src/events.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/client.c b/src/client.c index 0808e5a93..47f5c7b79 100644 --- a/src/client.c +++ b/src/client.c @@ -17,7 +17,7 @@ oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2011 Olivier Fourdan + xfwm4 - (c) 2002-2020 Olivier Fourdan */ @@ -1793,9 +1793,8 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture) clientAddUserTimeWin (c); clientGetUserTime (c); - /*client PID */ - getHint (display_info, c->window, NET_WM_PID, (long *) &pid); - c->pid = (GPid) pid; + /* client PID */ + c->pid = getWindowPID (display_info, c->window); TRACE ("client \"%s\" (0x%lx) PID = %i", c->name, c->window, c->pid); /* Apply startup notification properties if available */ diff --git a/src/events.c b/src/events.c index 7699ee614..dc74ce285 100644 --- a/src/events.c +++ b/src/events.c @@ -17,7 +17,7 @@ oroborus - (c) 2001 Ken Lynch - xfwm4 - (c) 2002-2015 Olivier Fourdan + xfwm4 - (c) 2002-2020 Olivier Fourdan */ @@ -581,6 +581,8 @@ handleKeyPress (DisplayInfo *display_info, XfwmEventKey *event) static eventFilterStatus handleKeyRelease (DisplayInfo *display_info, XfwmEventKey *event) { + Client *c; + TRACE ("entering"); /* Release pending events */ @@ -1621,6 +1623,7 @@ handleFocusIn (DisplayInfo *display_info, XFocusChangeEvent * ev) } } + return EVENT_FILTER_REMOVE; } @@ -1804,11 +1807,12 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev) } else if (ev->atom == display_info->atoms[NET_WM_PID]) { - long pid; TRACE ("client \"%s\" (0x%lx) has received a NET_WM_PID notify", c->name, c->window); - getHint (display_info, c->window, NET_WM_PID, (long *) &pid); - c->pid = (GPid) pid; - TRACE ("client \"%s\" (0x%lx) updated PID = %i", c->name, c->window, c->pid); + if (c->pid == 0) + { + c->pid = getWindowPID (display_info, c->window); + TRACE ("client \"%s\" (0x%lx) updated PID = %i", c->name, c->window, c->pid); + } } else if (ev->atom == display_info->atoms[NET_WM_WINDOW_OPACITY]) { -- GitLab