Commit 52d37bf6 authored by Jonathan Waddell's avatar Jonathan Waddell Committed by Aaron Plattner

Allow moving displays to the origin even if the layout window is too large.

Currently, we can get in a situation where the nvidia-settings display layout window is setup to be larger than what the X server allows. The problem is if we are in this situation, the user may not be able to fix the layout because our enforcement of size limits doesn't allow the user to move displays to the origin. This is because when moving items to the left or upward, we calculate our movement limit with respect to the right-most or furthest down position used.

This change will allow us to always move items to the origin. Note that we already always redefine the origin to be the top-left most valid item. This position should always be available when moving items.
parent dc9b16d0
......@@ -1965,6 +1965,8 @@ static int move_selected(CtkDisplayLayout *ctk_object, int x, int y, int snap)
sdim = get_screen_rect(info->screen, 1);
/* Prevent moving out of the max layout bounds */
/* Restrict movement in the positive direction */
x = MAX_LAYOUT_WIDTH - dim->width;
if (info->dst_dim.x > x) {
info->modify_dim.x += x - info->dst_dim.x;
......@@ -1975,12 +1977,18 @@ static int move_selected(CtkDisplayLayout *ctk_object, int x, int y, int snap)
info->modify_dim.y += y - info->dst_dim.y;
info->dst_dim.y = y;
}
x = layout->dim.width - MAX_LAYOUT_WIDTH;
/* Restrict movement in the negative direction. As long as the total
* distance does not exceed our maximum value, we can recalculate the
* layout origin. We should also make sure that the current origin (0,0)
* is accessible to the user.
*/
x = NV_MIN(layout->dim.width - MAX_LAYOUT_WIDTH, 0);
if (info->dst_dim.x < x) {
info->modify_dim.x += x - info->dst_dim.x;
info->dst_dim.x = x;
}
y = layout->dim.height - MAX_LAYOUT_HEIGHT;
y = NV_MIN(layout->dim.height - MAX_LAYOUT_HEIGHT, 0);
if (info->dst_dim.y < y) {
info->modify_dim.y += y - info->dst_dim.y;
info->dst_dim.y = y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment