diff options
author | Samuel Fadel <samuel@nihil.ws> | 2022-12-19 18:41:11 +0100 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2022-12-19 18:41:11 +0100 |
commit | 86d7067f5d27d7c97e9a1de8c4103e139af66c40 (patch) | |
tree | c844caea53bb5c190c8196b057196951dffe740e | |
parent | ee83fa44ae0e634fe7fbd94d7fd1b83d534e0437 (diff) |
Some debugging and bug fixing.
* schewm.c: Fix sizing when maximizing, investigate managing existing
windows
-rw-r--r-- | .manifest.scm | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | schewm.c | 35 | ||||
-rw-r--r-- | wm.scm | 1 |
4 files changed, 23 insertions, 18 deletions
diff --git a/.manifest.scm b/.manifest.scm index 56b34f4..a66134e 100644 --- a/.manifest.scm +++ b/.manifest.scm @@ -7,6 +7,7 @@ (gnu packages cpp) (gnu packages guile) (gnu packages pkg-config) + (gnu packages valgrind) (gnu packages xorg)) @@ -14,10 +15,12 @@ (list gnu-make gcc-toolchain + (list gcc-toolchain "debug") pkg-config libx11 libxcb xcb-util-keysyms xcb-util-wm ccls + valgrind )) @@ -4,4 +4,4 @@ LDFLAGS=`pkg-config --libs x11 xcb xcb-ewmh xcb-icccm xcb-keysyms xcb-randr` all: libschewm.so libschewm.so: schewm.c - gcc -fPIC -Wall ${CFLAGS} ${LDFLAGS} -shared -o libschewm.so schewm.c + gcc -fPIC -Wall -g ${CFLAGS} ${LDFLAGS} -shared -o libschewm.so schewm.c @@ -22,6 +22,7 @@ const uint16_t MOVE_GLYPH = 52; const uint16_t RESIZE_GLYPH = 120; // Key modifiers +const uint16_t MOD_ALT = XCB_MOD_MASK_1; const uint16_t MOD_META = XCB_MOD_MASK_4; const uint16_t MOD_SHIFT = XCB_MOD_MASK_SHIFT; @@ -717,7 +718,7 @@ windows_query(xcb_window_t root, struct WindowsQueryReply *reply) { } void -windows_query_reply_free(struct WindowsQueryReply *reply) { +windows_query_reply_wipe(struct WindowsQueryReply *reply) { if (reply->length > 0) { free(reply->data); } @@ -1370,7 +1371,7 @@ dpy_set_window_border_width(xcb_window_t window) { static void dpy_draw_borders(struct Client *client, bool is_focused) { - if (client->state != WS_NORMAL || client->should_ignore_borders) { + if (client->state == WS_ICONIFIED || client->should_ignore_borders) { return; } @@ -1663,12 +1664,14 @@ dpy_update_window_list(const struct ClientsMap *clients) { xcb_window_t *windows = NULL; size_t num_windows = 0; if (clients->size != 0) { + fprintf(stderr, "window_list:\n"); windows = malloc(clients->size * sizeof(xcb_window_t)); for (size_t i = 0; i < clients->num_buckets; i++) { for (struct ClientList *list = clients->buckets[i]; list != NULL; list = list->next) { windows[num_windows++] = list->client->id; + fprintf(stderr, "\twindow: %x\n", list->client->id); } } } @@ -1949,8 +1952,8 @@ wm_set_client_state(struct Client *client, enum WindowState state) { wm_client_monitor_size(client, true, &mon_rect); client->x = mon_rect.x; client->y = mon_rect.y; - client->width = mon_rect.width; - client->height = mon_rect.height; + client->width = mon_rect.width - cfg.inner_border_width * 2; + client->height = mon_rect.height - cfg.inner_border_width * 2; } dpy_update_window_geometry(client); break; @@ -2227,9 +2230,16 @@ manage_client_maybe_reposition(xcb_window_t window, bool set_position) { } wm_update_client_monitor(client); clients_map_add(wm.clients, client); - if (client->state == WS_NORMAL) { + 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; } @@ -2277,22 +2287,16 @@ wm_init() { * Could not be managed, just map it on screen because we * probably should not own it. */ + 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 at the - * wm_set_workspace() call below. - */ - dpy_unmap_window(window); } } - windows_query_reply_free(&reply); + windows_query_reply_wipe(&reply); dpy_update_window_list(wm.clients); wm_set_workspace(wm.cur_workspace); - wm.mod_key = MOD_META; + wm.mod_key = MOD_ALT; dpy_flush(); memset(wm.events, 0, sizeof(wm.events)); @@ -2736,7 +2740,6 @@ wm_run() { break; } - fprintf(stderr, "ev: %u\n", ev_type(ev)); EventHandler handler = wm.events[ev_type(ev)]; if (handler) { handler(ev); @@ -2830,7 +2833,7 @@ ev_configure_request(xcb_generic_event_t *generic_ev) { wm_update_client_monitor(client); // TODO: do we need this? - // dpy_draw_borders(client, wm.focus->id == client->id); + dpy_draw_borders(client, wm.focus == client); } } @@ -189,7 +189,6 @@ (define wm-client-monitor-next (schewm-func void "wm_client_monitor_next" '())) - (define c/keysym-from-str (schewm-func uint32 "keysym_from_str" |