mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
backends/native: Fix relative motion calculation if monitor isn't found
The method `relative_motion_across_outputs` is used to adjust the distance/delta of a mouse movement across multiple monitors to take the different scale factors of those monitors into account. This works by getting the adjacent monitors that the movement-line/vector intersects with and adjusting the final position (or end point of the movement-line) by multiplying the parts of the line spanning across different monitors with the scale factors of those monitors. In the end of this calculation, we always want to set the new end coordinates of the relative motion to the new end coordinates of the adjusted movement-line. We currently only do that if all adjacent monitors the line is crossing actually exist, because only then we end up inside the "We reached the dest logical monitor" else-block and set `x` and `y` to the correct values. Fix that and make sure the returned values are also correct in case an adjacent monitor doesn't exist by adding separate `target_x` and `target_y` variables which we update during each pass of the while loop so we're always prepared for the while loop exiting before the destination monitor was found. Thanks to Axel Kittenberger for reporting the initial bug and tracking the issue down to `relative_motion_across_outputs`. Fixes https://gitlab.gnome.org/GNOME/mutter/issues/774
This commit is contained in:
parent
84ea4ad990
commit
c4fa30ac7d
@ -227,6 +227,7 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
|||||||
{
|
{
|
||||||
MetaLogicalMonitor *cur = current;
|
MetaLogicalMonitor *cur = current;
|
||||||
float x = cur_x, y = cur_y;
|
float x = cur_x, y = cur_y;
|
||||||
|
float target_x = cur_x, target_y = cur_y;
|
||||||
float dx = *dx_inout, dy = *dy_inout;
|
float dx = *dx_inout, dy = *dy_inout;
|
||||||
MetaDisplayDirection direction = -1;
|
MetaDisplayDirection direction = -1;
|
||||||
|
|
||||||
@ -256,6 +257,9 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
|||||||
{ cur->rect.x + cur->rect.width, cur->rect.y + cur->rect.height }
|
{ cur->rect.x + cur->rect.width, cur->rect.y + cur->rect.height }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
target_x = motion.b.x;
|
||||||
|
target_y = motion.b.y;
|
||||||
|
|
||||||
if (direction != META_DISPLAY_RIGHT &&
|
if (direction != META_DISPLAY_RIGHT &&
|
||||||
meta_line2_intersects_with (&motion, &left, &intersection))
|
meta_line2_intersects_with (&motion, &left, &intersection))
|
||||||
direction = META_DISPLAY_LEFT;
|
direction = META_DISPLAY_LEFT;
|
||||||
@ -269,12 +273,8 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
|||||||
meta_line2_intersects_with (&motion, &bottom, &intersection))
|
meta_line2_intersects_with (&motion, &bottom, &intersection))
|
||||||
direction = META_DISPLAY_DOWN;
|
direction = META_DISPLAY_DOWN;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
/* We reached the dest logical monitor */
|
/* We reached the dest logical monitor */
|
||||||
x = motion.b.x;
|
|
||||||
y = motion.b.y;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
x = intersection.x;
|
x = intersection.x;
|
||||||
y = intersection.y;
|
y = intersection.y;
|
||||||
@ -285,8 +285,8 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
|||||||
cur, direction);
|
cur, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
*dx_inout = x - cur_x;
|
*dx_inout = target_x - cur_x;
|
||||||
*dy_inout = y - cur_y;
|
*dy_inout = target_y - cur_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user