- /* Find the screen that contains the mouse. */
- int which = -1;
- int i;
- for (i = 0; i < nscreens; i++)
- {
- if (target_x >= xsi[i].x_org &&
- target_y >= xsi[i].y_org &&
- target_x < xsi[i].x_org + xsi[i].width &&
- target_y < xsi[i].y_org + xsi[i].height)
- which = i;
- if (verbose_p)
- {
- fprintf (stderr, "%s: %d: xinerama vp: %dx%d+%d+%d",
- blurb(), i,
- xsi[which].width, xsi[which].height,
- xsi[i].x_org, xsi[i].y_org);
- if (which == i)
- fprintf (stderr, "; mouse at %d,%d",
- target_x, target_y);
- fprintf (stderr, ".\n");
- }
- }
- if (which == -1) which = 0; /* didn't find it? Use the first. */
- *x_ret = xsi[which].x_org;
- *y_ret = xsi[which].y_org;
- *w_ret = xsi[which].width;
- *h_ret = xsi[which].height;
- XFree (xsi);
- return;
+ target_x = ssi->x;
+ target_y = ssi->y;
+ }
+
+ /* Find the Xinerama rectangle that contains the mouse position. */
+ for (i = 0; i < si->nscreens; i++)
+ {
+ if (target_x >= si->screens[i].x &&
+ target_y >= si->screens[i].y &&
+ target_x < si->screens[i].x + si->screens[i].width &&
+ target_y < si->screens[i].y + si->screens[i].height)
+ which = i;
+ }
+ if (which == -1) which = 0; /* didn't find it? Use the first. */
+ *x_ret = si->screens[which].x;
+ *y_ret = si->screens[which].y;
+ *w_ret = si->screens[which].width;
+ *h_ret = si->screens[which].height;
+
+ if (verbose_p)
+ {
+ fprintf (stderr, "%s: %d: xinerama vp: %dx%d+%d+%d",
+ blurb(), which,
+ si->screens[which].width, si->screens[which].height,
+ si->screens[which].x, si->screens[which].y);
+ if (mouse_p)
+ fprintf (stderr, "; mouse at %d,%d", target_x, target_y);
+ fprintf (stderr, ".\n");