Add _NET_WM_PID and required WM_CLIENT_MACHINE properties to windows.

This commit is contained in:
Henrik Andersson 2015-09-15 12:38:28 +02:00
parent c843a3237f
commit 49a67bdfce
3 changed files with 33 additions and 1 deletions

View File

@ -6,6 +6,7 @@
Copyright 2005-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
Copyright 2015 Henrik Andersson <hean01@cendio.se> for Cendio AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -35,7 +36,7 @@ extern Display *g_display;
static Atom g_net_wm_state_maximized_vert_atom, g_net_wm_state_maximized_horz_atom,
g_net_wm_state_hidden_atom, g_net_wm_name_atom, g_utf8_string_atom,
g_net_wm_state_skip_taskbar_atom, g_net_wm_state_skip_pager_atom,
g_net_wm_state_modal_atom, g_net_wm_icon_atom, g_net_wm_state_above_atom;
g_net_wm_state_modal_atom, g_net_wm_icon_atom, g_net_wm_state_above_atom, g_net_wm_pid_atom;
Atom g_net_wm_state_atom, g_net_wm_desktop_atom;
@ -190,6 +191,7 @@ ewmh_init()
g_net_wm_desktop_atom = XInternAtom(g_display, "_NET_WM_DESKTOP", False);
g_net_wm_name_atom = XInternAtom(g_display, "_NET_WM_NAME", False);
g_net_wm_icon_atom = XInternAtom(g_display, "_NET_WM_ICON", False);
g_net_wm_pid_atom = XInternAtom(g_display, "_NET_WM_PID", False);
g_utf8_string_atom = XInternAtom(g_display, "UTF8_STRING", False);
}
@ -409,6 +411,12 @@ ewmh_set_wm_name(Window wnd, const char *title)
8, PropModeReplace, (unsigned char *) title, len);
}
void
ewmh_set_wm_pid(Window wnd, pid_t pid)
{
XChangeProperty(g_display, wnd, g_net_wm_pid_atom,
XA_CARDINAL, sizeof(pid_t) * 8, PropModeReplace, (unsigned char *) &pid, 1);
}
int
ewmh_set_window_popup(Window wnd)

View File

@ -7,6 +7,7 @@ int ewmh_change_state(Window wnd, int state);
int ewmh_move_to_desktop(Window wnd, unsigned int desktop);
int ewmh_get_window_desktop(Window wnd);
void ewmh_set_wm_name(Window wnd, const char *title);
void ewmh_set_wm_pid(Window wnd, pid_t pid);
int ewmh_set_window_popup(Window wnd);
int ewmh_set_window_modal(Window wnd);
void ewmh_set_icon(Window wnd, int width, int height, const char *rgba_data);

23
xwin.c
View File

@ -20,6 +20,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xproto.h>
@ -507,6 +508,7 @@ sw_find_group(unsigned long id, RD_BOOL dont_create)
sg->wnd =
XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, 0, &attribs);
ewmh_set_wm_pid(sg->wnd, getpid());
sg->id = id;
sg->refcnt = 0;
@ -1834,6 +1836,23 @@ error_handler(Display * dpy, XErrorEvent * eev)
return g_old_error_handler(dpy, eev);
}
static void
set_wm_client_machine(Display * dpy, Window win)
{
XTextProperty tp;
char hostname[HOST_NAME_MAX];
if (gethostname(hostname, sizeof(hostname)) != 0)
return;
tp.value = hostname;
tp.nitems = strlen(hostname);
tp.encoding = XA_STRING;
tp.format = 8;
XSetWMClientMachine(dpy, win, &tp);
}
/* Initialize the UI. This is done once per process. */
RD_BOOL
ui_init(void)
@ -2031,6 +2050,8 @@ ui_create_window(void)
wndheight, 0, g_depth, InputOutput, g_visual,
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
CWBorderPixel, &attribs);
ewmh_set_wm_pid(g_wnd, getpid());
set_wm_client_machine(g_display, g_wnd);
if (g_gc == NULL)
{
@ -3942,6 +3963,8 @@ ui_seamless_create_window(unsigned long id, unsigned long group, unsigned long p
wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, g_depth,
InputOutput, g_visual,
CWBackPixel | CWBackingStore | CWColormap | CWBorderPixel, &attribs);
ewmh_set_wm_pid(wnd, getpid());
set_wm_client_machine(g_display, wnd);
XStoreName(g_display, wnd, "SeamlessRDP");
ewmh_set_wm_name(wnd, "SeamlessRDP");