| 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; |