Commit e6888431 authored by Kate Hart's avatar Kate Hart
Browse files

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`
parent 5c59089f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -896,6 +896,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
+1 −0
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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;
		}
+1 −0
Original line number Diff line number Diff line
@@ -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;
+26 −5
Original line number Diff line number Diff line
@@ -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)
		}
	}

	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);
		                | 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,