]> git.mdlowis.com Git - proto/labwc.git/commitdiff
snapping: replace <snapping><range> with <snapping><range inner="" outer=""> (#3241)
authorelviosak <33790211+elviosak@users.noreply.github.com>
Sat, 6 Dec 2025 07:09:28 +0000 (04:09 -0300)
committerGitHub <noreply@github.com>
Sat, 6 Dec 2025 07:09:28 +0000 (16:09 +0900)
<inner>/<outer> configure the size of snapping area on output edges with/without adjacent outputs.

docs/labwc-config.5.scd
docs/rc.xml.all
include/config/rcxml.h
src/config/rcxml.c
src/interactive.c

index fa4f7e583cf4f4acfd0074ee2d090bb7451b0e4a..74442362eb085e6f4ef944868805a9605ce00237 100644 (file)
@@ -498,13 +498,16 @@ activated with SnapToEdge actions or, optionally, by dragging windows to the
 edges of an output. Edge snapping causes a window to occupy half of its output,
 extending outward from the snapped edge.
 
-*<snapping><range>*++
+*<snapping><range><inner>*++
+*<snapping><range><outer>*++
 *<snapping><cornerRange>*
-       If an interactive move ends with the cursor within *<range>* pixels of an
-       output edge, the window is snapped to the edge. If it's also within
-       *<cornerRange>* pixels of an output corner, the window is snapped to the
-       corner instead. A *<range>* of 0 disables snapping.
-       Default is 10 for *<range>* and 50 for *<cornerRange>*.
+       If an interactive move ends with the cursor within *inner* or *outer* pixels
+       of an output edge, the window is snapped to the edge. *inner* edges are edges
+       with an adjacent output and *outer* edges are edges without an adjacent output.
+       If it's also within *<cornerRange>* pixels of an output corner, the window is
+       snapped to the corner instead.
+       If *inner* and *outer* is 0, snapping is disabled.
+       Default is 10 for *<range><inner>* and *<range><outer>*, and 50 for *<cornerRange>*.
 
 *<snapping><overlay><enabled>* [yes|no]
        Show an overlay when snapping to a window to an edge. Default is yes.
index 13f4c8df285cc127bafdae007c70907b6597086e..f3d046d421f8c2db236d1d66060d74f60786cf7d 100644 (file)
   </focus>
 
   <snapping>
-    <!-- Set range to 0 to disable window snapping completely -->
-    <range>10</range>
+    <!-- Set inner and outer range to 0 to disable window snapping completely -->
+    <range inner="10" outer="10" />
     <cornerRange>50</cornerRange>
     <overlay enabled="yes">
       <delay inner="500" outer="500" />
index 55c0f877464afc0a7d903835dae3b3e1bbfcbc32..3e4f15a2219df519292e0cdc760dbe22643633e1 100644 (file)
@@ -151,7 +151,8 @@ struct rcxml {
        int unmaximize_threshold;
 
        /* window snapping */
-       int snap_edge_range;
+       int snap_edge_range_inner;
+       int snap_edge_range_outer;
        int snap_edge_corner_range;
        bool snap_overlay_enabled;
        int snap_overlay_delay_inner;
index 84054e82450f9f206b6472f3545ccca3050a9445..b54e528acc654638232269cc7bbefde9adc3835a 100644 (file)
@@ -1180,7 +1180,14 @@ entry(xmlNode *node, char *nodename, char *content)
        } else if (!strcasecmp(nodename, "unMaximizeThreshold.resistance")) {
                rc.unmaximize_threshold = atoi(content);
        } else if (!strcasecmp(nodename, "range.snapping")) {
-               rc.snap_edge_range = atoi(content);
+               rc.snap_edge_range_inner = atoi(content);
+               rc.snap_edge_range_outer = atoi(content);
+               wlr_log(WLR_ERROR, "<snapping><range> is deprecated. "
+                       "Use <snapping><range inner=\"\" outer=\"\"> instead.");
+       } else if (!strcasecmp(nodename, "inner.range.snapping")) {
+               rc.snap_edge_range_inner = atoi(content);
+       } else if (!strcasecmp(nodename, "outer.range.snapping")) {
+               rc.snap_edge_range_outer = atoi(content);
        } else if (!strcasecmp(nodename, "cornerRange.snapping")) {
                rc.snap_edge_corner_range = atoi(content);
        } else if (!strcasecmp(nodename, "enabled.overlay.snapping")) {
@@ -1459,7 +1466,8 @@ rcxml_init(void)
        rc.unsnap_threshold = 20;
        rc.unmaximize_threshold = 150;
 
-       rc.snap_edge_range = 10;
+       rc.snap_edge_range_inner = 10;
+       rc.snap_edge_range_outer = 10;
        rc.snap_edge_corner_range = 50;
        rc.snap_overlay_enabled = true;
        rc.snap_overlay_delay_inner = 500;
index df32f46f90f2e00c29c40c0b1abc9e3d6a6ce0fd..03c4ad53ba972b1042b6075f3f010f285eb6db20 100644 (file)
@@ -186,7 +186,7 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
                return false;
        }
 
-       if (rc.snap_edge_range == 0) {
+       if (rc.snap_edge_range_inner == 0 && rc.snap_edge_range_outer == 0) {
                return false;
        }
 
@@ -197,9 +197,31 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
        }
        *dest_output = output;
 
-       /* Translate into output local coordinates */
        double cursor_x = seat->cursor->x;
        double cursor_y = seat->cursor->y;
+
+       int top_range = rc.snap_edge_range_outer;
+       int bottom_range = rc.snap_edge_range_outer;
+       int left_range = rc.snap_edge_range_outer;
+       int right_range = rc.snap_edge_range_outer;
+       if (wlr_output_layout_adjacent_output(seat->server->output_layout, WLR_DIRECTION_UP,
+                       output->wlr_output, cursor_x, cursor_y)) {
+               top_range = rc.snap_edge_range_inner;
+       }
+       if (wlr_output_layout_adjacent_output(seat->server->output_layout, WLR_DIRECTION_DOWN,
+                       output->wlr_output, cursor_x, cursor_y)) {
+               bottom_range = rc.snap_edge_range_inner;
+       }
+       if (wlr_output_layout_adjacent_output(seat->server->output_layout, WLR_DIRECTION_LEFT,
+                       output->wlr_output, cursor_x, cursor_y)) {
+               left_range = rc.snap_edge_range_inner;
+       }
+       if (wlr_output_layout_adjacent_output(seat->server->output_layout, WLR_DIRECTION_RIGHT,
+                       output->wlr_output, cursor_x, cursor_y)) {
+               right_range = rc.snap_edge_range_inner;
+       }
+
+       /* Translate into output local coordinates */
        wlr_output_layout_output_coords(seat->server->output_layout,
                output->wlr_output, &cursor_x, &cursor_y);
 
@@ -210,13 +232,13 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
        int left = cursor_x - area->x;
        int right = area->x + area->width - cursor_x;
 
-       if (top < rc.snap_edge_range) {
+       if (top < top_range) {
                *edge1 = LAB_EDGE_TOP;
-       } else if (bottom < rc.snap_edge_range) {
+       } else if (bottom < bottom_range) {
                *edge1 = LAB_EDGE_BOTTOM;
-       } else if (left < rc.snap_edge_range) {
+       } else if (left < left_range) {
                *edge1 = LAB_EDGE_LEFT;
-       } else if (right < rc.snap_edge_range) {
+       } else if (right < right_range) {
                *edge1 = LAB_EDGE_RIGHT;
        } else {
                return false;