[mutter] window: Use client PID for meta_window_get_pid()
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window: Use client PID for meta_window_get_pid()
- Date: Thu, 21 May 2020 23:27:08 +0000 (UTC)
commit dac09a8e2332b4093d515343a162bc13b125dd72
Author: Jonas Dreßler <verdre v0yd nl>
Date: Mon Apr 6 13:03:49 2020 +0200
window: Use client PID for meta_window_get_pid()
The shell uses the PID of windows to map them to apps or to find out
which window/app triggered a dialog. It currently fails to do that in
some situations on Wayland, because meta_window_get_pid() only returns a
valid PID for x11 clients.
So use the client PID instead of the X11-exclusive _NET_WM_PID property
to find out the PID of the process that started the window. We can do
that by simply renaming the already existing
meta_window_get_client_pid() API to meta_window_get_pid() and moving
the old API providing the _NET_WM_PID to meta_window_get_netwm_pid().
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
src/core/delete.c | 2 +-
src/core/window-private.h | 2 --
src/core/window.c | 23 ++++-------------------
src/meta/window.h | 2 +-
src/wayland/meta-xwayland.c | 2 +-
5 files changed, 7 insertions(+), 24 deletions(-)
---
diff --git a/src/core/delete.c b/src/core/delete.c
index 28ca63d89..2727711f9 100644
--- a/src/core/delete.c
+++ b/src/core/delete.c
@@ -95,7 +95,7 @@ meta_window_delete (MetaWindow *window,
void
meta_window_kill (MetaWindow *window)
{
- pid_t pid = meta_window_get_client_pid (window);
+ pid_t pid = meta_window_get_pid (window);
if (pid > 0)
{
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 0d1ff6831..c72dc41d8 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -821,8 +821,6 @@ gboolean meta_window_handle_ui_frame_event (MetaWindow *window,
void meta_window_handle_ungrabbed_event (MetaWindow *window,
const ClutterEvent *event);
-uint32_t meta_window_get_client_pid (MetaWindow *window);
-
void meta_window_get_client_area_rect (const MetaWindow *window,
cairo_rectangle_int_t *rect);
void meta_window_get_titlebar_rect (MetaWindow *window,
diff --git a/src/core/window.c b/src/core/window.c
index 75012ed6c..d3b2c7d7e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -902,7 +902,7 @@ meta_window_update_sandboxed_app_id (MetaWindow *window)
g_clear_pointer (&window->sandboxed_app_id, g_free);
- pid = meta_window_get_client_pid (window);
+ pid = meta_window_get_pid (window);
if (pid == 0)
return;
@@ -7584,7 +7584,7 @@ meta_window_get_transient_for (MetaWindow *window)
}
/**
- * meta_window_get_client_pid:
+ * meta_window_get_pid:
* @window: a #MetaWindow
*
* Returns the pid of the process that created this window, if available
@@ -7593,26 +7593,11 @@ meta_window_get_transient_for (MetaWindow *window)
* Return value: the pid, or 0 if not known.
*/
uint32_t
-meta_window_get_client_pid (MetaWindow *window)
-{
- return META_WINDOW_GET_CLASS (window)->get_client_pid (window);
-}
-
-/**
- * meta_window_get_pid:
- * @window: a #MetaWindow
- *
- * Returns pid of the process that created this window, if known (obtained from
- * the _NET_WM_PID property).
- *
- * Return value: the pid, or -1 if not known.
- */
-int
meta_window_get_pid (MetaWindow *window)
{
- g_return_val_if_fail (META_IS_WINDOW (window), -1);
+ g_return_val_if_fail (META_IS_WINDOW (window), 0);
- return window->net_wm_pid;
+ return META_WINDOW_GET_CLASS (window)->get_client_pid (window);
}
/**
diff --git a/src/meta/window.h b/src/meta/window.h
index cb0f1afe6..46bdab964 100644
--- a/src/meta/window.h
+++ b/src/meta/window.h
@@ -328,7 +328,7 @@ META_EXPORT
guint32 meta_window_get_user_time (MetaWindow *window);
META_EXPORT
-int meta_window_get_pid (MetaWindow *window);
+uint32_t meta_window_get_pid (MetaWindow *window);
META_EXPORT
const char *meta_window_get_client_machine (MetaWindow *window);
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index ac55599d4..1b67c0a92 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -713,7 +713,7 @@ window_created_cb (MetaDisplay *display,
{
/* Ignore all internal windows */
if (!window->xwindow ||
- meta_window_get_client_pid (window) == getpid ())
+ meta_window_get_pid (window) == getpid ())
return;
manager->x11_windows = g_list_prepend (manager->x11_windows, window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]