mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
change to inner/outer range
This commit is contained in:
parent
f89c31c2de
commit
b2750027da
5 changed files with 54 additions and 27 deletions
|
|
@ -498,15 +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,
|
edges of an output. Edge snapping causes a window to occupy half of its output,
|
||||||
extending outward from the snapped edge.
|
extending outward from the snapped edge.
|
||||||
|
|
||||||
*<snapping><horizontalRange>*++
|
*<snapping><range><inner>*++
|
||||||
*<snapping><verticalRange>*++
|
*<snapping><range><outer>*++
|
||||||
*<snapping><cornerRange>*
|
*<snapping><cornerRange>*
|
||||||
If an interactive move ends with the cursor within *<horizontalRange>* pixels of
|
If an interactive move ends with the cursor within *inner* or *outer* pixels
|
||||||
the left/right output edge, or *<verticalRange>* of the top/bottom output edge,
|
of an output edge, the window is snapped to the edge. *inner* edges are edges
|
||||||
the window is snapped to the edge. If it's also within *<cornerRange>* pixels of
|
with an adjacent output and *outer* edges are edges without an adjacent output.
|
||||||
an output corner, the window is snapped to the corner instead.
|
If it's also within *<cornerRange>* pixels of an output corner, the window is
|
||||||
If *<horizontalRange>* and *<verticalRange>* is 0, snapping is disabled.
|
snapped to the corner instead.
|
||||||
Default is 10 for *<horizontalRange>* and *<verticalRange>*, and 50 for *<cornerRange>*.
|
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]
|
*<snapping><overlay><enabled>* [yes|no]
|
||||||
Show an overlay when snapping to a window to an edge. Default is yes.
|
Show an overlay when snapping to a window to an edge. Default is yes.
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,8 @@
|
||||||
</focus>
|
</focus>
|
||||||
|
|
||||||
<snapping>
|
<snapping>
|
||||||
<!-- Set range to 0 to disable window snapping completely -->
|
<!-- Set inner and outer range to 0 to disable window snapping completely -->
|
||||||
<horizontalRange>10</horizontalRange>
|
<range inner="10" outer="10" />
|
||||||
<verticalRange>10</verticalRange>
|
|
||||||
<cornerRange>50</cornerRange>
|
<cornerRange>50</cornerRange>
|
||||||
<overlay enabled="yes">
|
<overlay enabled="yes">
|
||||||
<delay inner="500" outer="500" />
|
<delay inner="500" outer="500" />
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,8 @@ struct rcxml {
|
||||||
int unmaximize_threshold;
|
int unmaximize_threshold;
|
||||||
|
|
||||||
/* window snapping */
|
/* window snapping */
|
||||||
int snap_edge_horizontal_range;
|
int snap_edge_range_inner;
|
||||||
int snap_edge_vertical_range;
|
int snap_edge_range_outer;
|
||||||
int snap_edge_corner_range;
|
int snap_edge_corner_range;
|
||||||
bool snap_overlay_enabled;
|
bool snap_overlay_enabled;
|
||||||
int snap_overlay_delay_inner;
|
int snap_overlay_delay_inner;
|
||||||
|
|
|
||||||
|
|
@ -1177,12 +1177,12 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
} else if (!strcasecmp(nodename, "unMaximizeThreshold.resistance")) {
|
} else if (!strcasecmp(nodename, "unMaximizeThreshold.resistance")) {
|
||||||
rc.unmaximize_threshold = atoi(content);
|
rc.unmaximize_threshold = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "range.snapping")) {
|
} else if (!strcasecmp(nodename, "range.snapping")) {
|
||||||
rc.snap_edge_horizontal_range = atoi(content);
|
rc.snap_edge_range_inner = atoi(content);
|
||||||
rc.snap_edge_vertical_range = atoi(content);
|
rc.snap_edge_range_outer = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "horizontalRange.snapping")) {
|
} else if (!strcasecmp(nodename, "inner.range.snapping")) {
|
||||||
rc.snap_edge_horizontal_range = atoi(content);
|
rc.snap_edge_range_inner = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "verticalRange.snapping")) {
|
} else if (!strcasecmp(nodename, "outer.range.snapping")) {
|
||||||
rc.snap_edge_vertical_range = atoi(content);
|
rc.snap_edge_range_outer = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "cornerRange.snapping")) {
|
} else if (!strcasecmp(nodename, "cornerRange.snapping")) {
|
||||||
rc.snap_edge_corner_range = atoi(content);
|
rc.snap_edge_corner_range = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "enabled.overlay.snapping")) {
|
} else if (!strcasecmp(nodename, "enabled.overlay.snapping")) {
|
||||||
|
|
@ -1461,8 +1461,8 @@ rcxml_init(void)
|
||||||
rc.unsnap_threshold = 20;
|
rc.unsnap_threshold = 20;
|
||||||
rc.unmaximize_threshold = 150;
|
rc.unmaximize_threshold = 150;
|
||||||
|
|
||||||
rc.snap_edge_horizontal_range = 10;
|
rc.snap_edge_range_inner = 10;
|
||||||
rc.snap_edge_vertical_range = 10;
|
rc.snap_edge_range_outer = 10;
|
||||||
rc.snap_edge_corner_range = 50;
|
rc.snap_edge_corner_range = 50;
|
||||||
rc.snap_overlay_enabled = true;
|
rc.snap_overlay_enabled = true;
|
||||||
rc.snap_overlay_delay_inner = 500;
|
rc.snap_overlay_delay_inner = 500;
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc.snap_edge_horizontal_range == 0 && rc.snap_edge_vertical_range == 0) {
|
if (rc.snap_edge_range_inner == 0 && rc.snap_edge_range_outer == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,9 +197,36 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
|
||||||
}
|
}
|
||||||
*dest_output = output;
|
*dest_output = output;
|
||||||
|
|
||||||
/* Translate into output local coordinates */
|
|
||||||
double cursor_x = seat->cursor->x;
|
double cursor_x = seat->cursor->x;
|
||||||
double cursor_y = seat->cursor->y;
|
double cursor_y = seat->cursor->y;
|
||||||
|
|
||||||
|
int top_range, bottom_range, left_range, right_range;
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
top_range = rc.snap_edge_range_outer;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
bottom_range = rc.snap_edge_range_outer;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
left_range = rc.snap_edge_range_outer;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
right_range = rc.snap_edge_range_outer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Translate into output local coordinates */
|
||||||
wlr_output_layout_output_coords(seat->server->output_layout,
|
wlr_output_layout_output_coords(seat->server->output_layout,
|
||||||
output->wlr_output, &cursor_x, &cursor_y);
|
output->wlr_output, &cursor_x, &cursor_y);
|
||||||
|
|
||||||
|
|
@ -210,13 +237,13 @@ edge_from_cursor(struct seat *seat, struct output **dest_output,
|
||||||
int left = cursor_x - area->x;
|
int left = cursor_x - area->x;
|
||||||
int right = area->x + area->width - cursor_x;
|
int right = area->x + area->width - cursor_x;
|
||||||
|
|
||||||
if (top < rc.snap_edge_vertical_range) {
|
if (top < top_range) {
|
||||||
*edge1 = LAB_EDGE_TOP;
|
*edge1 = LAB_EDGE_TOP;
|
||||||
} else if (bottom < rc.snap_edge_vertical_range) {
|
} else if (bottom < bottom_range) {
|
||||||
*edge1 = LAB_EDGE_BOTTOM;
|
*edge1 = LAB_EDGE_BOTTOM;
|
||||||
} else if (left < rc.snap_edge_horizontal_range) {
|
} else if (left < left_range) {
|
||||||
*edge1 = LAB_EDGE_LEFT;
|
*edge1 = LAB_EDGE_LEFT;
|
||||||
} else if (right < rc.snap_edge_horizontal_range) {
|
} else if (right < right_range) {
|
||||||
*edge1 = LAB_EDGE_RIGHT;
|
*edge1 = LAB_EDGE_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue