diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-05-28 12:09:47 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-05-29 20:19:05 -0400 |
commit | 60aeb15116364e42b48e1f99342b9812248450e2 (patch) | |
tree | f020014db50272a24c7a5279e07ff027cf42a0f3 | |
parent | c83441ae4a55db5487250821eed4a7bf900e495b (diff) | |
download | gtk+-60aeb15116364e42b48e1f99342b9812248450e2.tar.gz |
x11: Don't set NET_WM_PID when sandboxed
It is not useful, and some window managers misinterpret it and
add some "runs as root" indication to the window decoration.
See https://github.com/mate-desktop/marco/issues/301
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 15 | ||||
-rw-r--r-- | gdk/x11/gdksurface-x11.c | 17 |
2 files changed, 19 insertions, 13 deletions
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 4ac989d3de..c452fd1a96 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1436,7 +1436,6 @@ gdk_x11_display_open (const gchar *display_name) gchar *argv[1]; XClassHint *class_hint; - gulong pid; gint ignore; gint maj, min; @@ -1600,11 +1599,15 @@ gdk_x11_display_open (const gchar *display_name) if (gdk_sm_client_id) set_sm_client_id (display, gdk_sm_client_id); - pid = getpid (); - XChangeProperty (display_x11->xdisplay, - display_x11->leader_window, - gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"), - XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1); + if (!gdk_running_in_sandbox ()) + { + /* if sandboxed, we're likely in a pid namespace and would only confuse the wm with this */ + pid_t pid = getpid (); + XChangeProperty (display_x11->xdisplay, + display_x11->leader_window, + gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"), + XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1); + } /* We don't yet know a valid time. */ display_x11->user_time = 0; diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index c55589c849..43c48b986a 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -718,7 +718,6 @@ setup_toplevel_window (GdkSurface *surface, Display *xdisplay = GDK_SURFACE_XDISPLAY (surface); XID xid = GDK_SURFACE_XID (surface); XSizeHints size_hints; - long pid; Window leader_window; set_wm_protocols (surface); @@ -749,12 +748,16 @@ setup_toplevel_window (GdkSurface *surface, /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */ XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL); - pid = getpid (); - XChangeProperty (xdisplay, xid, - gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_PID"), - XA_CARDINAL, 32, - PropModeReplace, - (guchar *)&pid, 1); + if (!gdk_running_in_sandbox ()) + { + /* if sandboxed, we're likely in a pid namespace and would only confuse the wm with this */ + pid_t pid = getpid (); + XChangeProperty (xdisplay, xid, + gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_PID"), + XA_CARDINAL, 32, + PropModeReplace, + (guchar *)&pid, 1); + } leader_window = GDK_X11_DISPLAY (x11_screen->display)->leader_window; if (!leader_window) |