feat: implement composable window snapping with dual-axis constraints and toggle-to-full behavior

Add SnapHorizontal/SnapVertical enums and SnapConstraint struct to Client for tracking snap state. Introduce layout_apply_snap_constraint() to position windows into quadrants or full axes based on stored snap flags. Extend key_snap_left/right with toggle logic that expands to full width on second press, and add new key_snap_up/down handlers for vertical snapping. Update shortcut documentation and help overlay to describe composable two-key sequences (e.g. Super+Left then Super+Up for top-left quarter).
This commit is contained in:
2025-12-28 10:21:03 +00:00
parent 64f9761116
commit ab36b7dd2c
17 changed files with 210 additions and 64 deletions
+21
View File
@@ -62,6 +62,26 @@ typedef enum {
CLIENT_MAXIMIZED = (1 << 5)
} ClientFlags;
typedef enum {
SNAP_H_NONE = 0,
SNAP_H_LEFT,
SNAP_H_RIGHT,
SNAP_H_FULL
} SnapHorizontal;
typedef enum {
SNAP_V_NONE = 0,
SNAP_V_TOP,
SNAP_V_BOTTOM,
SNAP_V_FULL
} SnapVertical;
typedef struct {
SnapHorizontal horizontal;
SnapVertical vertical;
long timestamp;
} SnapConstraint;
typedef struct Client Client;
typedef struct Workspace Workspace;
typedef struct Monitor Monitor;
@@ -80,6 +100,7 @@ struct Client {
unsigned int workspace;
char title[256];
char class[64];
SnapConstraint snap;
Client *next;
Client *prev;
Client *mru_next;
+2
View File
@@ -83,6 +83,8 @@ void key_show_shortcuts(void);
void key_start_tutorial(void);
void key_snap_left(void);
void key_snap_right(void);
void key_snap_up(void);
void key_snap_down(void);
void key_start_demo(void);
void tutorial_start(void);
+3
View File
@@ -17,6 +17,9 @@ void layout_arrange_monocle(int workspace);
int layout_get_usable_area(int *x, int *y, int *width, int *height);
int layout_count_tiled_clients(int workspace);
void layout_apply_snap_constraint(Client *c, int area_x, int area_y,
int area_w, int area_h, int gap);
const char *layout_get_name(LayoutType layout);
const char *layout_get_symbol(LayoutType layout);