mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
interactive: allow moving horizontally/vertically maximized window
Applies drag resistance unidirectionally for horizontally/vertically maximized windows, allowing them to be dragged without being untiled immediately. When the distance of cursor movement orthogonal to the maximized direction exceeds <resistance><unMaximizeThreshold>. While dragging a horizontally/vertically maximized window, edge/region snapping is disabled to prevent unintentional snapping and overlays. This commit also includes some refactoring to simplify the logic.
This commit is contained in:
parent
2e19bd4d5b
commit
1f1bdad087
11 changed files with 137 additions and 120 deletions
|
|
@ -91,8 +91,38 @@ check_edge_window(int *next, struct edge current, struct edge target,
|
|||
oppose, align, rc.window_edge_strength, lesser);
|
||||
}
|
||||
|
||||
bool
|
||||
resistance_unsnap_apply(struct view *view, int *x, int *y)
|
||||
{
|
||||
if (view_is_floating(view)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int dx = *x - view->current.x;
|
||||
int dy = *y - view->current.y;
|
||||
if (view->maximized == VIEW_AXIS_HORIZONTAL) {
|
||||
if (abs(dx) < rc.unmaximize_threshold) {
|
||||
*x = view->current.x;
|
||||
return false;
|
||||
}
|
||||
} else if (view->maximized == VIEW_AXIS_VERTICAL) {
|
||||
if (abs(dy) < rc.unmaximize_threshold) {
|
||||
*y = view->current.y;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (dx * dx + dy * dy < rc.unsnap_threshold * rc.unsnap_threshold) {
|
||||
*x = view->current.x;
|
||||
*y = view->current.y;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resistance_move_apply(struct view *view, double *x, double *y)
|
||||
resistance_move_apply(struct view *view, int *x, int *y)
|
||||
{
|
||||
assert(view);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue