raster pushed a commit to branch v-1.26.0. http://git.enlightenment.org/core/efl.git/commit/?id=0eda6e589dec0cc3195ce5c00d084c6a054f2506
commit 0eda6e589dec0cc3195ce5c00d084c6a054f2506 Author: Carsten Haitzler <[email protected]> Date: Thu Jan 20 12:14:57 2022 +0000 ecore x - ensure pointer is not outside barriers when settingh for screens 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 --- src/lib/ecore_x/ecore_x_fixes.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) 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; --
