summaryrefslogtreecommitdiff
path: root/src/winwidget.c
diff options
context:
space:
mode:
authorKate Hart <codehearts@users.noreply.github.com>2020-07-24 00:41:12 -0700
committerKate Hart <codehearts@users.noreply.github.com>2020-07-24 00:41:12 -0700
commite68884314c563cd156d22c6cd1161e3c14ed8783 (patch)
tree0af8baf82843d9980bf5943ff798a0dbda2e4243 /src/winwidget.c
parent5c59089f12b7b07d46626ecdccf0cfcd4e875e26 (diff)
Add windowid option to draw to an existing window
This lets `feh` draw the background pixmap of an existing window, opening the door for use with tools like `xscreensaver` or `xsecurelock`
Diffstat (limited to 'src/winwidget.c')
-rw-r--r--src/winwidget.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/winwidget.c b/src/winwidget.c
index 6ff90ed..696f3db 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -143,6 +143,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;
@@ -249,11 +250,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,