Add resistance when dragging tiled windows

Adds a config option <snapping><dragResistance> with default value 20.
This prevents tiled/maximized windows from being unintentionally untiled.
This commit is contained in:
tokyo4j 2024-07-20 16:58:39 +09:00 committed by Consolatis
parent 750d37b16c
commit c202d77c2d
8 changed files with 82 additions and 4 deletions

View file

@ -125,6 +125,7 @@ struct rcxml {
int snap_overlay_delay_outer;
bool snap_top_maximize;
enum tiling_events_mode snap_tiling_events_mode;
int snap_drag_resistance;
enum resize_indicator_mode resize_indicator;
bool resize_draw_contents;

View file

@ -256,7 +256,16 @@ struct server {
/* cursor interactive */
enum input_mode input_mode;
struct view *grabbed_view;
/*
* When an interactive move is requested for tiled/maximized views by CSD
* clients or by Drag actions, the actual motion and untiling of the view
* can be delayed to prevent the view from being unintentionally untiled.
* During this delay, move_pending is set.
*/
bool move_pending;
/* Cursor position when interactive move/resize is requested */
double grab_x, grab_y;
/* View geometry when interactive move/resize is requested */
struct wlr_box grab_box;
uint32_t resize_edges;
@ -497,6 +506,15 @@ void seat_output_layout_changed(struct seat *seat);
*/
void interactive_anchor_to_cursor(struct view *view, struct wlr_box *geometry);
/**
* interactive_move_tiled_view_to() - Un-tile the tiled/maximized view at the
* start of an interactive move or when an interactive move is pending.
* Returns true if the distance of cursor motion exceeds the value of
* <snapping><dragResistance> and the view is un-tiled.
*/
bool interactive_move_tiled_view_to(struct server *server, struct view *view,
struct wlr_box *geometry);
void interactive_begin(struct view *view, enum input_mode mode, uint32_t edges);
void interactive_finish(struct view *view);
void interactive_cancel(struct view *view);