xaizek / euclid-wm (License: BSD 3-Clause) (since 2018-12-07)
A minimalist, tiling window manager for X11 that seeks to allow easy management of numerous windows entirely from the keyboard.
Commit d306f0119b133ceb9ee8a74153c2bddd6743eaf0

Try to pass focus back on closing windows
That is to window that was in focus when the one being closed
appeared. This leads to a more convenient workflow when new window
gets closed quite fast (e.g. when it's an input request).
Author: xaizek
Author date (UTC): 2016-09-27 11:25
Committer name: xaizek
Committer date (UTC): 2016-09-27 11:25
Parent(s): b6b0319166f2f10861fa9e17816436d0e8ba3a76
Signing key: 99DC5E4DB05F6BE2
Tree: 4659524b4222ed360cc1cd193e6c370280a8bd33
File Lines added Lines deleted
euclid-wm.c 21 2
File euclid-wm.c changed (mode: 100644) (index 0c756ed..66cb79c)
... ... struct win {
173 173 bool last_only_chld; //last time this window was mapped, was it in its own track? bool last_only_chld; //last time this window was mapped, was it in its own track?
174 174 int last_tpos; // we will store the last track and cont coords for the CENTER of the window here to allow semi-persistence int last_tpos; // we will store the last track and cont coords for the CENTER of the window here to allow semi-persistence
175 175 int last_cpos; int last_cpos;
176 struct cont *prev_focus; // container of previously focused window (needs validity check before use)
176 177 }; };
177 178
178 179 struct stack_item { //items in the stack are doubly linked per view struct stack_item { //items in the stack are doubly linked per view
 
... ... void addscreen(short h, short w, short x, short y, short n) {
758 759 XSync(dpy,False); XSync(dpy,False);
759 760 } }
760 761
762 //checks whether cont is part of the specified view
763 bool view_contains_win(struct view *v, struct cont *cont) {
764 for (struct track *t = v->ft; t != NULL; t = t->next) {
765 for (struct cont *c = t->c; c != NULL; c = c->next) {
766 if (c == cont) {
767 return true;
768 };
769 };
770 };
771 return false;
772 }
773
761 774 void remove_cont(struct cont *c) { void remove_cont(struct cont *c) {
762 775 struct win *w = c->win; struct win *w = c->win;
763 //reset focus if necessary
764 if (c->prev != NULL) {
776 //reset focus if necessary (prefer previously focused container if it's in the same view)
777 if (w->prev_focus != NULL && view_contains_win(c->track->view, w->prev_focus)) {
778 c->track->view->mfocus = w->prev_focus;
779 } else if (c->prev != NULL) {
765 780 c->track->view->mfocus = c->prev; c->track->view->mfocus = c->prev;
766 781 } else if (c->next != NULL) { } else if (c->next != NULL) {
767 782 c->track->view->mfocus = c->next; c->track->view->mfocus = c->next;
 
... ... struct win * add_win(Window id) {
888 903 p->last_cpos = 0; p->last_cpos = 0;
889 904 p->last_only_chld = false; p->last_only_chld = false;
890 905 p->cont = NULL; p->cont = NULL;
906 p->prev_focus = NULL;
891 907 return p; return p;
892 908 } }
893 909
 
... ... int event_loop() {
2815 2831
2816 2832 if (w == NULL) { //window was unknown, add it if (w == NULL) { //window was unknown, add it
2817 2833 w = add_win(ev.xmap.window); w = add_win(ev.xmap.window);
2834 w->prev_focus = cs->v->mfocus;
2818 2835 //need to get the win struct to pass to //need to get the win struct to pass to
2819 2836 //add_client_to_view; //add_client_to_view;
2820 2837 } else { //window is known } else { //window is known
2838 //reset pointer to previously focused container on window move
2839 w->prev_focus = NULL;
2821 2840 //remove from where it previously was, unless where it previously was is already on a screen (Which shouldn't happen, since then it would already have been mapped) //remove from where it previously was, unless where it previously was is already on a screen (Which shouldn't happen, since then it would already have been mapped)
2822 2841 if (w->cont) { //it is in a layout somewhere if (w->cont) { //it is in a layout somewhere
2823 2842 struct cont *c = w->cont; struct cont *c = w->cont;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/euclid-wm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/euclid-wm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master