From 466fcee707b11ddb0cac3caeedcf9966cbe8435b Mon Sep 17 00:00:00 2001 From: Michael Cardell Widerkrantz Date: Thu, 21 Jul 2011 14:50:23 +0200 Subject: Use the X server's Save Set to store the windows we know about. This means they will be get automatically mapped and reparented if mcwm exits even if it crashes. Simplified cleanup() to reflect the above change. We still need to change the keyboard focus policy from mcwm's default to follow pointer instead. If mcwm crashes completely before we reach cleanup() this might become a problem. All the windows will be mapped but there won't be a keyboard focus and no way to change it. I don't know how to fix that right now. Don't attempt to catch SIGSEGV. Might be dangerous. --- mcwm.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/mcwm.c b/mcwm.c index efba40e..758d8e3 100644 --- a/mcwm.c +++ b/mcwm.c @@ -447,33 +447,19 @@ struct modkeycodes getmodkeys(xcb_mod_mask_t modmask) } /* - * Map all windows we know about. Set keyboard focus to be wherever - * the mouse pointer is. Then exit. + * Set keyboard focus to follow mouse pointer. Then exit. + * + * We don't need to bother mapping all windows we know about. They + * should all be in the X server's Save Set and should be mapped + * automagically. */ void cleanup(int code) { - struct item *item; - struct client *client; - xcb_set_input_focus(conn, XCB_NONE, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_CURRENT_TIME); - - for (item = winlist; item != NULL; item = item->next) - { - client = item->data; - xcb_map_window(conn, client->id); - } - xcb_flush(conn); - - if (SIGSEGV == code) - { - abort(); - } - - xcb_disconnect(conn); - + xcb_disconnect(conn); exit(code); } @@ -1044,6 +1030,9 @@ struct client *setupwin(xcb_window_t win) values[0] = XCB_EVENT_MASK_ENTER_WINDOW; xcb_change_window_attributes_checked(conn, win, mask, values); + /* Add this window to the X Save Set. */ + xcb_change_save_set(conn, XCB_SET_MODE_INSERT, win); + xcb_flush(conn); /* Remember window and store a few things about it. */ @@ -3926,12 +3915,6 @@ int main(int argc, char **argv) exit(1); } - if (SIG_ERR == signal(SIGSEGV, sigcatch)) - { - perror("mcwm: signal"); - exit(1); - } - if (SIG_ERR == signal(SIGTERM, sigcatch)) { perror("mcwm: signal"); -- cgit v1.2.3