};
void focus(struct swm_region *, union arg *);
-void focus_magic(struct ws_win *, int);
-#define SWM_F_GENERIC (0)
-#define SWM_F_TRANSIENT (1)
+void focus_magic(struct ws_win *);
+
/* quirks */
struct quirk {
char *class;
if (win->java == 0)
XSetInputFocus(display, win->id,
RevertToParent, CurrentTime);
+ XMapRaised(display, win->id);
grabbuttons(win, 1);
XSetWindowBorder(display, win->id,
win->ws->r->s->c[SWM_S_COLOR_FOCUS].color);
if (winfocus == winlostfocus || winfocus == NULL)
return;
- focus_magic(winfocus, SWM_F_GENERIC);
+ focus_magic(winfocus);
}
void
if (winfocus->iconic == 0)
break;
- focus_magic(winfocus, SWM_F_GENERIC);
+ focus_magic(winfocus);
return;
}
if (head == NULL)
head = TAILQ_LAST(wl, ws_win_list);
winfocus = head;
- for (;;) {
- if (winfocus == NULL)
- break;
- if (!winfocus->iconic)
- break;
- winfocus = TAILQ_PREV(winfocus, ws_win_list, entry);
- if (winfocus == NULL)
- winfocus = TAILQ_LAST(wl, ws_win_list);
- if (winfocus == head) {
- winfocus = NULL;
- break;
- }
+ if (WINID(winfocus) == cur_focus->transient) {
+ head = TAILQ_PREV(winfocus, ws_win_list, entry);
+ if (head == NULL)
+ head = TAILQ_LAST(wl, ws_win_list);
+ winfocus = head;
}
break;
if (head == NULL)
head = TAILQ_FIRST(wl);
winfocus = head;
- for (;;) {
- if (winfocus == NULL)
- break;
- if (!winfocus->iconic)
- break;
- winfocus = TAILQ_NEXT(winfocus, entry);
- if (winfocus == NULL)
- winfocus = TAILQ_FIRST(wl);
- if (winfocus == head) {
- winfocus = NULL;
- break;
- }
- }
break;
case SWM_ARG_ID_FOCUSMAIN:
if (winfocus == winlostfocus || winfocus == NULL)
return;
- focus_magic(winfocus, SWM_F_GENERIC);
+ focus_magic(winfocus);
}
void
if (parent)
XMapRaised(display, parent->id);
stack_floater(wintrans, ws->r);
- focus_magic(wintrans, SWM_F_TRANSIENT);
+ focus_magic(wintrans);
}
}
DNPRINTF(SWM_D_MISC, "manage previously unmanaged window "
"%lu\n", win->id);
TAILQ_REMOVE(&win->ws->unmanagedlist, win, entry);
- TAILQ_INSERT_TAIL(&win->ws->winlist, win, entry);
if (win->transient)
set_child_transient(win);
+ if (trans && (ww = find_window(trans)))
+ TAILQ_INSERT_AFTER(&win->ws->winlist, ww, win, entry);
+ else
+ TAILQ_INSERT_TAIL(&win->ws->winlist, win, entry);
ewmh_update_actions(win);
return (win);
}
win->id = id;
win->ws = ws;
win->s = r->s; /* this never changes */
- TAILQ_INSERT_TAIL(&ws->winlist, win, entry);
+ if (trans && (ww = find_window(trans)))
+ TAILQ_INSERT_AFTER(&ws->winlist, ww, win, entry);
+ else
+ TAILQ_INSERT_TAIL(&ws->winlist, win, entry);
win->g.w = win->wa.width;
win->g.h = win->wa.height;
/* focus on root just in case */
XSetInputFocus(display, PointerRoot, PointerRoot, CurrentTime);
- if (!win->floating)
- focus_prev(win);
+ focus_prev(win);
TAILQ_REMOVE(&win->ws->winlist, win, entry);
TAILQ_INSERT_TAIL(&win->ws->unmanagedlist, win, entry);
}
void
-focus_magic(struct ws_win *win, int do_trans)
+focus_magic(struct ws_win *win)
{
- DNPRINTF(SWM_D_FOCUS, "focus_magic: %lu %d\n", WINID(win), do_trans);
+ DNPRINTF(SWM_D_FOCUS, "focus_magic: %lu\n", WINID(win));
if (win == NULL)
return;
- if (do_trans == SWM_F_TRANSIENT && win->child_trans) {
+ if (win->child_trans) {
/* win = parent & has a transient so focus on that */
if (win->java) {
focus_win(win->child_trans);
if ((win = find_window(ev->window)) == NULL)
return;
- focus_magic(win, SWM_F_TRANSIENT);
+ focus_magic(win);
action = client_click;
for (i = 0; i < LENGTH(buttons); i++)
return;
}
- focus_magic(win, SWM_F_TRANSIENT);
+ focus_magic(win);
}
/* lets us use one switch statement for arbitrary mode/detail combinations */
/* make new win focused */
r = root_to_region(win->wa.root);
if (win->ws == r->ws)
- focus_magic(win, SWM_F_GENERIC);
+ focus_magic(win);
}
void