GNOME Bugzilla – Bug 772613
Add meta_window_get_client_pid() method
Last modified: 2016-10-10 22:53:59 UTC
Having a way to identify the PID of the process that owns a window without relying on the application is part of making window matching reliable for Flatpak apps. I went with a separate method for now, though another option would be to extend the existing meta_window_get_pid() (that is, only fall back to _NET_WM_PID if the attempt to query the X server fails).
Created attachment 337239 [details] [review] window: Add get_client_pid() method It is often useful to identify the client process that created a particular window, however the existing meta_window_get_pid() method relies on _NET_WM_PID, which is only available on X11 and depends on applications to set it correctly (which may not even be possible when the app runs in its own PID namespace as Flatpak apps do). So add a get_client_pid() method that uses windowing system facilities to resolve the PID associated with a particular window.
Created attachment 337240 [details] [review] delete: Share some code between X11 and wayland In order to kill a window, on both X11 and wayland we first try to kill(3) the corresponding process, so we can add the newly added get_client_pid() method to share that code.
Review of attachment 337239 [details] [review]: looks fine ::: configure.ac @@ +86,3 @@ x11-xcb xcb-randr + xcb-res hopefully this is widely deployed, the X server implementation seems to be ~6 years old ::: src/x11/window-x11.c @@ +1497,3 @@ + + cookie = xcb_res_query_client_ids (xcb, 1, &spec); + reply = xcb_res_query_client_ids_reply (xcb, cookie, NULL); round trip :-/ I guess it doesn't matter too much in practice
Review of attachment 337240 [details] [review]: ++ ::: src/x11/window-x11.c @@ -706,3 @@ { meta_topic (META_DEBUG_WINDOW_OPS, - "Killing %s brutally\n", y u hate fun debug messages?!!!1!!one
Attachment 337239 [details] pushed as 1fab6e6 - window: Add get_client_pid() method Attachment 337240 [details] pushed as e994435 - delete: Share some code between X11 and wayland