nsxivf2ceac2
New option: -F, fixed/floating window
+20 −8
3 files changed
| @@ -29,7 +29,7 @@ options_t _options; | |||
| 29 | 29 | const options_t *options = (const options_t*) &_options; | |
| 30 | 30 | ||
| 31 | 31 | void print_usage() { | |
| 32 | − | printf("usage: sxiv [-dfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | |
| 32 | + | printf("usage: sxiv [-dFfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | |
| 33 | 33 | } | |
| 34 | 34 | ||
| 35 | 35 | void print_version() { | |
| @@ -45,12 +45,13 @@ void parse_options(int argc, char **argv) { | |||
| 45 | 45 | _options.zoom = 1.0; | |
| 46 | 46 | _options.aa = 1; | |
| 47 | 47 | ||
| 48 | + | _options.fixed = 0; | |
| 48 | 49 | _options.fullscreen = 0; | |
| 49 | 50 | _options.geometry = NULL; | |
| 50 | 51 | ||
| 51 | 52 | _options.quiet = 0; | |
| 52 | 53 | ||
| 53 | − | while ((opt = getopt(argc, argv, "dfg:hpqsvZz:")) != -1) { | |
| 54 | + | while ((opt = getopt(argc, argv, "dFfg:hpqsvZz:")) != -1) { | |
| 54 | 55 | switch (opt) { | |
| 55 | 56 | case '?': | |
| 56 | 57 | print_usage(); | |
| @@ -58,6 +59,9 @@ void parse_options(int argc, char **argv) { | |||
| 58 | 59 | case 'd': | |
| 59 | 60 | _options.scalemode = SCALE_DOWN; | |
| 60 | 61 | break; | |
| 62 | + | case 'F': | |
| 63 | + | _options.fixed = 1; | |
| 64 | + | break; | |
| 61 | 65 | case 'f': | |
| 62 | 66 | _options.fullscreen = 1; | |
| 63 | 67 | break; | |
| @@ -29,6 +29,7 @@ typedef struct options_s { | |||
| 29 | 29 | float zoom; | |
| 30 | 30 | unsigned char aa; | |
| 31 | 31 | ||
| 32 | + | unsigned char fixed; | |
| 32 | 33 | unsigned char fullscreen; | |
| 33 | 34 | char *geometry; | |
| 34 | 35 | ||
| @@ -33,7 +33,8 @@ static GC bgc; | |||
| 33 | 33 | ||
| 34 | 34 | void win_open(win_t *win) { | |
| 35 | 35 | win_env_t *e; | |
| 36 | − | XClassHint *classhint; | |
| 36 | + | XClassHint classhint; | |
| 37 | + | XSizeHints sizehints; | |
| 37 | 38 | XColor bgcol; | |
| 38 | 39 | int gmask; | |
| 39 | 40 | ||
| @@ -99,11 +100,17 @@ void win_open(win_t *win) { | |||
| 99 | 100 | ||
| 100 | 101 | win_set_title(win, "sxiv"); | |
| 101 | 102 | ||
| 102 | − | if ((classhint = XAllocClassHint())) { | |
| 103 | − | classhint->res_name = "sxiv"; | |
| 104 | − | classhint->res_class = "sxiv"; | |
| 105 | − | XSetClassHint(e->dpy, win->xwin, classhint); | |
| 106 | − | XFree(classhint); | |
| 103 | + | classhint.res_name = "sxiv"; | |
| 104 | + | classhint.res_class = "sxiv"; | |
| 105 | + | XSetClassHint(e->dpy, win->xwin, &classhint); | |
| 106 | + | ||
| 107 | + | if (options->fixed) { | |
| 108 | + | sizehints.flags = PMinSize | PMaxSize; | |
| 109 | + | sizehints.min_width = win->w; | |
| 110 | + | sizehints.max_width = win->w; | |
| 111 | + | sizehints.min_height = win->h; | |
| 112 | + | sizehints.max_height = win->h; | |
| 113 | + | XSetWMNormalHints(e->dpy, win->xwin, &sizehints); | |
| 107 | 114 | } | |
| 108 | 115 | ||
| 109 | 116 | XMapWindow(e->dpy, win->xwin); | |