summaryrefslogtreecommitdiff
path: root/src
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 /src
parent33c0b2a82d05ae0162e7f07665adc6598ed50c09 (diff)
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
Diffstat (limited to 'src')
-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)
465 static int bar_num = 0; 465 static int bar_num = 0;
466 static int bar_alloc = 0; 466 static int bar_alloc = 0;
467 Region reg, reg2, reg3; 467 Region reg, reg2, reg3;
468 Window rwin, cwin;
469 int rx, ry, wx, wy;
468 int i, j; 470 int i, j;
471 int closest_dist, dist;
472 int sx, sy, dx, dy;
473 unsigned int mask;
474 Eina_Bool inside = EINA_FALSE;
475 Ecore_X_Rectangle *closest_screen = NULL;
469 476
470 // clear out old root screen barriers.... 477 // clear out old root screen barriers....
471 if (bar) 478 if (bar)
@@ -476,6 +483,55 @@ ecore_x_root_screen_barriers_set(Ecore_X_Rectangle *screens, int num)
476 } 483 }
477 free(bar); 484 free(bar);
478 } 485 }
486 // ensure mouse pointer is insude the new set of screens if it is not
487 // inside them right now
488 XQueryPointer(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp),
489 &rwin, &cwin, &rx, &ry, &wx, &wy, &mask);
490 for (i = 0; i < num; i++)
491 {
492 if ((rx >= screens[i].x) &&
493 (rx < (screens[i].x + (int)screens[i].width)) &&
494 (ry >= screens[i].y) &&
495 (ry < (screens[i].y + (int)screens[i].height)))
496 {
497 inside = EINA_TRUE;
498 break;
499 }
500 if (!closest_screen) closest_screen = &(screens[i]);
501 else
502 {
503 // screen center
504 sx = closest_screen->x + (closest_screen->width / 2);
505 sy = closest_screen->y + (closest_screen->height / 2);
506 dx = rx - sx;
507 dy = ry - sy;
508 // square dist to center
509 closest_dist = ((dx * dx) + (dy * dy));
510 // screen center
511 sx = screens[i].x + (screens[i].width / 2);
512 sy = screens[i].y + (screens[i].height / 2);
513 dx = rx - sx;
514 dy = ry - sy;
515 // square dist to center
516 dist = ((dx * dx) + (dy * dy));
517 // if closer than previous closest, then this screen is closer
518 if (dist < closest_dist) closest_screen = &(screens[i]);
519 }
520 }
521 // if the pointer is not inside oneof the new screen areas then
522 // move it to the center of the closest one to ensure it doesn't get
523 // stuck outside
524 if ((!inside) && (closest_screen))
525 {
526 // screen center
527 sx = closest_screen->x + (closest_screen->width / 2);
528 sy = closest_screen->y + (closest_screen->height / 2);
529 // move pointer there
530 XWarpPointer(_ecore_x_disp, None,
531 DefaultRootWindow(_ecore_x_disp),
532 0, 0, 0, 0, sx, sy);
533 }
534
479 bar = NULL; 535 bar = NULL;
480 bar_num = 0; 536 bar_num = 0;
481 bar_alloc = 0; 537 bar_alloc = 0;