diff options
author | Samuel Fadel <samuel@nihil.ws> | 2022-12-18 13:34:54 +0100 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2022-12-18 13:34:54 +0100 |
commit | c33bba0db6e5c0d439a8aa5a1eb3a8a4ebcf03cf (patch) | |
tree | 554c8b793db509311aa0360ed825a91c5c40f19b /schewm.c | |
parent | ec2ecf9085d1c001b803d27261ecf7ae3fe6d298 (diff) |
WM reconfiguration code.
* main.scm: Added wm-reconifgure call to set initial config
* wm.scm: Added wiring to call C code for reconfiguration
* schewm.c: bugfix in ev_unmap_notify(); new wm_reconfigure() function
Diffstat (limited to 'schewm.c')
-rw-r--r-- | schewm.c | 89 |
1 files changed, 74 insertions, 15 deletions
@@ -600,7 +600,7 @@ callbacks_map_free(struct CallbacksMap *map) { free(map); } -static struct { +static struct Config { uint16_t inner_border_width, outer_border_width, magnet_border_width; int16_t offset_x, offset_y; uint16_t offset_width, offset_height; @@ -2103,6 +2103,12 @@ wm_fit_client(struct Client *client) { } void +wm_update_client_monitor(struct Client *client) { + client->monitor = find_monitor(client); + wm_fit_client(client); +} + +void wm_handle_state(struct Client *client, xcb_atom_t atom, uint32_t action) { // `state' holds what the atom wants to tell us about what to do enum WindowState state = WS_NORMAL; @@ -2219,8 +2225,7 @@ manage_client_maybe_reposition(xcb_window_t window, bool set_position) { client->y = p.y - client->height / 2; dpy_update_window_position(client); } - client->monitor = find_monitor(client); - wm_fit_client(client); + wm_update_client_monitor(client); clients_map_add(wm.clients, client); if (client->state == WS_NORMAL) { dpy_draw_unfocused_borders(client); @@ -2321,6 +2326,64 @@ wm_destroy() { } void +wm_reconfigure(uint16_t inner_border_width, + uint16_t outer_border_width, + uint16_t magnet_border_width, + int16_t offset_x, + int16_t offset_y, + uint16_t offset_width, + uint16_t offset_height, + uint32_t focused, + uint32_t unfocused, + uint32_t unkillable, + uint32_t empty, + uint32_t outer) { + cfg.inner_border_width = inner_border_width; + cfg.outer_border_width = outer_border_width; + cfg.magnet_border_width = magnet_border_width; + cfg.offset_x = offset_x; + cfg.offset_width = offset_width; + cfg.offset_height = offset_height; + cfg.colors.focused = focused; + cfg.colors.unfocused = unfocused; + cfg.colors.unkillable = unkillable; + cfg.colors.empty = empty; + cfg.colors.outer = outer; + + // Set new window border of ALL clients + for (uint32_t workspace = 0; workspace < wm.num_workspaces; workspace++) { + struct Client *client = wm.workspaces[workspace].ring; + if (client == NULL) { + continue; + } + + for (;;) { + dpy_set_window_border_width(client->id); + wm_fit_client(client); + + client = client->next; + if (client == wm.workspaces[workspace].ring) { + break; + } + } + } + + // Redraw borders of clients from current workspace only + struct Client *client = wm.workspaces[wm.cur_workspace].ring; + if (client == NULL) { + return; + } + + for (;;) { + dpy_draw_borders(client, wm.focus == client); + client = client->next; + if (client == wm.workspaces[wm.cur_workspace].ring) { + break; + } + } +} + +void wm_close(struct Client *client) { if (client->is_unkillable) { return; @@ -2764,13 +2827,7 @@ ev_configure_request(xcb_generic_event_t *generic_ev) { } wm_apply_size_hints(client); dpy_update_window_geometry(client); - - // Update the client monitor accordingly - struct Monitor *monitor = find_monitor(client); - if (monitor != NULL && client->monitor != monitor) { - client->monitor = monitor; - } - wm_fit_client(client); + wm_update_client_monitor(client); // TODO: do we need this? // dpy_draw_borders(client, wm.focus->id == client->id); @@ -2910,7 +2967,6 @@ ev_unmap_notify(xcb_generic_event_t *generic_ev) { struct Client *client = wm_find_client(ev->window); if (client == NULL || wm.workspaces[wm.cur_workspace].ring == NULL - || wm.workspaces[wm.cur_workspace].ring->id == ev->window || client->state == WS_ICONIFIED) { /* * For unknown clients, clients not in our current workspace, @@ -2921,15 +2977,18 @@ ev_unmap_notify(xcb_generic_event_t *generic_ev) { } bool should_ignore = true; - struct Client *ring_ptr = wm.workspaces[wm.cur_workspace].ring->next; - while (ring_ptr != wm.workspaces[wm.cur_workspace].ring) { - if (ring_ptr->id == ev->window) { + 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 should_ignore = false; break; } + ring_client = ring_client->next; + if (ring_client == wm.workspaces[wm.cur_workspace].ring) { + break; + } } - if (should_ignore) { return; } |