Nicer fit window to image
This commit is contained in:
parent
cbf6aae721
commit
603e664f7c
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
all: sxiv
|
||||
|
||||
VERSION=git-20110204
|
||||
VERSION=git-20110206
|
||||
|
||||
CC?=gcc
|
||||
PREFIX?=/usr/local
|
||||
|
|
12
main.c
12
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 */
|
||||
|
|
13
window.c
13
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue