mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-29 19:14:15 +00:00
replicate dwm behavior for snap resize
This commit is contained in:
parent
dd00d994ce
commit
f19301ef68
@ -7,6 +7,7 @@
|
|||||||
static const int sloppyfocus = 1; /* focus follows mouse */
|
static const int sloppyfocus = 1; /* focus follows mouse */
|
||||||
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
|
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const float rootcolor[] = COLOR(0x222222ff);
|
static const float rootcolor[] = COLOR(0x222222ff);
|
||||||
static const float bordercolor[] = COLOR(0x444444ff);
|
static const float bordercolor[] = COLOR(0x444444ff);
|
||||||
static const float focuscolor[] = COLOR(0x005577ff);
|
static const float focuscolor[] = COLOR(0x005577ff);
|
||||||
|
|||||||
13
dwl.c
13
dwl.c
@ -1688,6 +1688,7 @@ void
|
|||||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||||
double dx_unaccel, double dy_unaccel)
|
double dx_unaccel, double dy_unaccel)
|
||||||
{
|
{
|
||||||
|
int nx, ny;
|
||||||
double sx = 0, sy = 0, sx_confined, sy_confined;
|
double sx = 0, sy = 0, sx_confined, sy_confined;
|
||||||
Client *c = NULL, *w = NULL;
|
Client *c = NULL, *w = NULL;
|
||||||
LayerSurface *l = NULL;
|
LayerSurface *l = NULL;
|
||||||
@ -1733,7 +1734,17 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|||||||
/* If we are currently grabbing the mouse, handle and return */
|
/* If we are currently grabbing the mouse, handle and return */
|
||||||
if (cursor_mode == CurMove) {
|
if (cursor_mode == CurMove) {
|
||||||
/* Move the grabbed client to the new position. */
|
/* Move the grabbed client to the new position. */
|
||||||
resize(grabc, (struct wlr_box){.x = ROUND(cursor->x) - grabcx, .y = ROUND(cursor->y) - grabcy,
|
nx = ROUND(cursor->x) - grabcx;
|
||||||
|
ny = ROUND(cursor->y) - grabcy;
|
||||||
|
if (abs(selmon->w.x - nx) < snap)
|
||||||
|
nx = selmon->w.x;
|
||||||
|
else if (abs((selmon->w.x + selmon->w.width) - (nx + grabc->geom.width)) < snap)
|
||||||
|
nx = selmon->w.x + selmon->w.width - grabc->geom.width;
|
||||||
|
if (abs(selmon->w.y - ny) < snap)
|
||||||
|
ny = selmon->w.y;
|
||||||
|
else if (abs((selmon->w.y + selmon->w.height) - (ny + grabc->geom.height)) < snap)
|
||||||
|
ny = selmon->w.y + selmon->w.height - grabc->geom.height;
|
||||||
|
resize(grabc, (struct wlr_box){.x = nx, .y = ny,
|
||||||
.width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
.width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
||||||
return;
|
return;
|
||||||
} else if (cursor_mode == CurResize) {
|
} else if (cursor_mode == CurResize) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user