summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/feh.pre5
-rw-r--r--src/help.raw1
-rw-r--r--src/options.c4
-rw-r--r--src/options.h1
-rw-r--r--src/winwidget.c31
5 files changed, 37 insertions, 5 deletions
diff --git a/man/feh.pre b/man/feh.pre
index c55c924..0d78390 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -920,6 +920,11 @@ comes before
Note that this option only has an effect when a sort mode is set using
.Cm --sort .
.
+.It Cm --windowid Ar windowid
+.
+Draw to an existing X11 window by its ID
+.Ar windowid .
+.
.It Cm --xinerama-index Ar screen
.
.Pq optional feature, $MAN_XINERAMA$ in this build
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,