summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 23:18:30 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 23:18:30 +0200
commit83d23908d3438d7f1f62533a7c8d96fc1019df55 (patch)
tree5e6cead0c83f19f95157cd9fed95aa4ccb714c5f
parentmade code more readable (diff)
downloaddwm-83d23908d3438d7f1f62533a7c8d96fc1019df55.tar.gz
dwm-83d23908d3438d7f1f62533a7c8d96fc1019df55.zip
implemented draw_client stuff
-rw-r--r--client.c64
-rw-r--r--event.c5
-rw-r--r--wm.c9
3 files changed, 58 insertions, 20 deletions
diff --git a/client.c b/client.c
index b1b1417..b7c9455 100644
--- a/client.c
+++ b/client.c
@@ -37,10 +37,6 @@ update_name(Client *c)
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
46void 42void
@@ -51,27 +47,52 @@ update_size(Client *c)
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
64void 76void
65focus(Client *c) 77focus(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
@@ -91,7 +112,6 @@ manage(Window w, XWindowAttributes *wa)
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;
@@ -100,6 +120,7 @@ manage(Window w, XWindowAttributes *wa)
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 */
@@ -107,12 +128,14 @@ manage(Window w, XWindowAttributes *wa)
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
@@ -122,6 +145,7 @@ resize(Client *c)
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;
@@ -186,7 +210,17 @@ getclient(Window w)
186void 210void
187draw_client(Client *c) 211draw_client(Client *c)
188{ 212{
189 213 if(!c)
214 return;
215 if(c == stack)
216 draw_bar();
190 217
218 brush.rect.x = brush.rect.y = 0;
219 brush.rect.width = 2 * c->w / 3;
220 brush.rect.height = barrect.height;
191 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);
192} 226}
diff --git a/event.c b/event.c
index 84b0698..f29038a 100644
--- a/event.c
+++ b/event.c
@@ -143,9 +143,12 @@ static void
143expose(XEvent *e) 143expose(XEvent *e)
144{ 144{
145 XExposeEvent *ev = &e->xexpose; 145 XExposeEvent *ev = &e->xexpose;
146 Client *c;
146 147
147 if(ev->count == 0) { 148 if(ev->count == 0) {
148 if(ev->window == barwin) 149 if((c = getclient(ev->window)))
150 draw_client(c);
151 else if(ev->window == barwin)
149 draw_bar(); 152 draw_bar();
150 } 153 }
151} 154}
diff --git a/wm.c b/wm.c
index 837be3c..82b2dee 100644
--- a/wm.c
+++ b/wm.c
@@ -245,10 +245,6 @@ main(int argc, char *argv[])
245 245
246 update_keys(); 246 update_keys();
247 247
248 brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height,
249 DefaultDepth(dpy, screen));
250 brush.gc = XCreateGC(dpy, root, 0, 0);
251
252 /* style */ 248 /* style */
253 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); 249 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
254 loadfont(dpy, &brush.font, FONT); 250 loadfont(dpy, &brush.font, FONT);
@@ -266,6 +262,11 @@ main(int argc, char *argv[])
266 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 262 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
267 XDefineCursor(dpy, barwin, cursor[CurNormal]); 263 XDefineCursor(dpy, barwin, cursor[CurNormal]);
268 XMapRaised(dpy, barwin); 264 XMapRaised(dpy, barwin);
265
266 brush.drawable = XCreatePixmap(dpy, root, rect.width, barrect.height,
267 DefaultDepth(dpy, screen));
268 brush.gc = XCreateGC(dpy, root, 0, 0);
269
269 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); 270 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
270 draw_bar(); 271 draw_bar();
271 272