From 229830ad188fc520da56bfa8a3b8e0da3744c799 Mon Sep 17 00:00:00 2001 From: Bert Date: Sun, 30 Jan 2011 22:00:58 +0100 Subject: Replace -w with well-known geometry option --- window.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 82d8396..2b3e266 100644 --- a/window.c +++ b/window.c @@ -35,6 +35,7 @@ void win_open(win_t *win) { win_env_t *e; XClassHint *classhint; XColor bgcol; + int gmask; if (!win) return; @@ -58,10 +59,25 @@ void win_open(win_t *win) { win->pm = 0; win->fullscreen = 0; - win->w = MIN(options->winw, e->scrw); - win->h = MIN(options->winh, e->scrh); - win->x = (e->scrw - win->w) / 2; - win->y = (e->scrh - win->h) / 2; + + /* determine window offsets, width & height */ + if (!options->geometry) + gmask = 0; + else + gmask = XParseGeometry(options->geometry, &win->x, &win->y, + &win->w, &win->h); + if (!(gmask & WidthValue)) + win->w = WIN_WIDTH; + if (win->w > e->scrw) + win->w = e->scrw; + if (!(gmask & HeightValue)) + win->h = WIN_HEIGHT; + if (win->h > e->scrh) + win->h = e->scrh; + if (!(gmask & XValue)) + win->x = (e->scrw - win->w) / 2; + if (!(gmask & YValue)) + win->y = (e->scrh - win->h) / 2; win->xwin = XCreateWindow(e->dpy, RootWindow(e->dpy, e->scr), win->x, win->y, win->w, win->h, 0, -- cgit v1.2.3-54-g00ecf