aewl
changeset 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 |
files | client.c event.c wm.c |
diffstat | 3 files changed, 58 insertions(+), 20 deletions(-) [+] |
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 }
2.1 --- a/event.c Tue Jul 11 22:49:09 2006 +0200 2.2 +++ b/event.c Tue Jul 11 23:18:30 2006 +0200 2.3 @@ -143,9 +143,12 @@ 2.4 expose(XEvent *e) 2.5 { 2.6 XExposeEvent *ev = &e->xexpose; 2.7 + Client *c; 2.8 2.9 if(ev->count == 0) { 2.10 - if(ev->window == barwin) 2.11 + if((c = getclient(ev->window))) 2.12 + draw_client(c); 2.13 + else if(ev->window == barwin) 2.14 draw_bar(); 2.15 } 2.16 }
3.1 --- a/wm.c Tue Jul 11 22:49:09 2006 +0200 3.2 +++ b/wm.c Tue Jul 11 23:18:30 2006 +0200 3.3 @@ -245,10 +245,6 @@ 3.4 3.5 update_keys(); 3.6 3.7 - brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height, 3.8 - DefaultDepth(dpy, screen)); 3.9 - brush.gc = XCreateGC(dpy, root, 0, 0); 3.10 - 3.11 /* style */ 3.12 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); 3.13 loadfont(dpy, &brush.font, FONT); 3.14 @@ -266,6 +262,11 @@ 3.15 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 3.16 XDefineCursor(dpy, barwin, cursor[CurNormal]); 3.17 XMapRaised(dpy, barwin); 3.18 + 3.19 + brush.drawable = XCreatePixmap(dpy, root, rect.width, barrect.height, 3.20 + DefaultDepth(dpy, screen)); 3.21 + brush.gc = XCreateGC(dpy, root, 0, 0); 3.22 + 3.23 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); 3.24 draw_bar(); 3.25