nsxivc772d3c
Use -e for X window embedding
+13 −16
4 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION := git-20161020 | |
| 1 | + | VERSION := git-20161030 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX := /usr/local | |
| 4 | 4 | MANPREFIX := $(PREFIX)/share/man | |
| @@ -32,8 +32,8 @@ const options_t *options = (const options_t*) &_options; | |||
| 32 | 32 | ||
| 33 | 33 | void print_usage(void) | |
| 34 | 34 | { | |
| 35 | − | printf("usage: sxiv [-abcfhioqrtvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] " | |
| 36 | − | "[-N NAME] [-S DELAY] [-s MODE] [-z ZOOM] [-w WID] FILES...\n"); | |
| 35 | + | printf("usage: sxiv [-abcfhioqrtvZ] [-e WID] [-G GAMMA] [-g GEOMETRY] " | |
| 36 | + | "[-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n"); | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | void print_version(void) | |
| @@ -71,7 +71,7 @@ void parse_options(int argc, char **argv) | |||
| 71 | 71 | _options.thumb_mode = false; | |
| 72 | 72 | _options.clean_cache = false; | |
| 73 | 73 | ||
| 74 | − | while ((opt = getopt(argc, argv, "abcfG:g:hin:N:oqrS:s:tvw:Zz:")) != -1) { | |
| 74 | + | while ((opt = getopt(argc, argv, "abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) { | |
| 75 | 75 | switch (opt) { | |
| 76 | 76 | case '?': | |
| 77 | 77 | print_usage(); | |
| @@ -85,6 +85,12 @@ void parse_options(int argc, char **argv) | |||
| 85 | 85 | case 'c': | |
| 86 | 86 | _options.clean_cache = true; | |
| 87 | 87 | break; | |
| 88 | + | case 'e': | |
| 89 | + | n = strtol(optarg, &end, 0); | |
| 90 | + | if (*end != '\0') | |
| 91 | + | error(EXIT_FAILURE, 0, "Invalid argument for option -e: %s", optarg); | |
| 92 | + | _options.embed = n; | |
| 93 | + | break; | |
| 88 | 94 | case 'f': | |
| 89 | 95 | _options.fullscreen = true; | |
| 90 | 96 | break; | |
| @@ -139,12 +145,6 @@ void parse_options(int argc, char **argv) | |||
| 139 | 145 | case 'v': | |
| 140 | 146 | print_version(); | |
| 141 | 147 | exit(EXIT_SUCCESS); | |
| 142 | − | case 'w': | |
| 143 | − | n = strtol(optarg, &end, 0); | |
| 144 | − | if (*end != '\0') | |
| 145 | − | error(EXIT_FAILURE, 0, "Invalid argument for option -w: %s", optarg); | |
| 146 | − | _options.embed = n; | |
| 147 | − | break; | |
| 148 | 148 | case 'Z': | |
| 149 | 149 | _options.scalemode = SCALE_ZOOM; | |
| 150 | 150 | _options.zoom = 1.0; | |
| @@ -133,7 +133,6 @@ void win_init(win_t *win) | |||
| 133 | 133 | win->bar.l.buf = emalloc(win->bar.l.size); | |
| 134 | 134 | win->bar.r.buf = emalloc(win->bar.r.size); | |
| 135 | 135 | win->bar.h = options->hide_bar ? 0 : barheight; | |
| 136 | − | win->embed = options->embed; | |
| 137 | 136 | ||
| 138 | 137 | INIT_ATOM_(WM_DELETE_WINDOW); | |
| 139 | 138 | INIT_ATOM_(_NET_WM_NAME); | |
| @@ -149,6 +148,7 @@ void win_init(win_t *win) | |||
| 149 | 148 | void win_open(win_t *win) | |
| 150 | 149 | { | |
| 151 | 150 | int c, i, j, n; | |
| 151 | + | long parent; | |
| 152 | 152 | win_env_t *e; | |
| 153 | 153 | XClassHint classhint; | |
| 154 | 154 | unsigned long *icon_data; | |
| @@ -160,6 +160,7 @@ void win_open(win_t *win) | |||
| 160 | 160 | Bool fullscreen = options->fullscreen && fs_support; | |
| 161 | 161 | ||
| 162 | 162 | e = &win->env; | |
| 163 | + | parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); | |
| 163 | 164 | ||
| 164 | 165 | sizehints.flags = PWinGravity; | |
| 165 | 166 | sizehints.win_gravity = NorthWestGravity; | |
| @@ -198,10 +199,7 @@ void win_open(win_t *win) | |||
| 198 | 199 | win->y = 0; | |
| 199 | 200 | } | |
| 200 | 201 | ||
| 201 | − | if (!(win->embed)) { | |
| 202 | − | win->embed = RootWindow(e->dpy, e->scr); | |
| 203 | − | } | |
| 204 | − | win->xwin = XCreateWindow(e->dpy, win->embed, | |
| 202 | + | win->xwin = XCreateWindow(e->dpy, parent, | |
| 205 | 203 | win->x, win->y, win->w, win->h, 0, | |
| 206 | 204 | e->depth, InputOutput, e->vis, 0, NULL); | |
| 207 | 205 | if (win->xwin == None) | |
| @@ -71,7 +71,6 @@ typedef struct { | |||
| 71 | 71 | unsigned int bw; | |
| 72 | 72 | ||
| 73 | 73 | bool fullscreen; | |
| 74 | − | long embed; | |
| 75 | 74 | ||
| 76 | 75 | struct { | |
| 77 | 76 | int w; | |