window: "Hide" edge resistance behind modifier key

Aligning windows manually with other windows has become less important
since the advent of tiling. This decreases the usefulness of edge
resistance, which in fact many users perceive as lag nowadays.

Account for that by limiting resistance to screen and monitor edges by
default, and only include windows when the control key is pressed.

https://bugzilla.gnome.org/show_bug.cgi?id=679609
This commit is contained in:
Florian Müllner 2020-05-23 20:06:14 +02:00 committed by verdre
parent f9edb6bad3
commit 22902a5e2c
4 changed files with 21 additions and 4 deletions

View File

@ -334,6 +334,7 @@ apply_edge_resistance (MetaWindow *window,
ResistanceDataForAnEdge *resistance_data, ResistanceDataForAnEdge *resistance_data,
GSourceFunc timeout_func, GSourceFunc timeout_func,
gboolean xdir, gboolean xdir,
gboolean include_windows,
gboolean keyboard_op) gboolean keyboard_op)
{ {
int i, begin, end; int i, begin, end;
@ -420,6 +421,7 @@ apply_edge_resistance (MetaWindow *window,
switch (edge->edge_type) switch (edge->edge_type)
{ {
case META_EDGE_WINDOW: case META_EDGE_WINDOW:
if (include_windows)
timeout_length_ms = TIMEOUT_RESISTANCE_LENGTH_MS_WINDOW; timeout_length_ms = TIMEOUT_RESISTANCE_LENGTH_MS_WINDOW;
break; break;
case META_EDGE_MONITOR: case META_EDGE_MONITOR:
@ -464,6 +466,8 @@ apply_edge_resistance (MetaWindow *window,
switch (edge->edge_type) switch (edge->edge_type)
{ {
case META_EDGE_WINDOW: case META_EDGE_WINDOW:
if (!include_windows)
break;
if (movement_towards_edge (edge->side_type, increment)) if (movement_towards_edge (edge->side_type, increment))
threshold = PIXEL_DISTANCE_THRESHOLD_TOWARDS_WINDOW; threshold = PIXEL_DISTANCE_THRESHOLD_TOWARDS_WINDOW;
else else
@ -640,6 +644,8 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
} }
else else
{ {
gboolean include_windows = flags & META_EDGE_RESISTANCE_WINDOWS;
/* Disable edge resistance for resizes when windows have size /* Disable edge resistance for resizes when windows have size
* increment hints; see #346782. For all other cases, apply * increment hints; see #346782. For all other cases, apply
* them. * them.
@ -656,6 +662,7 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
&edge_data->left_data, &edge_data->left_data,
timeout_func, timeout_func,
TRUE, TRUE,
include_windows,
keyboard_op); keyboard_op);
new_right = apply_edge_resistance (window, new_right = apply_edge_resistance (window,
BOX_RIGHT (*old_outer), BOX_RIGHT (*old_outer),
@ -666,6 +673,7 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
&edge_data->right_data, &edge_data->right_data,
timeout_func, timeout_func,
TRUE, TRUE,
include_windows,
keyboard_op); keyboard_op);
} }
else else
@ -685,6 +693,7 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
&edge_data->top_data, &edge_data->top_data,
timeout_func, timeout_func,
FALSE, FALSE,
include_windows,
keyboard_op); keyboard_op);
new_bottom = apply_edge_resistance (window, new_bottom = apply_edge_resistance (window,
BOX_BOTTOM (*old_outer), BOX_BOTTOM (*old_outer),
@ -695,6 +704,7 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
&edge_data->bottom_data, &edge_data->bottom_data,
timeout_func, timeout_func,
FALSE, FALSE,
include_windows,
keyboard_op); keyboard_op);
} }
else else

View File

@ -2420,7 +2420,7 @@ process_keyboard_move_grab (MetaDisplay *display,
x = frame_rect.x; x = frame_rect.x;
y = frame_rect.y; y = frame_rect.y;
flags = META_EDGE_RESISTANCE_KEYBOARD_OP; flags = META_EDGE_RESISTANCE_KEYBOARD_OP | META_EDGE_RESISTANCE_WINDOWS;
if ((event->modifier_state & CLUTTER_SHIFT_MASK) != 0) if ((event->modifier_state & CLUTTER_SHIFT_MASK) != 0)
flags |= META_EDGE_RESISTANCE_SNAP; flags |= META_EDGE_RESISTANCE_SNAP;

View File

@ -162,6 +162,7 @@ typedef enum
META_EDGE_RESISTANCE_DEFAULT = 0, META_EDGE_RESISTANCE_DEFAULT = 0,
META_EDGE_RESISTANCE_SNAP = 1 << 0, META_EDGE_RESISTANCE_SNAP = 1 << 0,
META_EDGE_RESISTANCE_KEYBOARD_OP = 1 << 1, META_EDGE_RESISTANCE_KEYBOARD_OP = 1 << 1,
META_EDGE_RESISTANCE_WINDOWS = 1 << 2,
} MetaEdgeResistanceFlags; } MetaEdgeResistanceFlags;
struct _MetaWindow struct _MetaWindow

View File

@ -6421,6 +6421,9 @@ end_grab_op (MetaWindow *window,
if (modifiers & CLUTTER_SHIFT_MASK) if (modifiers & CLUTTER_SHIFT_MASK)
flags |= META_EDGE_RESISTANCE_SNAP; flags |= META_EDGE_RESISTANCE_SNAP;
if (modifiers & CLUTTER_CONTROL_MASK)
flags |= META_EDGE_RESISTANCE_WINDOWS;
if (meta_grab_op_is_moving (window->display->grab_op)) if (meta_grab_op_is_moving (window->display->grab_op))
{ {
if (window->display->preview_tile_mode != META_TILE_NONE) if (window->display->preview_tile_mode != META_TILE_NONE)
@ -6431,7 +6434,7 @@ end_grab_op (MetaWindow *window,
else if (meta_grab_op_is_resizing (window->display->grab_op)) else if (meta_grab_op_is_resizing (window->display->grab_op))
{ {
if (window->tile_match != NULL) if (window->tile_match != NULL)
flags |= META_EDGE_RESISTANCE_SNAP; flags |= (META_EDGE_RESISTANCE_SNAP | META_EDGE_RESISTANCE_WINDOWS);
update_resize (window, flags, x, y, TRUE); update_resize (window, flags, x, y, TRUE);
maybe_maximize_tiled_window (window); maybe_maximize_tiled_window (window);
@ -6503,6 +6506,9 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
if (modifier_state & CLUTTER_SHIFT_MASK) if (modifier_state & CLUTTER_SHIFT_MASK)
flags |= META_EDGE_RESISTANCE_SNAP; flags |= META_EDGE_RESISTANCE_SNAP;
if (modifier_state & CLUTTER_CONTROL_MASK)
flags |= META_EDGE_RESISTANCE_WINDOWS;
meta_display_check_threshold_reached (window->display, x, y); meta_display_check_threshold_reached (window->display, x, y);
if (meta_grab_op_is_moving (window->display->grab_op)) if (meta_grab_op_is_moving (window->display->grab_op))
{ {
@ -6511,7 +6517,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
else if (meta_grab_op_is_resizing (window->display->grab_op)) else if (meta_grab_op_is_resizing (window->display->grab_op))
{ {
if (window->tile_match != NULL) if (window->tile_match != NULL)
flags |= META_EDGE_RESISTANCE_SNAP; flags |= (META_EDGE_RESISTANCE_SNAP | META_EDGE_RESISTANCE_WINDOWS);
update_resize (window, flags, x, y, FALSE); update_resize (window, flags, x, y, FALSE);
} }