mirror of
https://codeberg.org/nsxiv/nsxiv
synced 2024-11-15 12:13:10 +00:00
Added a key-mapping for toggle anti-aliasing
This commit is contained in:
parent
2bedd22314
commit
7834dee6e7
@ -45,3 +45,4 @@ Use the following keys to control sxiv:
|
|||||||
<,> Rotate image (counter-)clockwise by 90 degrees
|
<,> Rotate image (counter-)clockwise by 90 degrees
|
||||||
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
|
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
|
||||||
window manager)
|
window manager)
|
||||||
|
a Toggle anti-aliasing
|
||||||
|
15
image.c
15
image.c
@ -33,8 +33,10 @@ void img_init(img_t *img, win_t *win) {
|
|||||||
zoom_min = zoom_levels[0] / 100.0;
|
zoom_min = zoom_levels[0] / 100.0;
|
||||||
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
|
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
|
||||||
|
|
||||||
if (img)
|
if (img) {
|
||||||
img->zoom = 1.0;
|
img->zoom = 1.0;
|
||||||
|
img->aa = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (win) {
|
if (win) {
|
||||||
imlib_context_set_display(win->env.dpy);
|
imlib_context_set_display(win->env.dpy);
|
||||||
@ -63,6 +65,7 @@ int img_load(img_t *img, const char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
imlib_context_set_image(im);
|
imlib_context_set_image(im);
|
||||||
|
imlib_context_set_anti_alias(img->aa);
|
||||||
|
|
||||||
img->re = 0;
|
img->re = 0;
|
||||||
img->checkpan = 0;
|
img->checkpan = 0;
|
||||||
@ -272,3 +275,13 @@ int img_rotate_left(img_t *img, win_t *win) {
|
|||||||
int img_rotate_right(img_t *img, win_t *win) {
|
int img_rotate_right(img_t *img, win_t *win) {
|
||||||
return img_rotate(img, win, 1);
|
return img_rotate(img, win, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int img_toggle_antialias(img_t *img) {
|
||||||
|
if (!img)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
img->aa ^= 1;
|
||||||
|
imlib_context_set_anti_alias(img->aa);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
3
image.h
3
image.h
@ -39,6 +39,7 @@ typedef struct img_s {
|
|||||||
unsigned char re;
|
unsigned char re;
|
||||||
unsigned char checkpan;
|
unsigned char checkpan;
|
||||||
unsigned char zoomed;
|
unsigned char zoomed;
|
||||||
|
unsigned char aa;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int w;
|
int w;
|
||||||
@ -59,4 +60,6 @@ int img_pan(img_t*, win_t*, pandir_t);
|
|||||||
int img_rotate_left(img_t*, win_t*);
|
int img_rotate_left(img_t*, win_t*);
|
||||||
int img_rotate_right(img_t*, win_t*);
|
int img_rotate_right(img_t*, win_t*);
|
||||||
|
|
||||||
|
int img_toggle_antialias(img_t*);
|
||||||
|
|
||||||
#endif /* IMAGE_H */
|
#endif /* IMAGE_H */
|
||||||
|
7
main.c
7
main.c
@ -227,10 +227,15 @@ void on_keypress(XEvent *ev) {
|
|||||||
changed = img_rotate_right(&img, &win);
|
changed = img_rotate_right(&img, &win);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Control window */
|
/* control window */
|
||||||
case 'f':
|
case 'f':
|
||||||
win_toggle_fullscreen(&win);
|
win_toggle_fullscreen(&win);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* miscellaneous */
|
||||||
|
case 'a':
|
||||||
|
changed = img_toggle_antialias(&img);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user