Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "trayicon.h"
#include "shm-args.h"
#include "util.h"
#include "unistd.h"
#include <qubes/pure.h>

/* Supported protocol version */
Expand Down Expand Up @@ -385,7 +386,17 @@ static Window mkwindow(Ghandles * g, struct windowdata *vm_window)
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask | StructureNotifyMask | PropertyChangeMask);
XSetWMProtocols(g->display, child_win, &g->wmDeleteMessage, 1);

/* setting WM_CLIENT_MACHINE, _NET_WM_PID, _NET_WM_PING */
XSetWMClientMachine(g->display, child_win, &g->hostname);
XChangeProperty(g->display, child_win, g->wm_pid, XA_CARDINAL,
32 /* bits */ , PropModeReplace,
(unsigned char *) &g->pid, 1);
Atom protocols[2];
protocols[0] = g->wmDeleteMessage;
protocols[1] = g->wm_ping;
XSetWMProtocols(g->display, child_win, protocols, 2);

if (g->icon_data) {
XChangeProperty(g->display, child_win, g->net_wm_icon, XA_CARDINAL, 32,
PropModeReplace, (unsigned char *) g->icon_data,
Expand Down Expand Up @@ -423,6 +434,7 @@ static Window mkwindow(Ghandles * g, struct windowdata *vm_window)
32, PropModeReplace,
(const unsigned char *)&vm_window->remote_winid,
1);

/* extra properties from command line */
for (i = 0; i < MAX_EXTRA_PROPS; i++) {
if (g->extra_props[i].prop) {
Expand Down Expand Up @@ -600,6 +612,8 @@ static void intern_global_atoms(Ghandles *const g) {
{ &g->wm_user_time, "_NET_WM_USER_TIME" },
{ &g->wmDeleteMessage, "WM_DELETE_WINDOW" },
{ &g->net_supported, "_NET_SUPPORTED" },
{ &g->wm_pid, "_NET_WM_PID" },
{ &g->wm_ping, "_NET_WM_PING" },
};
Atom labels[QUBES_ARRAY_SIZE(atoms_to_intern)];
const char *names[QUBES_ARRAY_SIZE(atoms_to_intern)];
Expand Down Expand Up @@ -644,6 +658,14 @@ static bool qubes_get_all_atom_properties(Display *const display,
* most of them are handles to local Xserver structures */
static void mkghandles(Ghandles * g)
{
char buf[256];
char *list[1] = { buf };
if (gethostname(buf, sizeof(buf)) == -1) {
fprintf(stderr, "Cannot get GUIVM hostname!\n");
exit(1);
}
XStringListToTextProperty(list, 1, &g->hostname);
g->pid = getpid();
int ev_base, err_base; /* ignore */
XWindowAttributes attr;
int i;
Expand Down Expand Up @@ -2649,6 +2671,15 @@ static void process_xevent(Ghandles * g)
(int) event_buffer.xclient.window);
process_xevent_close(g,
event_buffer.xclient.window);
} else if ((Atom)event_buffer.xclient.data.l[0] ==
g->wm_ping) {
XClientMessageEvent *ev = (XClientMessageEvent *) &event_buffer;
ev->window = g->root_win;
XSendEvent(g->display, g->root_win, False,
(SubstructureNotifyMask|SubstructureRedirectMask),
&event_buffer);
if (g->log_level > 1)
fprintf(stderr, "Received ping request from Window Manager\n");
}
break;
default:;
Expand Down Expand Up @@ -4570,6 +4601,7 @@ static void get_boot_lock(int domid)
}

static void cleanup() {
XFree(ghandles.hostname.value);
XCloseDisplay(ghandles.display);
unset_alive_flag();
close(ghandles.inter_appviewer_lock_fd);
Expand Down
4 changes: 4 additions & 0 deletions gui-daemon/xside.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ struct extra_prop {
struct _global_handles {
/* local X server handles and attributes */
Display *display;
XTextProperty hostname; /* dom0 or GUIVM hostname */
pid_t pid; /* GUI daemon PID */
int screen; /* shortcut to the default screen */
Window root_win; /* root attributes */
int root_width; /* size of root window */
Expand All @@ -171,6 +173,8 @@ struct _global_handles {
Atom wm_state_maximized_horz; /* Atom: _NET_WM_STATE_MAXIMIZED_HORZ */
Atom wm_user_time_window; /* Atom: _NET_WM_USER_TIME_WINDOW */
Atom wm_user_time; /* Atom: _NET_WM_USER_TIME */
Atom wm_pid; /* Atom: _NET_WM_PID */
Atom wm_ping; /* Atom: _NET_WM_PING */
int shm_major_opcode; /* MIT-SHM extension opcode */
/* shared memory handling */
struct shm_args_hdr *shm_args; /* shared memory with Xorg */
Expand Down