X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=277096267b28920eaa4e2b64f8ea80bba54fbcb6;hb=52299284979f743d1f859adc8ce0af1e4df0a954;hp=a6aa81fc17e54f5f2e7d750d1d0c0c90e88e946f;hpb=840c2ac2b668265acfd06f73ac2863c3ea111bbe;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index a6aa81f..2770962 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -1508,6 +1508,10 @@ stack_floater(struct ws_win *win, struct swm_region *r) wc.y = (HEIGHT(r) - win->g.h) / 2; } + /* adjust for region */ + wc.x += r->g.x; + wc.y += r->g.y; + DNPRINTF(SWM_D_STACK, "stack_floater: win %lu x %d y %d w %d h %d\n", win->id, wc.x, wc.y, wc.width, wc.height); @@ -1811,7 +1815,7 @@ max_stack(struct workspace *ws, struct swm_geometry *g) { XWindowChanges wc; struct swm_geometry gg = *g; - struct ws_win *win, *winfocus; + struct ws_win *win; unsigned int mask; int winno; @@ -1823,19 +1827,12 @@ max_stack(struct workspace *ws, struct swm_geometry *g) if (winno == 0 && count_win(ws, 1) == 0) return; - if (ws->focus == NULL) - ws->focus = TAILQ_FIRST(&ws->winlist); - winfocus = ws->focus; - TAILQ_FOREACH(win, &ws->winlist, entry) { if (win->transient != 0 || win->floating != 0) { if (win == ws->focus) { - /* XXX maximize? */ stack_floater(win, ws->r); XMapRaised(display, win->id); - } else { - /* XXX this sucks */ - XUnmapWindow(display, win->id); + focus_win(win); /* override */ } } else { bzero(&wc, sizeof wc); @@ -1846,16 +1843,8 @@ max_stack(struct workspace *ws, struct swm_geometry *g) win->g.h = wc.height = gg.h; mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth; XConfigureWindow(display, win->id, mask, &wc); - - if (win == ws->focus) { - XMapRaised(display, win->id); - } else - XUnmapWindow(display, win->id); } } - - if (winfocus) - focus_win(winfocus); /* has to be done outside of the loop */ } void @@ -3201,7 +3190,7 @@ manage_window(Window id) Window trans; struct workspace *ws; struct ws_win *win, *ww; - int format, i, ws_idx, n; + int format, i, ws_idx, n, border_me = 0; unsigned long nitems, bytes; Atom ws_idx_atom = 0, type; Atom *prot = NULL, *pp; @@ -3257,14 +3246,19 @@ manage_window(Window id) ws = r->ws; /* this should launch transients in the same ws as parent */ /* XXX doesn't work for intel xrandr */ - if (id && trans) { - if ((ww = find_window(trans)) != NULL) { - ws = ww->ws; - r = ws->r; - } - } + if (id && trans) + if ((ww = find_window(trans)) != NULL) + if (ws->r) { + ws = ww->ws; + r = ww->ws->r; + border_me = 1; + } } + /* shouldn't happen but does... */ + if (ws->r == NULL) + ws->r = r; /* use found r since it isn't filled in */ + /* set up the window layout */ win->id = id; win->ws = ws; @@ -3314,9 +3308,7 @@ manage_window(Window id) win->g.x = wc.x = WIDTH(win->ws->r) - win->g.w - 2; mask |= CWX; } - wc.border_width = 1; - mask |= CWBorderWidth; - XConfigureWindow(display, win->id, mask, &wc); + border_me = 1; } /* Reset font sizes (the bruteforce way; no default keybinding). */ @@ -3327,13 +3319,21 @@ manage_window(Window id) fake_keypress(win, XK_KP_Add, ShiftMask); } + /* border me */ + if (border_me) { + bzero(&wc, sizeof wc); + wc.border_width = 1; + mask = CWBorderWidth; + XConfigureWindow(display, win->id, mask, &wc); + } + XSelectInput(display, id, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask); set_win_state(win, NormalState); /* floaters need to be mapped if they are in the current workspace */ - if (win->floating && (ws->idx == r->ws->idx)) + if ((win->floating || win->transient) && (ws->idx == r->ws->idx)) XMapRaised(display, win->id); return (win); @@ -3542,7 +3542,7 @@ maprequest(XEvent *e) /* make new win focused */ win = find_window(ev->window); r = root_to_region(win->wa.root); - if (win->ws == r->ws) /* XXX this probably breaks multi screen */ + if (win->ws == r->ws) focus_win(win); }