Handle unmap notifications

This commit is contained in:
Bastien Dejean 2012-09-21 12:15:25 +02:00
parent eadc5f69a1
commit 09f163becc
5 changed files with 28 additions and 14 deletions

View file

@ -100,6 +100,8 @@ void map_request(xcb_generic_event_t *evt)
xcb_map_window(dpy, c->window);
c->visible = true;
if (takes_focus)
xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, win, XCB_CURRENT_TIME);
@ -193,12 +195,12 @@ void unmap_notify(xcb_generic_event_t *evt)
PRINTF("unmap notify %X\n", e->window);
return;
window_location_t loc;
if (locate_window(e->window, &loc)) {
remove_node(loc.desktop, loc.node);
apply_layout(loc.desktop, loc.desktop->root, root_rect);
if (loc.node->client->visible) {
remove_node(loc.desktop, loc.node);
apply_layout(loc.desktop, loc.desktop->root, root_rect);
}
}
}
@ -239,9 +241,11 @@ void client_message(xcb_generic_event_t *evt)
handle_state(loc.node, e->data.data32[1], e->data.data32[0]);
handle_state(loc.node, e->data.data32[2], e->data.data32[0]);
} else if (e->type == ewmh->_NET_ACTIVE_WINDOW) {
if (desk->focus != NULL && desk->focus->client->fullscreen)
return;
apply_layout(loc.desktop, loc.desktop->root, root_rect);
if (desk != loc.desktop)
select_desktop(loc.desktop);
apply_layout(loc.desktop, loc.desktop->root, root_rect);
focus_node(loc.desktop, loc.node, true);
}
}

20
tree.c
View file

@ -179,10 +179,11 @@ void dump_tree(desktop_t *d, node_t *n, char *rsp, int depth)
if (is_leaf(n))
/* sprintf(line, "0x%X [%i %i %u %u]", n->client->window, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height); */
sprintf(line, "C %X [%i %i %u %u] (%s%s) [%i %i %u %u]", n->client->window, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), n->client->rectangle.x, n->client->rectangle.y, n->client->rectangle.width, n->client->rectangle.height);
/* sprintf(line, "C %X [%i %i %u %u] (%s%s) [%i %i %u %u]", n->client->window, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), n->client->rectangle.x, n->client->rectangle.y, n->client->rectangle.width, n->client->rectangle.height); */
sprintf(line, "C %X %s%s%s%s%s%s", n->client->window, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), (n->client->fullscreen ? "F" : "-"), (n->client->urgent ? "u" : "-"), (n->client->locked ? "l" : "-"), (n->client->visible ? "v" : "-"));
else
/* sprintf(line, "%s %.2f [%i %i %u %u]", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height); */
sprintf(line, "%s %.2f [%i %i %u %u]", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio, n->rectangle.x, n->rectangle.y, n->rectangle.width, n->rectangle.height);
sprintf(line, "%s %.2f %s", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio, (n->vacant ? "f" : "-"));
strcat(rsp, line);
@ -286,7 +287,7 @@ void insert_node(desktop_t *d, node_t *n)
if (d == NULL || n == NULL)
return;
PUTS("insert node");
PRINTF("insert node %X\n", n->client->window);
node_t *focus = d->focus;
@ -378,7 +379,7 @@ void focus_node(desktop_t *d, node_t *n, bool is_mapped)
if (desk->focus != NULL && desk->focus->client->fullscreen)
return;
PRINTF("focus_node %X\n", n->client->window);
PRINTF("focus node %X\n", n->client->window);
split_mode = MODE_AUTOMATIC;
n->client->urgent = false;
@ -417,7 +418,7 @@ void unlink_node(desktop_t *d, node_t *n)
if (d == NULL || n == NULL)
return;
PUTS("unlink node");
PRINTF("unlink node %X\n", n->client->window);
node_t *p = n->parent;
@ -514,16 +515,19 @@ void transfer_node(desktop_t *ds, desktop_t *dd, node_t *n)
if (n == NULL || ds == NULL || dd == NULL || dd == ds)
return;
PUTS("transfer node");
PRINTF("transfer node %X\n", n->client->window);
unlink_node(ds, n);
if (ds == desk)
if (ds == desk) {
n->client->visible = false;
xcb_unmap_window(dpy, n->client->window);
}
insert_node(dd, n);
if (dd == desk) {
n->client->visible = true;
xcb_map_window(dpy, n->client->window);
focus_node(dd, n, true);
} else {
@ -544,6 +548,7 @@ void select_desktop(desktop_t *d)
node_t *n = first_extrema(d->root);
while (n != NULL) {
n->client->visible = true;
xcb_map_window(dpy, n->client->window);
n = next_leaf(n);
}
@ -551,6 +556,7 @@ void select_desktop(desktop_t *d)
n = first_extrema(desk->root);
while (n != NULL) {
n->client->visible = false;
xcb_unmap_window(dpy, n->client->window);
n = next_leaf(n);
}

View file

@ -29,7 +29,7 @@ client_t *make_client(xcb_window_t win)
{
client_t *c = malloc(sizeof(client_t));
c->window = win;
c->floating = c->transient = c->fullscreen = c->locked = c->urgent = false;
c->floating = c->transient = c->fullscreen = c->locked = c->urgent = c->visible = false;
return c;
}

View file

@ -64,6 +64,7 @@ typedef struct {
bool fullscreen;
bool locked; /* protects window from being closed */
bool urgent;
bool visible;
xcb_rectangle_t rectangle;
} client_t;

View file

@ -145,7 +145,7 @@ void close_window(desktop_t *d, node_t *n)
if (n == NULL || n->client->locked)
return;
PUTS("close window");
PRINTF("close window %X\n", n->client->window);
xcb_atom_t WM_DELETE_WINDOW;
xcb_window_t win = n->client->window;
@ -209,6 +209,9 @@ void toggle_floating(node_t *n)
update_vacant_state(n->parent);
if (c->floating)
window_raise(c->window);
else if (is_tiled(c))
window_lower(c->window);
}
void toggle_locked(client_t *c)