summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-01-09 12:34:26 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-01-09 12:34:26 +0100
commit4956bba42e65739a28e14d25cd05ee4601f67ca1 (patch)
tree90613df283e3b486351d0d8ba47728f46d3edbc1 /src
parent0c7a0b5379d6cfbd48df3ee568b79c6b988eec27 (diff)
parente68884314c563cd156d22c6cd1161e3c14ed8783 (diff)
Merge branch 'add-windowid-option' of https://github.com/codehearts/feh into codehearts-add-windowid-option
Diffstat (limited to 'src')
-rw-r--r--src/help.raw1
-rw-r--r--src/options.c4
-rw-r--r--src/options.h1
-rw-r--r--src/winwidget.c31
4 files changed, 32 insertions, 5 deletions
diff --git a/src/help.raw b/src/help.raw
index e0fb62a..2369c8d 100644
--- a/src/help.raw
+++ b/src/help.raw
@@ -100,6 +100,7 @@ OPTIONS
--scroll-step COUNT scroll COUNT pixels when movement key is pressed
--cache-size NUM imlib cache size in mebibytes (0 .. 2048)
--auto-reload automatically reload shown image if file was changed
+ --windowid Draw to an existing X11 window by its ID
MONTAGE MODE OPTIONS
-X, --ignore-aspect Set thumbnail to specified width/height without
diff --git a/src/options.c b/src/options.c
index 04f02c5..65e5a10 100644
--- a/src/options.c
+++ b/src/options.c
@@ -433,6 +433,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
#endif
{"class" , 1, 0, 249},
{"no-conversion-cache", 0, 0, 250},
+ {"windowid", 1, 0, 251},
{0, 0, 0, 0}
};
int optch = 0, cmdx = 0;
@@ -833,6 +834,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
case 250:
opt.use_conversion_cache = 0;
break;
+ case 251:
+ opt.x11_windowid = atoi(optarg);
+ break;
default:
break;
}
diff --git a/src/options.h b/src/options.h
index 4906004..5270f38 100644
--- a/src/options.h
+++ b/src/options.h
@@ -130,6 +130,7 @@ struct __fehoptions {
unsigned char adjust_reload;
int xinerama_index;
char *x11_class;
+ unsigned int *x11_windowid;
/* signed in case someone wants to invert scrolling real quick */
int scroll_step;
diff --git a/src/winwidget.c b/src/winwidget.c
index 119c3af..37031ec 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -144,6 +144,7 @@ winwidget winwidget_create_from_file(gib_list * list, char type)
void winwidget_create_window(winwidget ret, int w, int h)
{
+ XWindowAttributes window_attr;
XSetWindowAttributes attr;
XEvent ev;
XClassHint *xch;
@@ -250,11 +251,31 @@ void winwidget_create_window(winwidget ret, int w, int h)
}
}
- ret->win =
- XCreateWindow(disp, DefaultRootWindow(disp), x, y, w, h, 0,
- depth, InputOutput, vis,
- CWOverrideRedirect | CWSaveUnder | CWBackingStore
- | CWColormap | CWBackPixel | CWBorderPixel | CWEventMask, &attr);
+ if (opt.x11_windowid == 0) {
+ ret->win =
+ XCreateWindow(disp, DefaultRootWindow(disp), x, y, w, h, 0,
+ depth, InputOutput, vis,
+ CWOverrideRedirect | CWSaveUnder | CWBackingStore
+ | CWColormap | CWBackPixel | CWBorderPixel | CWEventMask,
+ &attr);
+ } else {
+ /* x11_windowid is a pointer to the window */
+ ret->win = (Window) opt.x11_windowid;
+
+ /* set our attributes on the window */
+ XChangeWindowAttributes(disp, ret->win,
+ CWOverrideRedirect | CWSaveUnder | CWBackingStore
+ | CWColormap | CWBackPixel | CWBorderPixel
+ | CWEventMask, &attr);
+
+ /* determine the size and visibility of the window */
+ XGetWindowAttributes(disp, ret->win, &window_attr);
+ ret->visible = (window_attr.map_state == IsViewable);
+ ret->x = window_attr.x;
+ ret->y = window_attr.y;
+ ret->w = window_attr.width;
+ ret->h = window_attr.height;
+ }
if (mwmhints.flags) {
XChangeProperty(disp, ret->win, prop, prop, 32,