From: Marco Peereboom Date: Wed, 14 Jan 2009 22:21:52 +0000 (+0000) Subject: center floaters X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=4f26b7c5ca04f70c9091d7f714ac6ae8602b2273;p=spectrwm.git center floaters --- diff --git a/scrotwm.c b/scrotwm.c index b8dca30..5890eab 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -140,6 +140,7 @@ struct ws_win { int height; int floating; int transient; + XWindowAttributes wa; }; TAILQ_HEAD(ws_win_list, ws_win); @@ -540,8 +541,13 @@ stack(void) win->height = wc.height = h; mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth; } else { - win->x = wc.x = width / 2; - win->y = wc.y = height / 2; + /* make sure we don't clobber the screen */ + if (win->wa.width > width) + win->wa.width = width; + if (win->wa.height > height) + win->wa.width = height; + win->x = wc.x = (width - win->wa.width) / 2; + win->y = wc.y = (height - win->wa.height) / 2; mask = CWX | CWY | CWBorderWidth; } XConfigureWindow(display, win->id, mask, &wc); @@ -764,6 +770,7 @@ configurerequest(XEvent *e) DNPRINTF(SWM_D_MISC, "configurerequest: win %u transient %u\n", (unsigned)win->id, win->transient); } + XGetWindowAttributes(display, win->id, &win->wa); #if 0 XClassHint ch = { 0 }; if(XGetClassHint(display, win->id, &ch)) {