aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--main.c12
-rw-r--r--window.c13
-rw-r--r--window.h2
4 files changed, 18 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 1f24280..ed8d343 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: sxiv
-VERSION=git-20110204
+VERSION=git-20110206
CC?=gcc
PREFIX?=/usr/local
diff --git a/main.c b/main.c
index 4ce19de..379b7bd 100644
--- a/main.c
+++ b/main.c
@@ -222,6 +222,8 @@ unsigned char timeout;
int mox, moy;
void on_keypress(XKeyEvent *kev) {
+ int x, y;
+ unsigned int w, h;
char key;
KeySym ksym;
int changed;
@@ -330,8 +332,14 @@ void on_keypress(XKeyEvent *kev) {
/* render on next configurenotify */
break;
case XK_W:
- if ((changed = win_resize(&win, img.w * img.zoom, img.h * img.zoom)))
- img.checkpan = 1;
+ x = win.x + img.x;
+ y = win.y + img.y;
+ w = img.w * img.zoom;
+ h = img.h * img.zoom;
+ if ((changed = win_moveresize(&win, x, y, w, h))) {
+ img.x = x - win.x;
+ img.y = y - win.y;
+ }
break;
/* miscellaneous */
diff --git a/window.c b/window.c
index 2c8ea68..23146cd 100644
--- a/window.c
+++ b/window.c
@@ -157,24 +157,23 @@ int win_configure(win_t *win, XConfigureEvent *c) {
return changed;
}
-int win_resize(win_t *win, unsigned int w, unsigned int h) {
+int win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
if (!win)
return 0;
+ x = MAX(0, x);
+ y = MAX(0, y);
w = MIN(w, win->env.scrw - 2 * win->bw);
h = MIN(h, win->env.scrh - 2 * win->bw);
- if (win->w == w && win->h == h)
+ if (win->x == x && win->y == y && win->w == w && win->h == h)
return 0;
+ win->x = x;
+ win->y = y;
win->w = w;
win->h = h;
- if (win->x + w + 2 * win->bw > win->env.scrw)
- win->x = win->env.scrw - w - 2 * win->bw;
- if (win->y + h + 2 * win->bw > win->env.scrh)
- win->y = win->env.scrh - h - 2 * win->bw;
-
if (options->fixed)
win_set_sizehints(win);
diff --git a/window.h b/window.h
index cc2598f..db91b18 100644
--- a/window.h
+++ b/window.h
@@ -57,7 +57,7 @@ void win_open(win_t*);
void win_close(win_t*);
int win_configure(win_t*, XConfigureEvent*);
-int win_resize(win_t*, unsigned int, unsigned int);
+int win_moveresize(win_t*, int, int, unsigned int, unsigned int);
void win_toggle_fullscreen(win_t*);