Add snap to window edge framework

Adds functions for calculation of distances between window edges, as
well as for window growing and shrinking.

All calculations are based on the "pending" geometry.

Ignored from snapping:

 - views that do not share the same output
 - minimized views
 - maximized views
 - views that are neither:
   - part of the current workspace
   - part of the always-on-top tree
This commit is contained in:
Axel Burri 2023-08-05 23:53:01 +02:00 committed by Johan Malm
parent 5176ac4f64
commit 1d72a08916
3 changed files with 297 additions and 0 deletions

17
include/snap.h Normal file
View file

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_SNAP_H
#define LABWC_SNAP_H
#include "common/border.h"
#include "view.h"
struct wlr_box;
struct border snap_get_max_distance(struct view *view);
void snap_vector_to_next_edge(struct view *view, enum view_edge direction, int *dx, int *dy);
int snap_distance_to_next_edge(struct view *view, enum view_edge direction);
void snap_grow_to_next_edge(struct view *view, enum view_edge direction, struct wlr_box *geo);
void snap_shrink_to_next_edge(struct view *view, enum view_edge direction, struct wlr_box *geo);
#endif /* LABWC_SNAP_H */