summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c64
1 files changed, 49 insertions, 15 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}