Nicer fit window to image
This commit is contained in:
parent
cbf6aae721
commit
603e664f7c
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
all: sxiv
|
all: sxiv
|
||||||
|
|
||||||
VERSION=git-20110204
|
VERSION=git-20110206
|
||||||
|
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
PREFIX?=/usr/local
|
PREFIX?=/usr/local
|
||||||
|
|
12
main.c
12
main.c
|
@ -222,6 +222,8 @@ unsigned char timeout;
|
||||||
int mox, moy;
|
int mox, moy;
|
||||||
|
|
||||||
void on_keypress(XKeyEvent *kev) {
|
void on_keypress(XKeyEvent *kev) {
|
||||||
|
int x, y;
|
||||||
|
unsigned int w, h;
|
||||||
char key;
|
char key;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
int changed;
|
int changed;
|
||||||
|
@ -330,8 +332,14 @@ void on_keypress(XKeyEvent *kev) {
|
||||||
/* render on next configurenotify */
|
/* render on next configurenotify */
|
||||||
break;
|
break;
|
||||||
case XK_W:
|
case XK_W:
|
||||||
if ((changed = win_resize(&win, img.w * img.zoom, img.h * img.zoom)))
|
x = win.x + img.x;
|
||||||
img.checkpan = 1;
|
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;
|
break;
|
||||||
|
|
||||||
/* miscellaneous */
|
/* miscellaneous */
|
||||||
|
|
13
window.c
13
window.c
|
@ -157,24 +157,23 @@ int win_configure(win_t *win, XConfigureEvent *c) {
|
||||||
return changed;
|
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)
|
if (!win)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
x = MAX(0, x);
|
||||||
|
y = MAX(0, y);
|
||||||
w = MIN(w, win->env.scrw - 2 * win->bw);
|
w = MIN(w, win->env.scrw - 2 * win->bw);
|
||||||
h = MIN(h, win->env.scrh - 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;
|
return 0;
|
||||||
|
|
||||||
|
win->x = x;
|
||||||
|
win->y = y;
|
||||||
win->w = w;
|
win->w = w;
|
||||||
win->h = h;
|
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)
|
if (options->fixed)
|
||||||
win_set_sizehints(win);
|
win_set_sizehints(win);
|
||||||
|
|
||||||
|
|
2
window.h
2
window.h
|
@ -57,7 +57,7 @@ void win_open(win_t*);
|
||||||
void win_close(win_t*);
|
void win_close(win_t*);
|
||||||
|
|
||||||
int win_configure(win_t*, XConfigureEvent*);
|
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*);
|
void win_toggle_fullscreen(win_t*);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue