dwm-meillo
changeset 29:8ad86d0a6a53
added gravity stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Wed, 12 Jul 2006 17:17:15 +0200 |
parents | 3dceb132082d |
children | 2e0fb4130bfb |
files | client.c event.c kb.c wm.h |
diffstat | 4 files changed, 76 insertions(+), 7 deletions(-) [+] |
line diff
1.1 --- a/client.c Wed Jul 12 16:40:37 2006 +0200 1.2 +++ b/client.c Wed Jul 12 17:17:15 2006 +0200 1.3 @@ -18,9 +18,10 @@ 1.4 return; 1.5 stack->x = sx; 1.6 stack->y = bh; 1.7 - stack->w = sw - 2; 1.8 - stack->h = sh - bh - 2; 1.9 + stack->w = sw - 2 * stack->border; 1.10 + stack->h = sh - bh - 2 * stack->border; 1.11 resize(stack); 1.12 + discard_events(EnterWindowMask); 1.13 } 1.14 1.15 void 1.16 @@ -43,8 +44,8 @@ 1.17 else 1.18 cols = rows; 1.19 1.20 - gw = (sw - 1) / cols; 1.21 - gh = (sh - bh - 1) / rows; 1.22 + gw = (sw - 2 * c->border) / cols; 1.23 + gh = (sh - bh - 2 * c->border) / rows; 1.24 1.25 for(i = j = 0, c = clients; c; c = c->next) { 1.26 c->x = i * gw; 1.27 @@ -57,6 +58,7 @@ 1.28 i = 0; 1.29 } 1.30 } 1.31 + discard_events(EnterWindowMask); 1.32 } 1.33 1.34 void 1.35 @@ -161,6 +163,10 @@ 1.36 } 1.37 else 1.38 c->minw = c->minh = 0; 1.39 + if(c->flags & PWinGravity) 1.40 + c->grav = size.win_gravity; 1.41 + else 1.42 + c->grav = NorthWestGravity; 1.43 } 1.44 1.45 void 1.46 @@ -213,6 +219,7 @@ 1.47 c->tw = c->w = wa->width; 1.48 c->h = wa->height; 1.49 c->th = bh; 1.50 + c->border = 1; 1.51 update_size(c); 1.52 XSetWindowBorderWidth(dpy, c->win, 1); 1.53 XSetWindowBorder(dpy, c->win, brush.border); 1.54 @@ -247,6 +254,61 @@ 1.55 } 1.56 1.57 void 1.58 +gravitate(Client *c, Bool invert) 1.59 +{ 1.60 + int dx = 0, dy = 0; 1.61 + 1.62 + switch(c->grav) { 1.63 + case StaticGravity: 1.64 + case NorthWestGravity: 1.65 + case NorthGravity: 1.66 + case NorthEastGravity: 1.67 + dy = c->border; 1.68 + break; 1.69 + case EastGravity: 1.70 + case CenterGravity: 1.71 + case WestGravity: 1.72 + dy = -(c->h / 2) + c->border; 1.73 + break; 1.74 + case SouthEastGravity: 1.75 + case SouthGravity: 1.76 + case SouthWestGravity: 1.77 + dy = -c->h; 1.78 + break; 1.79 + default: 1.80 + break; 1.81 + } 1.82 + 1.83 + switch (c->grav) { 1.84 + case StaticGravity: 1.85 + case NorthWestGravity: 1.86 + case WestGravity: 1.87 + case SouthWestGravity: 1.88 + dx = c->border; 1.89 + break; 1.90 + case NorthGravity: 1.91 + case CenterGravity: 1.92 + case SouthGravity: 1.93 + dx = -(c->w / 2) + c->border; 1.94 + break; 1.95 + case NorthEastGravity: 1.96 + case EastGravity: 1.97 + case SouthEastGravity: 1.98 + dx = -(c->w + c->border); 1.99 + break; 1.100 + default: 1.101 + break; 1.102 + } 1.103 + 1.104 + if(invert) { 1.105 + dx = -dx; 1.106 + dy = -dy; 1.107 + } 1.108 + c->x += dx; 1.109 + c->y += dy; 1.110 +} 1.111 + 1.112 +void 1.113 resize(Client *c) 1.114 { 1.115 XConfigureEvent e; 1.116 @@ -260,7 +322,7 @@ 1.117 e.y = c->y; 1.118 e.width = c->w; 1.119 e.height = c->h; 1.120 - e.border_width = 0; 1.121 + e.border_width = c->border; 1.122 e.above = None; 1.123 e.override_redirect = False; 1.124 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
2.1 --- a/event.c Wed Jul 12 16:40:37 2006 +0200 2.2 +++ b/event.c Wed Jul 12 17:17:15 2006 +0200 2.3 @@ -77,6 +77,7 @@ 2.4 2.5 ev->value_mask &= ~CWSibling; 2.6 if((c = getclient(ev->window))) { 2.7 + gravitate(c, True); 2.8 if(ev->value_mask & CWX) 2.9 c->x = ev->x; 2.10 if(ev->value_mask & CWY) 2.11 @@ -85,6 +86,9 @@ 2.12 c->w = ev->width; 2.13 if(ev->value_mask & CWHeight) 2.14 c->h = ev->height; 2.15 + if(ev->value_mask & CWBorderWidth) 2.16 + c->border = ev->border_width; 2.17 + gravitate(c, False); 2.18 } 2.19 2.20 wc.x = ev->x;
3.1 --- a/kb.c Wed Jul 12 16:40:37 2006 +0200 3.2 +++ b/kb.c Wed Jul 12 17:17:15 2006 +0200 3.3 @@ -8,7 +8,7 @@ 3.4 #include <X11/keysym.h> 3.5 3.6 static const char *term[] = { 3.7 - "xterm", "-bg", "black", "-fg", "white", "-fn", 3.8 + "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", 3.9 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0 3.10 }; 3.11
4.1 --- a/wm.h Wed Jul 12 16:40:37 2006 +0200 4.2 +++ b/wm.h Wed Jul 12 17:17:15 2006 +0200 4.3 @@ -27,6 +27,8 @@ 4.4 int x, y, w, h; 4.5 int tx, ty, tw, th; 4.6 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 4.7 + int grav; 4.8 + unsigned int border; 4.9 long flags; 4.10 Window win; 4.11 Window trans; 4.12 @@ -73,7 +75,8 @@ 4.13 extern void kill(void *aux); 4.14 extern void sel(void *aux); 4.15 extern void max(void *aux); 4.16 -extern void arrange(); 4.17 +extern void arrange(void *aux); 4.18 +extern void gravitate(Client *c, Bool invert); 4.19 4.20 /* event.c */ 4.21 extern void discard_events(long even_mask);