diff options
-rw-r--r-- | man/feh.pre | 12 | ||||
-rw-r--r-- | src/help.raw | 1 | ||||
-rw-r--r-- | src/options.c | 4 | ||||
-rw-r--r-- | src/options.h | 1 | ||||
-rw-r--r-- | src/winwidget.c | 31 |
5 files changed, 44 insertions, 5 deletions
diff --git a/man/feh.pre b/man/feh.pre index c55c924..79aa355 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -920,6 +920,18 @@ comes before Note that this option only has an effect when a sort mode is set using .Cm --sort . . +.It Cm --window-id Ar windowid +. +Draw to an existing X11 window by its ID +.Ar windowid . +This option is intended for use with software such as xcreensaver or +xsecurelock, which provide a window for other applications to draw into. +Unexpected things will happen if you specify a window belonging to software +which does not expect +.Nm +to draw into it or attempt to use options or keybindings which affect window +attributes, such as full-screen mode. +. .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..1846908 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 + --window-id 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 02c9b83..4744bb0 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}, + {"window-id", 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 = atol(optarg); + break; default: break; } diff --git a/src/options.h b/src/options.h index 4906004..7ca699b 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 long 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, |