Skip to content

Commit

Permalink
Keep override_redirect in sync between guid and X11
Browse files Browse the repository at this point in the history
commit 50b0c3f911c2624dde76f4a17a539a7d6361539f upstream.

XChangeWindowAttributes() was not called when a window switched
override_redirect from enabled to disabled, allowing a VM to create a
window without any border.

Fix this by inlining fix_menu() into handle_map() -- it was not used
anywhere else -- and tweaking the logic.
  • Loading branch information
Rusty Bird authored and l0kod committed Oct 27, 2016
1 parent 48e2565 commit 53eb1e6
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions daemon/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,29 +336,13 @@ static void handle_destroy(Ghandles * g, struct genlist *l)
free(vm_window);
}

/* fix menu window parameters: override_redirect and force to not hide its
* frame */
static void fix_menu(Ghandles * g, struct windowdata *vm_window)
{
XSetWindowAttributes attr;

attr.override_redirect = 1;
XChangeWindowAttributes(g->display, vm_window->local_winid,
CWOverrideRedirect, &attr);
vm_window->override_redirect = 1;

// do not let menu window hide its color frame by moving outside of the screen
// if it is located offscreen, then allow negative x/y
if (force_on_screen(g, vm_window, 0, "fix_menu"))
moveresize_vm_window(g, vm_window);
}

/* handle VM message: MSG_MAP
* Map a window with given parameters */
static void handle_map(Ghandles * g, struct windowdata *vm_window)
{
struct genlist *trans;
struct msg_map_info untrusted_txt;
XSetWindowAttributes attr;

read_struct(g->xchan, untrusted_txt);
vm_window->is_mapped = 1;
Expand All @@ -372,9 +356,15 @@ static void handle_map(Ghandles * g, struct windowdata *vm_window)
transdata->local_winid);
} else
vm_window->transient_for = NULL;
vm_window->override_redirect = 0;
if (untrusted_txt.override_redirect)
fix_menu(g, vm_window);

vm_window->override_redirect = !!(untrusted_txt.override_redirect);
attr.override_redirect = vm_window->override_redirect;
XChangeWindowAttributes(g->display, vm_window->local_winid,
CWOverrideRedirect, &attr);
if (vm_window->override_redirect
&& force_on_screen(g, vm_window, 0, "handle_map"))
moveresize_vm_window(g, vm_window);

(void) XMapWindow(g->display, vm_window->local_winid);
}

Expand Down

0 comments on commit 53eb1e6

Please sign in to comment.