applied Sanders all5.patch (thanks for your weekend session, Sander!)
This commit is contained in:
parent
201c56f6d3
commit
b233089815
68
client.c
68
client.c
|
@ -79,19 +79,14 @@ configure(Client *c) {
|
|||
|
||||
void
|
||||
focus(Client *c) {
|
||||
Client *old;
|
||||
Client *old = sel;
|
||||
|
||||
if(!issel || (c && !isvisible(c)))
|
||||
return;
|
||||
if(!sel)
|
||||
sel = c;
|
||||
else if(sel != c) {
|
||||
old = sel;
|
||||
sel = c;
|
||||
if(old) {
|
||||
grabbuttons(old, False);
|
||||
XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
|
||||
}
|
||||
|
||||
if(old && old != c) {
|
||||
grabbuttons(old, False);
|
||||
XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
|
||||
}
|
||||
if(c) {
|
||||
detachstack(c);
|
||||
|
@ -103,6 +98,7 @@ focus(Client *c) {
|
|||
}
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
sel = c;
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
|
@ -134,20 +130,27 @@ manage(Window w, XWindowAttributes *wa) {
|
|||
c = emallocz(sizeof(Client));
|
||||
c->tags = emallocz(ntags * sizeof(Bool));
|
||||
c->win = w;
|
||||
c->border = 0;
|
||||
c->x = wa->x;
|
||||
c->y = wa->y;
|
||||
c->w = wa->width;
|
||||
c->h = wa->height;
|
||||
updatesizehints(c);
|
||||
if(c->x + c->w + 2 * BORDERPX > sw)
|
||||
c->x = sw - c->w - 2 * BORDERPX;
|
||||
if(c->x < sx)
|
||||
if(c->w == sw && c->h == sh) {
|
||||
c->border = 0;
|
||||
c->x = sx;
|
||||
if(c->y + c->h + 2 * BORDERPX > sh)
|
||||
c->y = sh - c->h - 2 * BORDERPX;
|
||||
if(c->h != sh && c->y < bh)
|
||||
c->y = bh;
|
||||
c->y = sy;
|
||||
}
|
||||
else {
|
||||
c->border = BORDERPX;
|
||||
if(c->x < wax)
|
||||
c->x = wax;
|
||||
if(c->y < way)
|
||||
c->y = way;
|
||||
if(c->x + c->w + 2 * c->border > wax + waw)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(c->y + c->h + 2 * c->border > way + wah)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
}
|
||||
updatesizehints(c);
|
||||
c->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
|
@ -170,9 +173,7 @@ manage(Window w, XWindowAttributes *wa) {
|
|||
}
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
int bottom = c->y + c->h;
|
||||
int right = c->x + c->w;
|
||||
resize(Client *c, Bool sizehints) {
|
||||
XWindowChanges wc;
|
||||
|
||||
if(sizehints) {
|
||||
|
@ -189,27 +190,24 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
|||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
}
|
||||
if(sticky == TopRight || sticky == BotRight)
|
||||
c->x = right - c->w;
|
||||
if(sticky == BotLeft || sticky == BotRight)
|
||||
c->y = bottom - c->h;
|
||||
if(c->w == sw && c->h == sh)
|
||||
c->border = 0;
|
||||
else
|
||||
c->border = BORDERPX;
|
||||
/* offscreen appearance fixes */
|
||||
if(c->x + c->w < sx)
|
||||
if(c->x + c->w + 2 * c->border < sx)
|
||||
c->x = sx;
|
||||
if(c->y + c->h < bh)
|
||||
c->y = bh;
|
||||
if(c->y + c->h + 2 * c->border < sy)
|
||||
c->y = sy;
|
||||
if(c->x > sw)
|
||||
c->x = sw - c->w;
|
||||
c->x = sw - c->w - 2 * c->border;
|
||||
if(c->y > sh)
|
||||
c->y = sh - c->h;
|
||||
c->y = sh - c->h - 2 * c->border;
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
wc.height = c->h;
|
||||
if(c->w == sw && c->h == sh)
|
||||
wc.border_width = 0;
|
||||
else
|
||||
wc.border_width = BORDERPX;
|
||||
wc.border_width = c->border;
|
||||
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
|
|
6
dwm.h
6
dwm.h
|
@ -44,10 +44,6 @@ enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
|
|||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef enum {
|
||||
TopLeft, TopRight, BotLeft, BotRight
|
||||
} Corner; /* window corners */
|
||||
|
||||
typedef union {
|
||||
const char *cmd;
|
||||
int i;
|
||||
|
@ -110,7 +106,7 @@ extern void focus(Client *c); /* focus c, c may be NULL */
|
|||
extern Client *getclient(Window w); /* return client of w */
|
||||
extern void killclient(Arg *arg); /* kill c nicely */
|
||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
|
||||
extern void resize(Client *c, Bool sizehints); /* resize c*/
|
||||
extern void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
extern void updatetitle(Client *c); /* update the name of c */
|
||||
extern void unmanage(Client *c); /* destroy c */
|
||||
|
|
50
event.c
50
event.c
|
@ -35,14 +35,16 @@ movemouse(Client *c) {
|
|||
c->ismax = False;
|
||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
|
@ -50,13 +52,13 @@ movemouse(Client *c) {
|
|||
c->y = ocy + (ev.xmotion.y - y1);
|
||||
if(abs(wax + c->x) < SNAP)
|
||||
c->x = wax;
|
||||
else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * BORDERPX;
|
||||
else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(abs(way - c->y) < SNAP)
|
||||
c->y = way;
|
||||
else if(abs((way + wah) - (c->y + c->h)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * BORDERPX;
|
||||
resize(c, False, TopLeft);
|
||||
else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
resize(c, False);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +68,6 @@ static void
|
|||
resizemouse(Client *c) {
|
||||
int ocx, ocy;
|
||||
int nw, nh;
|
||||
Corner sticky;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
|
@ -75,30 +76,26 @@ resizemouse(Client *c) {
|
|||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
c->ismax = False;
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
||||
switch(ev.type) {
|
||||
case ButtonRelease:
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
if((nw = abs(ocx - ev.xmotion.x)))
|
||||
c->w = nw;
|
||||
if((nh = abs(ocy - ev.xmotion.y)))
|
||||
c->h = nh;
|
||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||
if(ocx <= ev.xmotion.x)
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
||||
else
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
||||
resize(c, True, sticky);
|
||||
nw = ev.xmotion.x - ocx - 2 * c->border + 1;
|
||||
c->w = nw > 0 ? nw : 1;
|
||||
nh = ev.xmotion.y - ocy - 2 * c->border + 1;
|
||||
c->h = nh > 0 ? nh : 1;
|
||||
resize(c, True);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +191,7 @@ configurerequest(XEvent *e) {
|
|||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat) {
|
||||
resize(c, False, TopLeft);
|
||||
resize(c, False);
|
||||
if(!isvisible(c))
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
|
@ -234,7 +231,8 @@ enternotify(XEvent *e) {
|
|||
focus(c);
|
||||
else if(ev->window == root) {
|
||||
issel = True;
|
||||
focus(sel);
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
main.c
2
main.c
|
@ -41,7 +41,7 @@ static void
|
|||
cleanup(void) {
|
||||
close(STDIN_FILENO);
|
||||
while(stack) {
|
||||
resize(stack, True, TopLeft);
|
||||
resize(stack, True);
|
||||
unmanage(stack);
|
||||
}
|
||||
if(dc.font.set)
|
||||
|
|
8
view.c
8
view.c
|
@ -31,7 +31,7 @@ togglemax(Client *c) {
|
|||
c->w = c->rw;
|
||||
c->h = c->rh;
|
||||
}
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ dofloat(void) {
|
|||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
}
|
||||
else
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
|
@ -84,7 +84,7 @@ dotile(void) {
|
|||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isfloat) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
continue;
|
||||
}
|
||||
c->ismax = False;
|
||||
|
@ -105,7 +105,7 @@ dotile(void) {
|
|||
else /* fallback if th < bh */
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
resize(c, False);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue