shell: Move _NET_WM_PID query to NaTrayChild
It already does some other poking on the plug window, it can do this as well. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2590>
This commit is contained in:
parent
ab60902058
commit
b8e3f5a536
@ -238,18 +238,10 @@ shell_tray_icon_set_child (ShellTrayIcon *tray_icon,
|
|||||||
NaTrayChild *tray_child)
|
NaTrayChild *tray_child)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = shell_global_get_display (shell_global_get ());
|
MetaDisplay *display = shell_global_get_display (shell_global_get ());
|
||||||
MetaX11Display *x11_display;
|
|
||||||
Display *xdisplay;
|
|
||||||
Window plug_xid;
|
|
||||||
Atom type;
|
|
||||||
int result, format;
|
|
||||||
gulong nitems, bytes_after, *val = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (tray_icon != NULL);
|
g_return_if_fail (tray_icon != NULL);
|
||||||
g_return_if_fail (tray_child != NULL);
|
g_return_if_fail (tray_child != NULL);
|
||||||
|
|
||||||
x11_display = meta_display_get_x11_display (display);
|
|
||||||
|
|
||||||
/* We do all this now rather than computing it on the fly later,
|
/* We do all this now rather than computing it on the fly later,
|
||||||
* because the shell may want to see their values from a
|
* because the shell may want to see their values from a
|
||||||
* tray-icon-removed signal handler, at which point the plug has
|
* tray-icon-removed signal handler, at which point the plug has
|
||||||
@ -261,25 +253,7 @@ shell_tray_icon_set_child (ShellTrayIcon *tray_icon,
|
|||||||
tray_icon->title = na_tray_child_get_title (tray_icon->tray_child);
|
tray_icon->title = na_tray_child_get_title (tray_icon->tray_child);
|
||||||
na_tray_child_get_wm_class (tray_icon->tray_child,
|
na_tray_child_get_wm_class (tray_icon->tray_child,
|
||||||
NULL, &tray_icon->wm_class);
|
NULL, &tray_icon->wm_class);
|
||||||
|
tray_icon->pid = na_tray_child_get_pid (tray_icon->tray_child);
|
||||||
plug_xid = na_xembed_get_plug_window (NA_XEMBED (tray_icon->tray_child));
|
|
||||||
|
|
||||||
xdisplay = meta_x11_display_get_xdisplay (x11_display);
|
|
||||||
meta_x11_error_trap_push (x11_display);
|
|
||||||
result = XGetWindowProperty (xdisplay, plug_xid,
|
|
||||||
XInternAtom (xdisplay, "_NET_WM_PID", False),
|
|
||||||
0, G_MAXLONG, False, XA_CARDINAL,
|
|
||||||
&type, &format, &nitems,
|
|
||||||
&bytes_after, (guchar **)&val);
|
|
||||||
|
|
||||||
if (!meta_x11_error_trap_pop_with_return (x11_display) &&
|
|
||||||
result == Success &&
|
|
||||||
type == XA_CARDINAL &&
|
|
||||||
nitems == 1)
|
|
||||||
tray_icon->pid = *val;
|
|
||||||
|
|
||||||
if (val)
|
|
||||||
XFree (val);
|
|
||||||
|
|
||||||
tray_icon->window_created_handler =
|
tray_icon->window_created_handler =
|
||||||
g_signal_connect (display,
|
g_signal_connect (display,
|
||||||
|
@ -219,3 +219,37 @@ na_tray_child_get_wm_class (NaTrayChild *child,
|
|||||||
res_class,
|
res_class,
|
||||||
res_name);
|
res_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
na_tray_child_get_pid (NaTrayChild *child)
|
||||||
|
{
|
||||||
|
MetaX11Display *x11_display;
|
||||||
|
Display *xdisplay;
|
||||||
|
Atom type;
|
||||||
|
int result, format;
|
||||||
|
gulong nitems, bytes_after, *val = NULL;
|
||||||
|
pid_t pid = 0;
|
||||||
|
|
||||||
|
x11_display = na_xembed_get_x11_display (NA_XEMBED (child));
|
||||||
|
xdisplay = meta_x11_display_get_xdisplay (x11_display);
|
||||||
|
|
||||||
|
xdisplay = meta_x11_display_get_xdisplay (x11_display);
|
||||||
|
meta_x11_error_trap_push (x11_display);
|
||||||
|
result = XGetWindowProperty (xdisplay,
|
||||||
|
na_xembed_get_plug_window (NA_XEMBED (child)),
|
||||||
|
XInternAtom (xdisplay, "_NET_WM_PID", False),
|
||||||
|
0, G_MAXLONG, False, XA_CARDINAL,
|
||||||
|
&type, &format, &nitems,
|
||||||
|
&bytes_after, (guchar **)&val);
|
||||||
|
|
||||||
|
if (!meta_x11_error_trap_pop_with_return (x11_display) &&
|
||||||
|
result == Success &&
|
||||||
|
type == XA_CARDINAL &&
|
||||||
|
nitems == 1)
|
||||||
|
pid = *val;
|
||||||
|
|
||||||
|
if (val)
|
||||||
|
XFree (val);
|
||||||
|
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
@ -37,6 +37,9 @@ void na_tray_child_get_wm_class (NaTrayChild *child,
|
|||||||
char **res_name,
|
char **res_name,
|
||||||
char **res_class);
|
char **res_class);
|
||||||
|
|
||||||
|
pid_t na_tray_child_get_pid (NaTrayChild *child);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __NA_TRAY_CHILD_H__ */
|
#endif /* __NA_TRAY_CHILD_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user