about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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)
 		}
 	}
 	XFree(name.value);
-	if(c == stack)
-		draw_bar();
-	else
-		draw_client(c);
 }
 
 void
@@ -51,27 +47,52 @@ update_size(Client *c)
 	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
 		size.flags = PSize;
 	c->flags = size.flags;
-	c->basew = size.base_width;
-	c->baseh = size.base_height;
-	c->incw = size.width_inc;
-	c->inch = size.height_inc;
-	c->maxw = size.max_width;
-	c->maxh = size.max_height;
-	c->minw = size.min_width;
-	c->minh = size.min_height;
+	if(c->flags & PBaseSize) {
+		c->basew = size.base_width;
+		c->baseh = size.base_height;
+	}
+	else
+		c->basew = c->baseh = 0;
+	if(c->flags & PResizeInc) {
+		c->incw = size.width_inc;
+		c->inch = size.height_inc;
+	}
+	else
+		c->incw = c->inch = 0;
+	if(c->flags & PMaxSize) {
+		c->maxw = size.max_width;
+		c->maxh = size.max_height;
+	}
+	else
+		c->maxw = c->maxh = 0;
+	if(c->flags & PMinSize) {
+		c->minw = size.min_width;
+		c->minh = size.min_height;
+	}
+	else
+		c->minw = c->minh = 0;
 }
 
 void
 focus(Client *c)
 {
-	Client **l;
+	Client **l, *old;
+
+	old = stack;
 	for(l=&stack; *l && *l != c; l=&(*l)->snext);
 	eassert(*l == c);
 	*l = c->snext;
 	c->snext = stack;
 	stack = c;
 	XRaiseWindow(dpy, c->win);
+	XRaiseWindow(dpy, c->title);
 	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+	if(old && old != c) {
+		XMapWindow(dpy, old->title);
+		draw_client(old);
+	}
+	XUnmapWindow(dpy, c->title);
+	draw_bar();
 	XFlush(dpy);
 }
 
@@ -91,7 +112,6 @@ manage(Window w, XWindowAttributes *wa)
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XSelectInput(dpy, c->win, CLIENT_MASK);
 	XGetTransientForHint(dpy, c->win, &c->trans);
-	update_name(c);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
 	twa.event_mask = ExposureMask;
@@ -100,6 +120,7 @@ manage(Window w, XWindowAttributes *wa)
 			0, DefaultDepth(dpy, screen), CopyFromParent,
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
+	update_name(c);
 
 	for(l=&clients; *l; l=&(*l)->next);
 	c->next = *l; /* *l == nil */
@@ -107,12 +128,14 @@ manage(Window w, XWindowAttributes *wa)
 	c->snext = stack;
 	stack = c;
 	XMapWindow(dpy, c->win);
+	XMapWindow(dpy, c->title);
 	XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
 	XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
 	XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
+	resize(c);
 	focus(c);
 }
 
@@ -122,6 +145,7 @@ resize(Client *c)
 	XConfigureEvent e;
 
 	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+	XMoveResizeWindow(dpy, c->title, c->x + c->w / 3, c->y, 2 * c->w / 3, barrect.height);
 	e.type = ConfigureNotify;
 	e.event = c->win;
 	e.window = c->win;
@@ -186,7 +210,17 @@ getclient(Window w)
 void
 draw_client(Client *c)
 {
-	
+	if(!c)
+		return;
+	if(c == stack)
+		draw_bar();
 
+	brush.rect.x = brush.rect.y = 0;
+	brush.rect.width = 2 * c->w / 3;
+	brush.rect.height = barrect.height;
 
+	draw(dpy, &brush, True, c->name);
+	XCopyArea(dpy, brush.drawable, c->title, brush.gc, 0, 0,
+			brush.rect.width, brush.rect.height, 0, 0);
+	XFlush(dpy);
 }
diff --git a/event.c b/event.c
index 84b0698..f29038a 100644
--- a/event.c
+++ b/event.c
@@ -143,9 +143,12 @@ static void
 expose(XEvent *e)
 {
 	XExposeEvent *ev = &e->xexpose;
+	Client *c;
 
 	if(ev->count == 0) {
-		if(ev->window == barwin)
+		if((c = getclient(ev->window)))
+			draw_client(c);
+		else if(ev->window == barwin)
 			draw_bar();
 	}
 }
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[])
 
 	update_keys();
 
-	brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height,
-			DefaultDepth(dpy, screen));
-	brush.gc = XCreateGC(dpy, root, 0, 0);
-
 	/* style */
 	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
 	loadfont(dpy, &brush.font, FONT);
@@ -266,6 +262,11 @@ main(int argc, char *argv[])
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
 	XMapRaised(dpy, barwin);
+
+	brush.drawable = XCreatePixmap(dpy, root, rect.width, barrect.height,
+			DefaultDepth(dpy, screen));
+	brush.gc = XCreateGC(dpy, root, 0, 0);
+
 	pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
 	draw_bar();
 
EADME?h=v1.4.2&id=bd088c49e649ab4a548f8528e065ff472baec89d'>bd088c49 ^
36e4e71e ^
0a32b684 ^
36e4e71e ^

f6ae504c ^
4ea0f69a ^

0a32b684 ^

4ea0f69a ^
0a32b684 ^
4ea0f69a ^


0a32b684 ^

4ea0f69a ^



36e4e71e ^
7582555b ^
36e4e71e ^
7582555b ^








36e4e71e ^
4ea0f69a ^


36e4e71e ^




4ea0f69a ^

36e4e71e ^



f6ae504c ^
4ea0f69a ^
36e4e71e ^

4ea0f69a ^

36e4e71e ^






4ea0f69a ^

306c76d8 ^






b6aff4c3 ^

306c76d8 ^
4ea0f69a ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124