summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-30 22:00:58 +0100
committerBert <ber.t@gmx.com>2011-01-30 22:00:58 +0100
commit229830ad188fc520da56bfa8a3b8e0da3744c799 (patch)
tree172092091b6486bb592a2034724c4f7d5cf85d6c /window.c
parentc937570bbe61985f632db2b9285232453a8b8ee5 (diff)
downloadnsxiv-229830ad188fc520da56bfa8a3b8e0da3744c799.tar.zst
Replace -w with well-known geometry option
Diffstat (limited to 'window.c')
-rw-r--r--window.c24
1 files changed, 20 insertions, 4 deletions
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,