summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2011-07-21 14:50:23 +0200
committerMichael Cardell Widerkrantz <mc@hack.org>2011-07-21 14:50:23 +0200
commit466fcee707b11ddb0cac3caeedcf9966cbe8435b (patch)
tree5120c1e34272df5df61b137809e3cb81472e3f31
parent45f3d30720e29b1b7596df47add1ee7cd80b0530 (diff)
downloadmcwm-466fcee707b11ddb0cac3caeedcf9966cbe8435b.zip
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.
-rw-r--r--mcwm.c35
1 files 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");