Mercurial > gbwm
comparison gbwm.c @ 14:9a4656899644 default tip
add backward window cycling with Win+Shift+Tab
author | Atarwn Gard <a@qwa.su> |
---|---|
date | Tue, 14 Oct 2025 18:20:13 +0500 |
parents | 7d783901ff7d |
children |
comparison
equal
deleted
inserted
replaced
13:7d783901ff7d | 14:9a4656899644 |
---|---|
70 static void process_overlay_input(void); | 70 static void process_overlay_input(void); |
71 static void draw_overlay(void); | 71 static void draw_overlay(void); |
72 static void hide_overlay(void); | 72 static void hide_overlay(void); |
73 static void quit(const Arg *arg); | 73 static void quit(const Arg *arg); |
74 static void cycle_focus(const Arg *arg); | 74 static void cycle_focus(const Arg *arg); |
75 static void cycle_focus_backward(const Arg *arg); | |
75 static void grabkeys(void); | 76 static void grabkeys(void); |
76 static void setfullscreen(Client *c, int fullscreen); | 77 static void setfullscreen(Client *c, int fullscreen); |
77 static int sendevent(Client *c, Atom proto); | 78 static int sendevent(Client *c, Atom proto); |
78 static void updateborder(Client *c); | 79 static void updateborder(Client *c); |
79 static void find_next_free_cell(int *out_r, int *out_c); | 80 static void find_next_free_cell(int *out_r, int *out_c); |
701 if (!next) next = workspaces[current_ws]; | 702 if (!next) next = workspaces[current_ws]; |
702 | 703 |
703 focus(next, 1); | 704 focus(next, 1); |
704 } | 705 } |
705 | 706 |
707 static void cycle_focus_backward(const Arg *arg) { | |
708 if (!workspaces[current_ws]) return; | |
709 | |
710 if (!focused) { | |
711 // If there is no focus, focus on the last window | |
712 Client *last = workspaces[current_ws]; | |
713 while (last && last->next) | |
714 last = last->next; | |
715 focus(last, 1); | |
716 return; | |
717 } | |
718 | |
719 // Find the previous window | |
720 Client *prev = NULL; | |
721 for (Client *c = workspaces[current_ws]; c; c = c->next) { | |
722 if (c->next == focused) { | |
723 prev = c; | |
724 break; | |
725 } | |
726 } | |
727 | |
728 // If focused is the first, then prev = the last | |
729 if (!prev) { | |
730 prev = workspaces[current_ws]; | |
731 while (prev && prev->next) | |
732 prev = prev->next; | |
733 } | |
734 | |
735 focus(prev, 1); | |
736 } | |
737 | |
706 static void grabkeys(void) { | 738 static void grabkeys(void) { |
707 XUngrabKey(dpy, AnyKey, AnyModifier, root); | 739 XUngrabKey(dpy, AnyKey, AnyModifier, root); |
708 for (unsigned int i = 0; i < sizeof(keys) / sizeof(Key); i++) { | 740 for (unsigned int i = 0; i < sizeof(keys) / sizeof(Key); i++) { |
709 KeyCode code = XKeysymToKeycode(dpy, keys[i].keysym); | 741 KeyCode code = XKeysymToKeycode(dpy, keys[i].keysym); |
710 if (code) { | 742 if (code) { |