interactive: allow snapping to corner edges

In addition to <snapping><range>, <snapping><cornerRange> configures the
distance from the screen corner to trigger quater window snapping.

Also, new values "up-left", "up-right", "down-left" and "down-right" are
allowed for <action name="(Toggle)SnapToEdge" direction="[value]"> and
<query tiled="[value]">.
This commit is contained in:
tokyo4j 2025-08-02 21:35:51 +09:00 committed by Johan Malm
parent b0ff2911b6
commit 2f183cdcb6
14 changed files with 147 additions and 89 deletions

View file

@ -2,9 +2,10 @@
#ifndef LABWC_DIRECTION_H
#define LABWC_DIRECTION_H
#include <wlr/types/wlr_output_layout.h>
#include "view.h"
enum wlr_direction direction_from_view_edge(enum view_edge edge);
bool direction_from_view_edge(enum view_edge edge, enum wlr_direction *direction);
enum wlr_direction direction_get_opposite(enum wlr_direction direction);
#endif /* LABWC_DIRECTION_H */

View file

@ -145,6 +145,7 @@ struct rcxml {
/* window snapping */
int snap_edge_range;
int snap_edge_corner_range;
bool snap_overlay_enabled;
int snap_overlay_delay_inner;
int snap_overlay_delay_outer;

View file

@ -429,7 +429,16 @@ void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo);
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);
enum view_edge edge_from_cursor(struct seat *seat, struct output **dest_output);
/**
* Returns the edge to snap a window to.
* For example, if the output-relative cursor position (x,y) fulfills
* x <= (<snapping><cornerRange>) and y <= (<snapping><range>),
* then edge1=VIEW_EDGE_UP and edge2=VIEW_EDGE_LEFT.
* The value of (edge1|edge2) can be passed to view_snap_to_edge().
*/
bool edge_from_cursor(struct seat *seat, struct output **dest_output,
enum view_edge *edge1, enum view_edge *edge2);
void handle_tearing_new_object(struct wl_listener *listener, void *data);

View file

@ -73,6 +73,10 @@ enum view_edge {
VIEW_EDGE_DOWN = (1 << 3),
VIEW_EDGE_CENTER = (1 << 4),
VIEW_EDGE_ANY = (1 << 5),
VIEW_EDGE_UPLEFT = (VIEW_EDGE_UP | VIEW_EDGE_LEFT),
VIEW_EDGE_UPRIGHT = (VIEW_EDGE_UP | VIEW_EDGE_RIGHT),
VIEW_EDGE_DOWNLEFT = (VIEW_EDGE_DOWN | VIEW_EDGE_LEFT),
VIEW_EDGE_DOWNRIGHT = (VIEW_EDGE_DOWN | VIEW_EDGE_RIGHT),
};
enum view_wants_focus {
@ -524,6 +528,9 @@ bool view_is_focusable(struct view *view);
*/
void view_offer_focus(struct view *view);
struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output,
enum view_edge edge);
void mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
wl_notify_func_t notify_map, wl_notify_func_t notify_unmap);
void mappable_disconnect(struct mappable *mappable);