summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2016-10-03 13:52:19 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2016-10-03 13:52:19 +0000
commit6ef44e3bea4c8facd6af4a3d363c273d6f1947de (patch)
tree6038b029b4599bb4bdac554c21ae5726e7df39a8 /app
parentab47de82afc75c6ebaf4bc43fabf2c4921adad83 (diff)
For both kb and mouse move, it is possible to grab a client and move it
completely off the screen/region; instead, if the pointer is outside of the client bounds, warp the pointer to the closest edge before moving.
Diffstat (limited to 'app')
-rw-r--r--app/cwm/kbfunc.c16
-rw-r--r--app/cwm/mousefunc.c20
2 files changed, 29 insertions, 7 deletions
diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c
index f30f809ff..fd7b096d4 100644
--- a/app/cwm/kbfunc.c
+++ b/app/cwm/kbfunc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: kbfunc.c,v 1.128 2016/10/03 13:41:30 okan Exp $
+ * $OpenBSD: kbfunc.c,v 1.129 2016/10/03 13:52:17 okan Exp $
*/
#include <sys/types.h>
@@ -95,12 +95,24 @@ kbfunc_client_move(struct client_ctx *cc, union arg *arg)
{
struct screen_ctx *sc = cc->sc;
struct geom area;
- int x, y;
+ int x, y, px, py;
unsigned int mx = 0, my = 0;
if (cc->flags & CLIENT_FREEZE)
return;
+ xu_ptr_getpos(cc->win, &px, &py);
+ if (px < 0)
+ px = 0;
+ else if (px > cc->geom.w)
+ px = cc->geom.w;
+ if (py < 0)
+ py = 0;
+ else if (py > cc->geom.h)
+ py = cc->geom.h;
+
+ xu_ptr_setpos(cc->win, px, py);
+
kbfunc_amount(arg->i, Conf.mamount, &mx, &my);
cc->geom.x += mx;
diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c
index 24f0e3e7a..bc451e38e 100644
--- a/app/cwm/mousefunc.c
+++ b/app/cwm/mousefunc.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: mousefunc.c,v 1.111 2016/09/30 18:28:06 okan Exp $
+ * $OpenBSD: mousefunc.c,v 1.112 2016/10/03 13:52:18 okan Exp $
*/
#include <sys/types.h>
@@ -45,13 +45,13 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg)
client_raise(cc);
client_ptrsave(cc);
+ xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h);
+
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_RESIZE],
CurrentTime) != GrabSuccess)
return;
- xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h);
-
for (;;) {
XWindowEvent(X_Dpy, cc->win, MOUSEMASK, &ev);
@@ -101,13 +101,23 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
if (cc->flags & CLIENT_FREEZE)
return;
+ xu_ptr_getpos(cc->win, &px, &py);
+ if (px < 0)
+ px = 0;
+ else if (px > cc->geom.w)
+ px = cc->geom.w;
+ if (py < 0)
+ py = 0;
+ else if (py > cc->geom.h)
+ py = cc->geom.h;
+
+ xu_ptr_setpos(cc->win, px, py);
+
if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK,
GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_MOVE],
CurrentTime) != GrabSuccess)
return;
- xu_ptr_getpos(cc->win, &px, &py);
-
for (;;) {
XWindowEvent(X_Dpy, cc->win, MOUSEMASK, &ev);