mirror of
https://github.com/brl/mutter.git
synced 2025-01-12 20:52:37 +00:00
input-capture: Check barriers don't extend into nonexisting monitors
Create a fake monitor region right of the right-most monitor and if a horizontal barrier extends into that region, fail the barrier. Barriers are aligned on the top/left edge of the pixel so the most natural barrier of (e.g. 0-1024) is also wrong - it's one pixel into the next monitor. Check this for nonexisting screens on the right too to avoid clients suddenly failing when multiple monitors are present. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3319>
This commit is contained in:
parent
b7078ddab7
commit
85885c6539
@ -748,6 +748,33 @@ check_barrier (MetaInputCaptureSession *session,
|
||||
}
|
||||
}
|
||||
|
||||
if (has_adjacent_monitor && y1 == y2)
|
||||
{
|
||||
MetaLogicalMonitor *monitor;
|
||||
MetaLogicalMonitor *next;
|
||||
MtkRectangle layout, fake_layout;
|
||||
|
||||
monitor = meta_monitor_manager_get_logical_monitor_at (monitor_manager, 0, 0);
|
||||
while ((next = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager, monitor, META_DISPLAY_RIGHT)))
|
||||
monitor = next;
|
||||
|
||||
layout = meta_logical_monitor_get_layout (monitor);
|
||||
fake_layout = (MtkRectangle) {
|
||||
.x = layout.x + layout.width,
|
||||
.y = layout.y,
|
||||
.width = layout.width,
|
||||
.height = layout.height,
|
||||
};
|
||||
|
||||
LineAdjacency adjacency = get_barrier_adjacency (&fake_layout, x1, y1, x2, y2, error);
|
||||
if (adjacency != LINE_ADJACENCY_NONE)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
|
||||
"Line extends into nonexisting monitor region");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return has_adjacent_monitor;
|
||||
}
|
||||
|
||||
|
@ -702,8 +702,8 @@ test_barriers (void)
|
||||
* +==============+
|
||||
*/
|
||||
barrier1 = input_capture_session_add_barrier (session, 0, 0, 0, 600);
|
||||
barrier2 = input_capture_session_add_barrier (session, 800, 768, 1824, 768);
|
||||
barrier3 = input_capture_session_add_barrier (session, 800, 0, 1824, 0);
|
||||
barrier2 = input_capture_session_add_barrier (session, 800, 768, 1823, 768);
|
||||
barrier3 = input_capture_session_add_barrier (session, 800, 0, 1823, 0);
|
||||
|
||||
g_assert_cmpuint (barrier1, !=, 0);
|
||||
g_assert_cmpuint (barrier2, !=, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user