diff options
Diffstat (limited to 'schewm.c')
-rw-r--r-- | schewm.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -1934,6 +1934,40 @@ wm_destroy() { dpy_destroy(); } +void +wm_raise_and_center_cursor(struct Client *client) { + dpy_raise_window(client->id); + dpy_center_cursor_client(client); +} + +void +wm_focus_other(bool is_next) { + struct Client *focused = wm.focus; + if (focused == NULL) { + // No current focus, pick first client from the ring + focused = wm.workspaces[wm.cur_workspace].ring; + } else { + // We have focus, pick next/prev + focused = is_next ? focused->next : focused->prev; + } + if (focused == NULL) { + return; + } + + wm_raise_and_center_cursor(focused); + wm_set_focus(focused); +} + +void +wm_focus_prev() { + wm_focus_other(false); +} + +void +wm_focus_next() { + wm_focus_other(true); +} + static uint8_t ev_type(const xcb_generic_event_t *ev) { return ev->response_type & ~0x80; |