summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2022-01-20 12:14:57 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2022-01-20 12:14:57 +0000
commit5e1023f64b35c6e999b1c0468fa0700069c86369 (patch)
tree77be8db0061c99d786fc11d9baed472abe1548b3
parent33c0b2a82d05ae0162e7f07665adc6598ed50c09 (diff)
downloadefl-5e1023f64b35c6e999b1c0468fa0700069c86369.tar.gz
ecore x - ensure pointer is not outside barriers when settingh for screensHEADmaster
it might be possible the pointer is outside the screen areas and perhaps gets caught there, so move the pointer in first before setting up new barriers @fix
-rw-r--r--src/lib/ecore_x/ecore_x_fixes.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/lib/ecore_x/ecore_x_fixes.c b/src/lib/ecore_x/ecore_x_fixes.c
index 1c92d574f3..ac6f9bcab7 100644
--- a/src/lib/ecore_x/ecore_x_fixes.c
+++ b/src/lib/ecore_x/ecore_x_fixes.c
@@ -465,7 +465,14 @@ ecore_x_root_screen_barriers_set(Ecore_X_Rectangle *screens, int num)
static int bar_num = 0;
static int bar_alloc = 0;
Region reg, reg2, reg3;
+ Window rwin, cwin;
+ int rx, ry, wx, wy;
int i, j;
+ int closest_dist, dist;
+ int sx, sy, dx, dy;
+ unsigned int mask;
+ Eina_Bool inside = EINA_FALSE;
+ Ecore_X_Rectangle *closest_screen = NULL;
// clear out old root screen barriers....
if (bar)
@@ -476,6 +483,55 @@ ecore_x_root_screen_barriers_set(Ecore_X_Rectangle *screens, int num)
}
free(bar);
}
+ // ensure mouse pointer is insude the new set of screens if it is not
+ // inside them right now
+ XQueryPointer(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp),
+ &rwin, &cwin, &rx, &ry, &wx, &wy, &mask);
+ for (i = 0; i < num; i++)
+ {
+ if ((rx >= screens[i].x) &&
+ (rx < (screens[i].x + (int)screens[i].width)) &&
+ (ry >= screens[i].y) &&
+ (ry < (screens[i].y + (int)screens[i].height)))
+ {
+ inside = EINA_TRUE;
+ break;
+ }
+ if (!closest_screen) closest_screen = &(screens[i]);
+ else
+ {
+ // screen center
+ sx = closest_screen->x + (closest_screen->width / 2);
+ sy = closest_screen->y + (closest_screen->height / 2);
+ dx = rx - sx;
+ dy = ry - sy;
+ // square dist to center
+ closest_dist = ((dx * dx) + (dy * dy));
+ // screen center
+ sx = screens[i].x + (screens[i].width / 2);
+ sy = screens[i].y + (screens[i].height / 2);
+ dx = rx - sx;
+ dy = ry - sy;
+ // square dist to center
+ dist = ((dx * dx) + (dy * dy));
+ // if closer than previous closest, then this screen is closer
+ if (dist < closest_dist) closest_screen = &(screens[i]);
+ }
+ }
+ // if the pointer is not inside oneof the new screen areas then
+ // move it to the center of the closest one to ensure it doesn't get
+ // stuck outside
+ if ((!inside) && (closest_screen))
+ {
+ // screen center
+ sx = closest_screen->x + (closest_screen->width / 2);
+ sy = closest_screen->y + (closest_screen->height / 2);
+ // move pointer there
+ XWarpPointer(_ecore_x_disp, None,
+ DefaultRootWindow(_ecore_x_disp),
+ 0, 0, 0, 0, sx, sy);
+ }
+
bar = NULL;
bar_num = 0;
bar_alloc = 0;