1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 21:38:00 +01:00

wmaker: Allow configuration of window snapping detect distances.

This patch introduces two new configuration values, SnapEdgeDetect and
SnapCornerDetect, which users can set to change the distance from an edge
or corner at which window snapping will begin.  The defaults are 1 and 10,
respectively.

Suggested-by: Josip Deanovic <djosip+news@linuxpages.net>
This commit is contained in:
Doug Torrance
2015-06-22 09:50:51 -05:00
committed by Carlos R. Mafra
parent 791fdd1eff
commit 443a08ea16
4 changed files with 30 additions and 14 deletions

View File

@@ -1240,23 +1240,28 @@ static void draw_snap_frame(WWindow *wwin, int direction)
static int get_snap_direction(WScreen *scr, int x, int y)
{
if (x < 1) {
if (y < 1)
return SNAP_TOPLEFT;
if (y > scr->scr_height - 2)
return SNAP_BOTTOMLEFT;
int edge, corner;
edge = wPreferences.snap_edge_detect;
corner = wPreferences.snap_corner_detect;
if (x < corner && y < corner)
return SNAP_TOPLEFT;
if (x < corner && y >= scr->scr_height - corner)
return SNAP_BOTTOMLEFT;
if (x < edge)
return SNAP_LEFT;
}
if (x > scr->scr_width - 2) {
if (y < 1)
return SNAP_TOPRIGHT;
if (y > scr->scr_height - 2)
return SNAP_BOTTOMRIGHT;
if (x >= scr->scr_width - corner && y < corner)
return SNAP_TOPRIGHT;
if (x >= scr->scr_width - corner && y >= scr->scr_height - corner)
return SNAP_BOTTOMRIGHT;
if (x >= scr->scr_width - edge)
return SNAP_RIGHT;
}
if (y < 1)
if (y < edge)
return SNAP_TOP;
if (y > scr->scr_height - 2)
if (y >= scr->scr_height - edge)
return SNAP_BOTTOM;
return SNAP_NONE;
}