Mercurial > aewl
comparison 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 |
comparison
equal
deleted
inserted
replaced
20:4560e0882c1d | 21:3ef108a5ca0a |
---|---|
35 strncpy(c->name, *list, sizeof(c->name)); | 35 strncpy(c->name, *list, sizeof(c->name)); |
36 XFreeStringList(list); | 36 XFreeStringList(list); |
37 } | 37 } |
38 } | 38 } |
39 XFree(name.value); | 39 XFree(name.value); |
40 if(c == stack) | |
41 draw_bar(); | |
42 else | |
43 draw_client(c); | |
44 } | 40 } |
45 | 41 |
46 void | 42 void |
47 update_size(Client *c) | 43 update_size(Client *c) |
48 { | 44 { |
49 XSizeHints size; | 45 XSizeHints size; |
50 long msize; | 46 long msize; |
51 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) | 47 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) |
52 size.flags = PSize; | 48 size.flags = PSize; |
53 c->flags = size.flags; | 49 c->flags = size.flags; |
54 c->basew = size.base_width; | 50 if(c->flags & PBaseSize) { |
55 c->baseh = size.base_height; | 51 c->basew = size.base_width; |
56 c->incw = size.width_inc; | 52 c->baseh = size.base_height; |
57 c->inch = size.height_inc; | 53 } |
58 c->maxw = size.max_width; | 54 else |
59 c->maxh = size.max_height; | 55 c->basew = c->baseh = 0; |
60 c->minw = size.min_width; | 56 if(c->flags & PResizeInc) { |
61 c->minh = size.min_height; | 57 c->incw = size.width_inc; |
58 c->inch = size.height_inc; | |
59 } | |
60 else | |
61 c->incw = c->inch = 0; | |
62 if(c->flags & PMaxSize) { | |
63 c->maxw = size.max_width; | |
64 c->maxh = size.max_height; | |
65 } | |
66 else | |
67 c->maxw = c->maxh = 0; | |
68 if(c->flags & PMinSize) { | |
69 c->minw = size.min_width; | |
70 c->minh = size.min_height; | |
71 } | |
72 else | |
73 c->minw = c->minh = 0; | |
62 } | 74 } |
63 | 75 |
64 void | 76 void |
65 focus(Client *c) | 77 focus(Client *c) |
66 { | 78 { |
67 Client **l; | 79 Client **l, *old; |
80 | |
81 old = stack; | |
68 for(l=&stack; *l && *l != c; l=&(*l)->snext); | 82 for(l=&stack; *l && *l != c; l=&(*l)->snext); |
69 eassert(*l == c); | 83 eassert(*l == c); |
70 *l = c->snext; | 84 *l = c->snext; |
71 c->snext = stack; | 85 c->snext = stack; |
72 stack = c; | 86 stack = c; |
73 XRaiseWindow(dpy, c->win); | 87 XRaiseWindow(dpy, c->win); |
88 XRaiseWindow(dpy, c->title); | |
74 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); | 89 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
90 if(old && old != c) { | |
91 XMapWindow(dpy, old->title); | |
92 draw_client(old); | |
93 } | |
94 XUnmapWindow(dpy, c->title); | |
95 draw_bar(); | |
75 XFlush(dpy); | 96 XFlush(dpy); |
76 } | 97 } |
77 | 98 |
78 void | 99 void |
79 manage(Window w, XWindowAttributes *wa) | 100 manage(Window w, XWindowAttributes *wa) |
89 c->h = wa->height; | 110 c->h = wa->height; |
90 update_size(c); | 111 update_size(c); |
91 XSetWindowBorderWidth(dpy, c->win, 1); | 112 XSetWindowBorderWidth(dpy, c->win, 1); |
92 XSelectInput(dpy, c->win, CLIENT_MASK); | 113 XSelectInput(dpy, c->win, CLIENT_MASK); |
93 XGetTransientForHint(dpy, c->win, &c->trans); | 114 XGetTransientForHint(dpy, c->win, &c->trans); |
94 update_name(c); | |
95 twa.override_redirect = 1; | 115 twa.override_redirect = 1; |
96 twa.background_pixmap = ParentRelative; | 116 twa.background_pixmap = ParentRelative; |
97 twa.event_mask = ExposureMask; | 117 twa.event_mask = ExposureMask; |
98 | 118 |
99 c->title = XCreateWindow(dpy, root, c->x, c->y, c->w, barrect.height, | 119 c->title = XCreateWindow(dpy, root, c->x, c->y, c->w, barrect.height, |
100 0, DefaultDepth(dpy, screen), CopyFromParent, | 120 0, DefaultDepth(dpy, screen), CopyFromParent, |
101 DefaultVisual(dpy, screen), | 121 DefaultVisual(dpy, screen), |
102 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); | 122 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
123 update_name(c); | |
103 | 124 |
104 for(l=&clients; *l; l=&(*l)->next); | 125 for(l=&clients; *l; l=&(*l)->next); |
105 c->next = *l; /* *l == nil */ | 126 c->next = *l; /* *l == nil */ |
106 *l = c; | 127 *l = c; |
107 c->snext = stack; | 128 c->snext = stack; |
108 stack = c; | 129 stack = c; |
109 XMapWindow(dpy, c->win); | 130 XMapWindow(dpy, c->win); |
131 XMapWindow(dpy, c->title); | |
110 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, | 132 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, |
111 GrabModeAsync, GrabModeSync, None, None); | 133 GrabModeAsync, GrabModeSync, None, None); |
112 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, | 134 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
113 GrabModeAsync, GrabModeSync, None, None); | 135 GrabModeAsync, GrabModeSync, None, None); |
114 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, | 136 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
115 GrabModeAsync, GrabModeSync, None, None); | 137 GrabModeAsync, GrabModeSync, None, None); |
138 resize(c); | |
116 focus(c); | 139 focus(c); |
117 } | 140 } |
118 | 141 |
119 void | 142 void |
120 resize(Client *c) | 143 resize(Client *c) |
121 { | 144 { |
122 XConfigureEvent e; | 145 XConfigureEvent e; |
123 | 146 |
124 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); | 147 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
148 XMoveResizeWindow(dpy, c->title, c->x + c->w / 3, c->y, 2 * c->w / 3, barrect.height); | |
125 e.type = ConfigureNotify; | 149 e.type = ConfigureNotify; |
126 e.event = c->win; | 150 e.event = c->win; |
127 e.window = c->win; | 151 e.window = c->win; |
128 e.x = c->x; | 152 e.x = c->x; |
129 e.y = c->y; | 153 e.y = c->y; |
184 } | 208 } |
185 | 209 |
186 void | 210 void |
187 draw_client(Client *c) | 211 draw_client(Client *c) |
188 { | 212 { |
189 | 213 if(!c) |
190 | 214 return; |
191 | 215 if(c == stack) |
192 } | 216 draw_bar(); |
217 | |
218 brush.rect.x = brush.rect.y = 0; | |
219 brush.rect.width = 2 * c->w / 3; | |
220 brush.rect.height = barrect.height; | |
221 | |
222 draw(dpy, &brush, True, c->name); | |
223 XCopyArea(dpy, brush.drawable, c->title, brush.gc, 0, 0, | |
224 brush.rect.width, brush.rect.height, 0, 0); | |
225 XFlush(dpy); | |
226 } |