aboutsummaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c115
1 files changed, 26 insertions, 89 deletions
diff --git a/dwm.c b/dwm.c
index a1da650..80fc7b4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1342,81 +1342,32 @@ movemouse(const Arg *arg)
void
moveresize(const Arg *arg) {
/* only floating windows can be moved */
- Client *c;
- c = selmon->sel;
- int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh;
- char xAbs, yAbs, wAbs, hAbs;
- int msx, msy, dx, dy, nmx, nmy;
- unsigned int dui;
- Window dummy;
+ Client *c = selmon->sel;
+ int x, y, w, h, nx, ny, nw, nh;
if (!c || !arg)
return;
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
- return;
- if (sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y, &yAbs, &w, &wAbs, &h, &hAbs) != 8)
+ togglefloating(NULL);
+ if (sscanf((char *)arg->v, "%d %d %d %d", &x, &y, &w, &h) != 4)
return;
- /* compute new window position; prevent window from be positioned outside the current monitor */
nw = c->w + w;
- if (wAbs == 'W')
- nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * c->bw;
-
nh = c->h + h;
- if (hAbs == 'H')
- nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * c->bw;
-
nx = c->x + x;
- if (xAbs == 'X') {
- if (x < selmon->mx)
- nx = selmon->mx;
- else if (x > selmon->mx + selmon->mw)
- nx = selmon->mx + selmon->mw - nw - 2 * c->bw;
- else
- nx = x;
- }
-
ny = c->y + y;
- if (yAbs == 'Y') {
- if (y < selmon->my)
- ny = selmon->my;
- else if (y > selmon->my + selmon->mh)
- ny = selmon->my + selmon->mh - nh - 2 * c->bw;
- else
- ny = y;
- }
-
- ox = c->x;
- oy = c->y;
- ow = c->w;
- oh = c->h;
XRaiseWindow(dpy, c->win);
- Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy, &dx, &dy, &dui);
resize(c, nx, ny, nw, nh, True);
-
- /* move cursor along with the window to avoid problems caused by the sloppy focus */
- if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + oh) >= msy)
- {
- nmx = c->x - ox + c->w - ow;
- nmy = c->y - oy + c->h - oh;
- /* make sure the cursor stays inside the window */
- if ((msx + nmx) > c->x && (msy + nmy) > c->y)
- XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
- }
}
void
moveresizeedge(const Arg *arg) {
/* move or resize floating window to edge of screen */
- Client *c;
- c = selmon->sel;
+ Client *c = selmon->sel;
char e;
- int nx, ny, nw, nh, ox, oy, ow, oh, bp;
- int msx, msy, dx, dy, nmx, nmy;
+ int nx, ny, nw, nh, bp;
int starty;
- unsigned int dui;
- Window dummy;
nx = c->x;
ny = c->y;
@@ -1429,24 +1380,25 @@ moveresizeedge(const Arg *arg) {
if (!c || !arg)
return;
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
- return;
+ togglefloating(NULL);
if(sscanf((char *)arg->v, "%c", &e) != 1)
return;
- if(e == 't')
+ switch(e) {
+ case 't':
ny = starty;
-
- if(e == 'b')
+ break;
+ case 'b':
ny = c->h > selmon->mh - 2 * c->bw ? c->h - bp : selmon->mh - c->h - 2 * c->bw - bp;
-
- if(e == 'l')
+ break;
+ case 'l':
nx = selmon->mx;
-
- if(e == 'r')
+ break;
+ case 'r':
nx = c->w > selmon->mw - 2 * c->bw ? selmon->mx + c->w : selmon->mx + selmon->mw - c->w - 2 * c->bw;
-
- if(e == 'T') {
- /* if you click to resize again, it will return to old size/position */
+ break;
+ /* if you click to resize again, it will return to old size/position */
+ case 'T':
if(c->h + starty == c->oldh + c->oldy) {
nh = c->oldh;
ny = c->oldy;
@@ -1454,12 +1406,11 @@ moveresizeedge(const Arg *arg) {
nh = c->h + c->y - starty;
ny = starty;
}
- }
-
- if(e == 'B')
+ break;
+ case 'B':
nh = c->h + c->y + 2 * c->bw + bp == selmon->mh ? c->oldh : selmon->mh - c->y - 2 * c->bw - bp;
-
- if(e == 'L') {
+ break;
+ case 'L':
if(selmon->mx + c->w == c->oldw + c->oldx) {
nw = c->oldw;
nx = c->oldx;
@@ -1467,28 +1418,14 @@ moveresizeedge(const Arg *arg) {
nw = c->w + c->x - selmon->mx;
nx = selmon->mx;
}
- }
-
- if(e == 'R')
+ break;
+ case 'R':
nw = c->w + c->x + 2 * c->bw == selmon->mx + selmon->mw ? c->oldw : selmon->mx + selmon->mw - c->x - 2 * c->bw;
-
- ox = c->x;
- oy = c->y;
- ow = c->w;
- oh = c->h;
+ break;
+ }
XRaiseWindow(dpy, c->win);
- Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy, &dx, &dy, &dui);
resize(c, nx, ny, nw, nh, True);
-
- /* move cursor along with the window to avoid problems caused by the sloppy focus */
- if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + oh) >= msy) {
- nmx = c->x - ox + c->w - ow;
- nmy = c->y - oy + c->h - oh;
- /* make sure the cursor stays inside the window */
- if ((msx + nmx) > c->x && (msy + nmy) > c->y)
- XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
- }
}
void