From b6614261ea48c9711cefd79601e09fa764ee3075 Mon Sep 17 00:00:00 2001 From: "arg@mig29" Date: Mon, 30 Oct 2006 11:58:05 +0100 Subject: [PATCH] added screen-border snapping in floating mode, feels quite well --- config.arg.h | 1 + config.default.h | 1 + event.c | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/config.arg.h b/config.arg.h index 84f37a7..30bfaf9 100644 --- a/config.arg.h +++ b/config.arg.h @@ -19,6 +19,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL }; #define MASTER 600 /* per thousand */ #define MODKEY Mod1Mask +#define SNAP 20 /* pixel */ #define KEYS \ static Key key[] = { \ diff --git a/config.default.h b/config.default.h index fb452f2..0a595a2 100644 --- a/config.default.h +++ b/config.default.h @@ -19,6 +19,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL }; #define MASTER 600 /* per thousand */ #define MODKEY Mod1Mask +#define SNAP 20 /* pixel */ #define KEYS \ static Key key[] = { \ diff --git a/event.c b/event.c index bf88819..d0f446f 100644 --- a/event.c +++ b/event.c @@ -48,6 +48,14 @@ movemouse(Client *c) { XSync(dpy, False); c->x = ocx + (ev.xmotion.x - x1); c->y = ocy + (ev.xmotion.y - y1); + if(abs(c->x) < sx + SNAP) + c->x = sx; + if(abs(c->y) < sy + bh + SNAP) + c->y = sy + bh; + if(abs(c->x + c->w) > sx + sw - SNAP) + c->x = sw - c->w - 2 * BORDERPX; + if(abs(c->y + c->h) > sy + sh - SNAP) + c->y = sh - c->h - 2 * BORDERPX; resize(c, False, TopLeft); break; } -- 1.7.10.4