Krolyxon
Commit c772d3c

Branches

Refs →

nsxivc772d3c

Use -e for X window embedding

Author
Bert Münnich
Date
2016-10-30 19:10 +0100
Committer
Bert Münnich · 2016-10-30 19:16 +0100
Parent
0b758e0
Commit
c772d3c3f3e9cc986e8e0c0242b4d7a8e8dab4c3

+13 −16

4 files changed

  1. M Makefile +1 −1
  2. M options.c +9 −9
  3. M window.c +3 −5
  4. M window.h +0 −1
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION := git-20161020
1+VERSION := git-20161030
22
33 PREFIX := /usr/local
44 MANPREFIX := $(PREFIX)/share/man
M options.c View
@@ -32,8 +32,8 @@ const options_t *options = (const options_t*) &_options;
3232
3333 void print_usage(void)
3434 {
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");
3737 }
3838
3939 void print_version(void)
@@ -71,7 +71,7 @@ void parse_options(int argc, char **argv)
7171 _options.thumb_mode = false;
7272 _options.clean_cache = false;
7373
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) {
7575 switch (opt) {
7676 case '?':
7777 print_usage();
@@ -85,6 +85,12 @@ void parse_options(int argc, char **argv)
8585 case 'c':
8686 _options.clean_cache = true;
8787 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;
8894 case 'f':
8995 _options.fullscreen = true;
9096 break;
@@ -139,12 +145,6 @@ void parse_options(int argc, char **argv)
139145 case 'v':
140146 print_version();
141147 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;
148148 case 'Z':
149149 _options.scalemode = SCALE_ZOOM;
150150 _options.zoom = 1.0;
M window.c View
@@ -133,7 +133,6 @@ void win_init(win_t *win)
133133 win->bar.l.buf = emalloc(win->bar.l.size);
134134 win->bar.r.buf = emalloc(win->bar.r.size);
135135 win->bar.h = options->hide_bar ? 0 : barheight;
136− win->embed = options->embed;
137136
138137 INIT_ATOM_(WM_DELETE_WINDOW);
139138 INIT_ATOM_(_NET_WM_NAME);
@@ -149,6 +148,7 @@ void win_init(win_t *win)
149148 void win_open(win_t *win)
150149 {
151150 int c, i, j, n;
151+ long parent;
152152 win_env_t *e;
153153 XClassHint classhint;
154154 unsigned long *icon_data;
@@ -160,6 +160,7 @@ void win_open(win_t *win)
160160 Bool fullscreen = options->fullscreen && fs_support;
161161
162162 e = &win->env;
163+ parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr);
163164
164165 sizehints.flags = PWinGravity;
165166 sizehints.win_gravity = NorthWestGravity;
@@ -198,10 +199,7 @@ void win_open(win_t *win)
198199 win->y = 0;
199200 }
200201
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,
205203 win->x, win->y, win->w, win->h, 0,
206204 e->depth, InputOutput, e->vis, 0, NULL);
207205 if (win->xwin == None)
M window.h View
@@ -71,7 +71,6 @@ typedef struct {
7171 unsigned int bw;
7272
7373 bool fullscreen;
74− long embed;
7574
7675 struct {
7776 int w;