Commit 5dfdc0bc authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Determine active Xinerama screen by pointer position

parent fc11253d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
git HEAD

    * Set correct window dimensions on any Xinerama screen, not just the
      first one (active screen is determined by current pointer location)

Wed, 13 Feb 2013 01:46:56 +0100  Daniel Friesel <derf+feh@finalrewind.org>

* Release v2.9
+23 −4
Original line number Diff line number Diff line
@@ -68,13 +68,32 @@ static char *feh_magick_load_image(char *filename);
void init_xinerama(void)
{
	if (opt.xinerama && XineramaIsActive(disp)) {
		int major, minor;
		int major, minor, px, py, i;

		/* discarded */
		Window dw;
		int di;
		unsigned int du;

		XineramaQueryVersion(disp, &major, &minor);
		xinerama_screens = XineramaQueryScreens(disp, &num_xinerama_screens);

		if (getenv("XINERAMA_SCREEN"))
			xinerama_screen = atoi(getenv("XINERAMA_SCREEN"));
		else
		else {
			xinerama_screen = 0;
		XineramaQueryVersion(disp, &major, &minor);
		xinerama_screens = XineramaQueryScreens(disp, &num_xinerama_screens);
			XQueryPointer(disp, root, &dw, &dw, &px, &py, &di, &di, &du);
			for (i = 0; i < num_xinerama_screens; i++) {
				if (XY_IN_RECT(px, py,
							xinerama_screens[i].x_org,
							xinerama_screens[i].y_org,
							xinerama_screens[i].width,
							xinerama_screens[i].height)) {
					xinerama_screen = i;
					break;
				}
			}
		}
	}
}
#endif				/* HAVE_LIBXINERAMA */
+11 −6
Original line number Diff line number Diff line
@@ -780,23 +780,28 @@ void winwidget_move(winwidget winwid, int x, int y)

void winwidget_resize(winwidget winwid, int w, int h)
{
	Window ignored_window;
	XWindowAttributes attributes;
	int tc_x, tc_y;
	int tc_x, tc_y, px, py;
	int scr_width = scr->width;
	int scr_height = scr->height;

	/* discarded */
	Window dw;
	int di, i;
	unsigned int du;

	XGetWindowAttributes(disp, winwid->win, &attributes);

#ifdef HAVE_LIBXINERAMA
	if (opt.xinerama && xinerama_screens) {
		int i;
		xinerama_screen = 0;
		XQueryPointer(disp, root, &dw, &dw, &px, &py, &di, &di, &du);
		for (i = 0; i < num_xinerama_screens; i++) {
			if (XY_IN_RECT(attributes.x, attributes.y,
			if (XY_IN_RECT(px, py,
						xinerama_screens[i].x_org,
						xinerama_screens[i].y_org,
						xinerama_screens[i].width, xinerama_screens[i].height)) {
						xinerama_screens[i].width,
						xinerama_screens[i].height)) {
				xinerama_screen = i;
				break;
			}
@@ -828,7 +833,7 @@ void winwidget_resize(winwidget winwid, int w, int h)
			XTranslateCoordinates(disp, winwid->win, attributes.root,
						-attributes.border_width -
						attributes.x,
						-attributes.border_width - attributes.y, &tc_x, &tc_y, &ignored_window);
						-attributes.border_width - attributes.y, &tc_x, &tc_y, &dw);
			winwid->x = tc_x;
			winwid->y = tc_y;
			XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h);