Properly handle windows unsetting WM_TRANSIENT_FOR (Thanks Janus)

fixes #1351
This commit is contained in:
Michael Stapelberg 2014-08-26 10:00:14 +02:00
parent 9058fc44e6
commit 2fecf57699
4 changed files with 33 additions and 3 deletions

View File

@ -339,6 +339,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr(i3string_as_utf8(con->window->name)); ystr(i3string_as_utf8(con->window->name));
} }
ystr("transient_for");
if (con->window->transient_for == XCB_NONE)
y(null);
else y(integer, con->window->transient_for);
y(map_close); y(map_close);
} }

View File

@ -288,6 +288,8 @@ void render_con(Con *con, bool render_fullscreen) {
while (transient_con != NULL && while (transient_con != NULL &&
transient_con->window != NULL && transient_con->window != NULL &&
transient_con->window->transient_for != XCB_NONE) { transient_con->window->transient_for != XCB_NONE) {
DLOG("transient_con = 0x%08x, transient_con->window->transient_for = 0x%08x, fullscreen_id = 0x%08x\n",
transient_con->window->id, transient_con->window->transient_for, fullscreen->window->id);
if (transient_con->window->transient_for == fullscreen->window->id) { if (transient_con->window->transient_for == fullscreen->window->id) {
is_transient_for = true; is_transient_for = true;
break; break;

View File

@ -125,7 +125,8 @@ void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bo
*/ */
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop) { void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop) {
if (prop == NULL || xcb_get_property_value_length(prop) == 0) { if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
DLOG("CLIENT_LEADER not set.\n"); DLOG("CLIENT_LEADER not set on window 0x%08x.\n", win->id);
win->leader = XCB_NONE;
FREE(prop); FREE(prop);
return; return;
} }
@ -149,7 +150,8 @@ void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop) {
*/ */
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop) { void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop) {
if (prop == NULL || xcb_get_property_value_length(prop) == 0) { if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
DLOG("TRANSIENT_FOR not set.\n"); DLOG("TRANSIENT_FOR not set on window 0x%08x.\n", win->id);
win->transient_for = XCB_NONE;
FREE(prop); FREE(prop);
return; return;
} }
@ -160,7 +162,7 @@ void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
return; return;
} }
DLOG("Transient for changed to %08x\n", transient_for); DLOG("Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->id);
win->transient_for = transient_for; win->transient_for = transient_for;

View File

@ -99,4 +99,25 @@ is($x->input_focus, $child->id, "Child window focused");
} }
################################################################################
# Verify that transient_for can be set and unset.
################################################################################
$tmp = fresh_workspace;
$fwindow = open_window({ dont_map => 1 });
$fwindow->transient_for($right);
$fwindow->map;
my $floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
is($floating_con->{window_properties}->{transient_for}, $right->id, 'WM_TRANSIENT_FOR properly parsed');
$x->delete_property($fwindow->id, $x->atom(name => 'WM_TRANSIENT_FOR')->id);
$x->flush;
sync_with_i3;
$floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
is($floating_con->{window_properties}->{transient_for}, undef, 'WM_TRANSIENT_FOR properly removed');
done_testing; done_testing;