nsxiv7834dee
Added a key-mapping for toggle anti-aliasing
+28 −2
5 files changed
| @@ -45,3 +45,4 @@ Use the following keys to control sxiv: | |||
| 45 | 45 | <,> Rotate image (counter-)clockwise by 90 degrees | |
| 46 | 46 | f Toggle fullscreen mode (requires an EWMH/NetWM compliant | |
| 47 | 47 | window manager) | |
| 48 | + | a Toggle anti-aliasing | |
| @@ -33,8 +33,10 @@ void img_init(img_t *img, win_t *win) { | |||
| 33 | 33 | zoom_min = zoom_levels[0] / 100.0; | |
| 34 | 34 | zoom_max = zoom_levels[zl_cnt - 1] / 100.0; | |
| 35 | 35 | ||
| 36 | − | if (img) | |
| 36 | + | if (img) { | |
| 37 | 37 | img->zoom = 1.0; | |
| 38 | + | img->aa = 1; | |
| 39 | + | } | |
| 38 | 40 | ||
| 39 | 41 | if (win) { | |
| 40 | 42 | imlib_context_set_display(win->env.dpy); | |
| @@ -63,6 +65,7 @@ int img_load(img_t *img, const char *filename) { | |||
| 63 | 65 | } | |
| 64 | 66 | ||
| 65 | 67 | imlib_context_set_image(im); | |
| 68 | + | imlib_context_set_anti_alias(img->aa); | |
| 66 | 69 | ||
| 67 | 70 | img->re = 0; | |
| 68 | 71 | img->checkpan = 0; | |
| @@ -272,3 +275,13 @@ int img_rotate_left(img_t *img, win_t *win) { | |||
| 272 | 275 | int img_rotate_right(img_t *img, win_t *win) { | |
| 273 | 276 | return img_rotate(img, win, 1); | |
| 274 | 277 | } | |
| 278 | + | ||
| 279 | + | int img_toggle_antialias(img_t *img) { | |
| 280 | + | if (!img) | |
| 281 | + | return 0; | |
| 282 | + | ||
| 283 | + | img->aa ^= 1; | |
| 284 | + | imlib_context_set_anti_alias(img->aa); | |
| 285 | + | ||
| 286 | + | return 1; | |
| 287 | + | } | |
| @@ -39,6 +39,7 @@ typedef struct img_s { | |||
| 39 | 39 | unsigned char re; | |
| 40 | 40 | unsigned char checkpan; | |
| 41 | 41 | unsigned char zoomed; | |
| 42 | + | unsigned char aa; | |
| 42 | 43 | int x; | |
| 43 | 44 | int y; | |
| 44 | 45 | int w; | |
| @@ -59,4 +60,6 @@ int img_pan(img_t*, win_t*, pandir_t); | |||
| 59 | 60 | int img_rotate_left(img_t*, win_t*); | |
| 60 | 61 | int img_rotate_right(img_t*, win_t*); | |
| 61 | 62 | ||
| 63 | + | int img_toggle_antialias(img_t*); | |
| 64 | + | ||
| 62 | 65 | #endif /* IMAGE_H */ | |
| @@ -227,10 +227,15 @@ void on_keypress(XEvent *ev) { | |||
| 227 | 227 | changed = img_rotate_right(&img, &win); | |
| 228 | 228 | break; | |
| 229 | 229 | ||
| 230 | − | /* Control window */ | |
| 230 | + | /* control window */ | |
| 231 | 231 | case 'f': | |
| 232 | 232 | win_toggle_fullscreen(&win); | |
| 233 | 233 | break; | |
| 234 | + | ||
| 235 | + | /* miscellaneous */ | |
| 236 | + | case 'a': | |
| 237 | + | changed = img_toggle_antialias(&img); | |
| 238 | + | break; | |
| 234 | 239 | } | |
| 235 | 240 | ||
| 236 | 241 | if (changed) { | |
| @@ -76,6 +76,10 @@ Rotate image clockwise by 90 degrees. | |||
| 76 | 76 | .TP | |
| 77 | 77 | .B f | |
| 78 | 78 | Toggle fullscreen mode. | |
| 79 | + | .SS Miscellaneous | |
| 80 | + | .TP | |
| 81 | + | .B a | |
| 82 | + | Toggle anti-aliasing. | |
| 79 | 83 | .SH AUTHORS | |
| 80 | 84 | .TP | |
| 81 | 85 | Bert Muennich <ber.t at gmx.com> | |