summaryrefslogtreecommitdiff
path: root/schewm.c
diff options
context:
space:
mode:
Diffstat (limited to 'schewm.c')
-rw-r--r--schewm.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/schewm.c b/schewm.c
index e8d3151..bcbcb62 100644
--- a/schewm.c
+++ b/schewm.c
@@ -1264,8 +1264,8 @@ dpy_set_workspace(uint32_t workspace) {
}
static void
-dpy_set_num_workspaces() {
- xcb_ewmh_set_number_of_desktops(dpy.ewmh, dpy.screen_num, wm.num_workspaces);
+dpy_set_num_workspaces(uint32_t num_workspaces) {
+ xcb_ewmh_set_number_of_desktops(dpy.ewmh, dpy.screen_num, num_workspaces);
}
static void
@@ -2235,13 +2235,6 @@ manage_client_maybe_reposition(xcb_window_t window, bool set_position) {
if (client->state == WS_NORMAL || client->state == WS_MAXIMIZED) {
dpy_draw_unfocused_borders(client);
}
- /*
- * Unmap everything we grab initially because they may be
- * mapped currently, but belong to another workspace; this
- * way, we can map again only the correct windows at the
- * wm_set_workspace() call below.
- */
- dpy_unmap_window(window);
return client;
}
@@ -2272,12 +2265,12 @@ wm_init() {
}
wm.cur_workspace = 0;
- wm.num_workspaces = 10;
+ wm.num_workspaces = 9;
wm.workspaces = calloc(wm.num_workspaces, sizeof(struct Workspace));
if (wm.workspaces == NULL) {
return false;
}
- dpy_set_num_workspaces();
+ dpy_set_num_workspaces(wm.num_workspaces);
// Look into all existing windows and set them up
struct WindowsQueryReply reply;
@@ -2292,6 +2285,12 @@ wm_init() {
fprintf(stderr, "wm_init(): could not manage: %x\n", window);
dpy_map_window(window);
} else {
+ /*
+ * Unmap everything we grab initially because they may be
+ * mapped currently, but belong to another workspace; this
+ * way, we can map again only the correct windows.
+ */
+ dpy_unmap_window(window);
}
}
windows_query_reply_wipe(&reply);
@@ -2758,6 +2757,7 @@ wm_set_configure_request_handler(configure_request_handler_t handler) {
static void
ev_configure_request(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_configure_request\n");
xcb_configure_request_event_t *ev = (xcb_configure_request_event_t *) generic_ev;
if (configure_request_handler) {
configure_request_handler();
@@ -2835,6 +2835,7 @@ wm_set_destroy_notify_handler(destroy_notify_handler_t handler) {
static void
ev_destroy_notify(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_destroy_notify\n");
xcb_destroy_notify_event_t *ev = (xcb_destroy_notify_event_t *) generic_ev;
if (destroy_notify_handler) {
destroy_notify_handler();
@@ -2888,6 +2889,7 @@ wm_set_key_press_handler(key_press_handler_t handler) {
static void
ev_key_press(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_key_press\n");
xcb_key_press_event_t *ev = (xcb_key_press_event_t *) generic_ev;
uint16_t mod = dpy_clean_mod(ev->state);
xcb_keysym_t keysym = dpy_keysym_from_keycode(ev->detail);
@@ -2914,6 +2916,7 @@ wm_set_map_request_handler(map_request_handler_t handler) {
static void
ev_map_request(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_map_request\n");
xcb_map_request_event_t *ev = (xcb_map_request_event_t *) generic_ev;
if (map_request_handler) {
map_request_handler();
@@ -2926,15 +2929,14 @@ ev_map_request(xcb_generic_event_t *generic_ev) {
}
client = manage_client_maybe_reposition(ev->window, true);
- if (client == NULL) {
- dpy_map_window(ev->window);
- return;
+ if (client != NULL) {
+ dpy_set_window_state(client->id, WS_NORMAL);
+ dpy_center_cursor_client(client);
+ dpy_update_window_list(wm.clients);
}
- dpy_map_window(client->id);
- dpy_set_window_state(client->id, WS_NORMAL);
- dpy_center_cursor_client(client);
- dpy_update_window_list(wm.clients);
+ // Map as requested, it does not matter if we can manage or not
+ dpy_map_window(ev->window);
dpy_flush();
}
@@ -2949,10 +2951,12 @@ wm_set_unmap_notify_handler(unmap_notify_handler_t handler) {
static void
ev_unmap_notify(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_unmap_notify\n");
xcb_unmap_notify_event_t *ev = (xcb_unmap_notify_event_t *) generic_ev;
if (unmap_notify_handler) {
unmap_notify_handler();
}
+ return;
struct Client *client = wm_find_client(ev->window);
if (client == NULL
@@ -2960,7 +2964,7 @@ ev_unmap_notify(xcb_generic_event_t *generic_ev) {
|| client->state == WS_ICONIFIED) {
/*
* For unknown clients, clients not in our current workspace,
- * or when a client was unmmaped and new state is iconified,
+ * or when a client was unmmaped and state is already iconified,
* we don't have to do anything
*/
return;
@@ -2970,7 +2974,10 @@ ev_unmap_notify(xcb_generic_event_t *generic_ev) {
struct Client *ring_client = wm.workspaces[wm.cur_workspace].ring;
for (;;) {
if (ring_client->id == ev->window) {
- // We found the client, now we must handle the unmapping
+ /*
+ * We found the client in the current workspace, now we
+ * must handle the unmapping
+ */
should_ignore = false;
break;
}
@@ -2983,8 +2990,6 @@ ev_unmap_notify(xcb_generic_event_t *generic_ev) {
return;
}
- wm_erase_client(client->id);
- dpy_update_window_list(wm.clients);
dpy_flush();
}
@@ -3000,6 +3005,7 @@ wm_set_mapping_notify_handler(mapping_notify_handler_t handler) {
static void
ev_mapping_notify(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_mapping_notify\n");
if (mapping_notify_handler) {
xcb_mapping_notify_event_t *ev = (xcb_mapping_notify_event_t *) generic_ev;
mapping_notify_handler();
@@ -3017,12 +3023,14 @@ wm_set_configure_notify_handler(configure_notify_handler_t handler) {
static void
ev_configure_notify(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_configure_notify\n");
xcb_configure_notify_event_t *ev = (xcb_configure_notify_event_t *) generic_ev;
if (configure_notify_handler) {
configure_notify_handler(ev->x, ev->y, ev->width, ev->height);
}
if (ev->window != dpy.screen->root) {
+ // Currently ignoring regular windows being reconfigured
return;
}
@@ -3049,6 +3057,7 @@ wm_set_circulate_request_handler(circulate_request_handler_t handler) {
static void
ev_circulate_request(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_circulate_request\n");
xcb_circulate_request_event_t *ev = (xcb_circulate_request_event_t *) generic_ev;
if (circulate_request_handler) {
circulate_request_handler();
@@ -3076,6 +3085,7 @@ wm_set_button_press_handler(button_press_handler_t handler) {
static void
ev_button_press(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_button_press\n");
if (button_press_handler) {
xcb_button_press_event_t *ev = (xcb_button_press_event_t *) generic_ev;
button_press_handler();
@@ -3093,6 +3103,7 @@ wm_set_client_message_handler(client_message_handler_t handler) {
static void
ev_client_message(xcb_generic_event_t *generic_ev) {
+ fprintf(stderr, "ev_client_message\n");
xcb_client_message_event_t *ev = (xcb_client_message_event_t *) generic_ev;
if (client_message_handler) {
client_message_handler();