dwm-meillo
diff client.c @ 21:3ef108a5ca0a
implemented draw_client stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 23:18:30 +0200 |
parents | 4560e0882c1d |
children | bd3a44353916 |
line diff
1.1 --- a/client.c Tue Jul 11 22:49:09 2006 +0200 1.2 +++ b/client.c Tue Jul 11 23:18:30 2006 +0200 1.3 @@ -37,10 +37,6 @@ 1.4 } 1.5 } 1.6 XFree(name.value); 1.7 - if(c == stack) 1.8 - draw_bar(); 1.9 - else 1.10 - draw_client(c); 1.11 } 1.12 1.13 void 1.14 @@ -51,27 +47,52 @@ 1.15 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) 1.16 size.flags = PSize; 1.17 c->flags = size.flags; 1.18 - c->basew = size.base_width; 1.19 - c->baseh = size.base_height; 1.20 - c->incw = size.width_inc; 1.21 - c->inch = size.height_inc; 1.22 - c->maxw = size.max_width; 1.23 - c->maxh = size.max_height; 1.24 - c->minw = size.min_width; 1.25 - c->minh = size.min_height; 1.26 + if(c->flags & PBaseSize) { 1.27 + c->basew = size.base_width; 1.28 + c->baseh = size.base_height; 1.29 + } 1.30 + else 1.31 + c->basew = c->baseh = 0; 1.32 + if(c->flags & PResizeInc) { 1.33 + c->incw = size.width_inc; 1.34 + c->inch = size.height_inc; 1.35 + } 1.36 + else 1.37 + c->incw = c->inch = 0; 1.38 + if(c->flags & PMaxSize) { 1.39 + c->maxw = size.max_width; 1.40 + c->maxh = size.max_height; 1.41 + } 1.42 + else 1.43 + c->maxw = c->maxh = 0; 1.44 + if(c->flags & PMinSize) { 1.45 + c->minw = size.min_width; 1.46 + c->minh = size.min_height; 1.47 + } 1.48 + else 1.49 + c->minw = c->minh = 0; 1.50 } 1.51 1.52 void 1.53 focus(Client *c) 1.54 { 1.55 - Client **l; 1.56 + Client **l, *old; 1.57 + 1.58 + old = stack; 1.59 for(l=&stack; *l && *l != c; l=&(*l)->snext); 1.60 eassert(*l == c); 1.61 *l = c->snext; 1.62 c->snext = stack; 1.63 stack = c; 1.64 XRaiseWindow(dpy, c->win); 1.65 + XRaiseWindow(dpy, c->title); 1.66 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.67 + if(old && old != c) { 1.68 + XMapWindow(dpy, old->title); 1.69 + draw_client(old); 1.70 + } 1.71 + XUnmapWindow(dpy, c->title); 1.72 + draw_bar(); 1.73 XFlush(dpy); 1.74 } 1.75 1.76 @@ -91,7 +112,6 @@ 1.77 XSetWindowBorderWidth(dpy, c->win, 1); 1.78 XSelectInput(dpy, c->win, CLIENT_MASK); 1.79 XGetTransientForHint(dpy, c->win, &c->trans); 1.80 - update_name(c); 1.81 twa.override_redirect = 1; 1.82 twa.background_pixmap = ParentRelative; 1.83 twa.event_mask = ExposureMask; 1.84 @@ -100,6 +120,7 @@ 1.85 0, DefaultDepth(dpy, screen), CopyFromParent, 1.86 DefaultVisual(dpy, screen), 1.87 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 1.88 + update_name(c); 1.89 1.90 for(l=&clients; *l; l=&(*l)->next); 1.91 c->next = *l; /* *l == nil */ 1.92 @@ -107,12 +128,14 @@ 1.93 c->snext = stack; 1.94 stack = c; 1.95 XMapWindow(dpy, c->win); 1.96 + XMapWindow(dpy, c->title); 1.97 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, 1.98 GrabModeAsync, GrabModeSync, None, None); 1.99 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, 1.100 GrabModeAsync, GrabModeSync, None, None); 1.101 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, 1.102 GrabModeAsync, GrabModeSync, None, None); 1.103 + resize(c); 1.104 focus(c); 1.105 } 1.106 1.107 @@ -122,6 +145,7 @@ 1.108 XConfigureEvent e; 1.109 1.110 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); 1.111 + XMoveResizeWindow(dpy, c->title, c->x + c->w / 3, c->y, 2 * c->w / 3, barrect.height); 1.112 e.type = ConfigureNotify; 1.113 e.event = c->win; 1.114 e.window = c->win; 1.115 @@ -186,7 +210,17 @@ 1.116 void 1.117 draw_client(Client *c) 1.118 { 1.119 - 1.120 + if(!c) 1.121 + return; 1.122 + if(c == stack) 1.123 + draw_bar(); 1.124 1.125 + brush.rect.x = brush.rect.y = 0; 1.126 + brush.rect.width = 2 * c->w / 3; 1.127 + brush.rect.height = barrect.height; 1.128 1.129 + draw(dpy, &brush, True, c->name); 1.130 + XCopyArea(dpy, brush.drawable, c->title, brush.gc, 0, 0, 1.131 + brush.rect.width, brush.rect.height, 0, 0); 1.132 + XFlush(dpy); 1.133 }