]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
use the label only for popups without an icon, if the label is not parentrelative
[chaz/openbox] / openbox / framerender.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 framerender.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "frame.h"
21 #include "openbox.h"
22 #include "screen.h"
23 #include "client.h"
24 #include "framerender.h"
25 #include "render/theme.h"
26
27 static void framerender_label(ObFrame *self, RrAppearance *a);
28 static void framerender_icon(ObFrame *self, RrAppearance *a);
29 static void framerender_max(ObFrame *self, RrAppearance *a);
30 static void framerender_iconify(ObFrame *self, RrAppearance *a);
31 static void framerender_desk(ObFrame *self, RrAppearance *a);
32 static void framerender_shade(ObFrame *self, RrAppearance *a);
33 static void framerender_close(ObFrame *self, RrAppearance *a);
34
35 void framerender_frame(ObFrame *self)
36 {
37 {
38 gulong px;
39
40 px = (self->focused ?
41 RrColorPixel(ob_rr_theme->cb_focused_color) :
42 RrColorPixel(ob_rr_theme->cb_unfocused_color));
43
44 XSetWindowBackground(ob_display, self->backback, px);
45 XClearWindow(ob_display, self->backback);
46 XSetWindowBackground(ob_display, self->innerleft, px);
47 XClearWindow(ob_display, self->innerleft);
48 XSetWindowBackground(ob_display, self->innertop, px);
49 XClearWindow(ob_display, self->innertop);
50 XSetWindowBackground(ob_display, self->innerright, px);
51 XClearWindow(ob_display, self->innerright);
52 XSetWindowBackground(ob_display, self->innerbottom, px);
53 XClearWindow(ob_display, self->innerbottom);
54
55 px = (self->focused ?
56 RrColorPixel(ob_rr_theme->frame_focused_border_color) :
57 RrColorPixel(ob_rr_theme->frame_unfocused_border_color));
58
59 XSetWindowBackground(ob_display, self->left, px);
60 XClearWindow(ob_display, self->left);
61 XSetWindowBackground(ob_display, self->right, px);
62 XClearWindow(ob_display, self->right);
63
64 XSetWindowBackground(ob_display, self->titleleft, px);
65 XClearWindow(ob_display, self->titleleft);
66 XSetWindowBackground(ob_display, self->titletop, px);
67 XClearWindow(ob_display, self->titletop);
68 XSetWindowBackground(ob_display, self->titletopleft, px);
69 XClearWindow(ob_display, self->titletopleft);
70 XSetWindowBackground(ob_display, self->titletopright, px);
71 XClearWindow(ob_display, self->titletopright);
72 XSetWindowBackground(ob_display, self->titleright, px);
73 XClearWindow(ob_display, self->titleright);
74
75 XSetWindowBackground(ob_display, self->handleleft, px);
76 XClearWindow(ob_display, self->handleleft);
77 XSetWindowBackground(ob_display, self->handletop, px);
78 XClearWindow(ob_display, self->handletop);
79 XSetWindowBackground(ob_display, self->handleright, px);
80 XClearWindow(ob_display, self->handleright);
81 XSetWindowBackground(ob_display, self->handlebottom, px);
82 XClearWindow(ob_display, self->handlebottom);
83
84 XSetWindowBackground(ob_display, self->lgripleft, px);
85 XClearWindow(ob_display, self->lgripleft);
86 XSetWindowBackground(ob_display, self->lgriptop, px);
87 XClearWindow(ob_display, self->lgriptop);
88 XSetWindowBackground(ob_display, self->lgripbottom, px);
89 XClearWindow(ob_display, self->lgripbottom);
90
91 XSetWindowBackground(ob_display, self->rgripright, px);
92 XClearWindow(ob_display, self->rgripright);
93 XSetWindowBackground(ob_display, self->rgriptop, px);
94 XClearWindow(ob_display, self->rgriptop);
95 XSetWindowBackground(ob_display, self->rgripbottom, px);
96 XClearWindow(ob_display, self->rgripbottom);
97
98 /* don't use the separator color for shaded windows */
99 if (!self->client->shaded)
100 px = (self->focused ?
101 RrColorPixel(ob_rr_theme->title_separator_focused_color) :
102 RrColorPixel(ob_rr_theme->title_separator_unfocused_color));
103
104 XSetWindowBackground(ob_display, self->titlebottom, px);
105 XClearWindow(ob_display, self->titlebottom);
106 }
107
108 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
109 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c, *clear;
110 if (self->focused) {
111
112 t = self->a_focused_title;
113 l = self->a_focused_label;
114
115 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
116 ob_rr_theme->a_disabled_focused_max :
117 (self->client->max_vert || self->client->max_horz ?
118 (self->max_press ?
119 ob_rr_theme->a_toggled_focused_pressed_max :
120 (self->max_hover ?
121 ob_rr_theme->a_toggled_hover_focused_max :
122 ob_rr_theme->a_toggled_focused_unpressed_max)) :
123 (self->max_press ?
124 ob_rr_theme->a_focused_pressed_max :
125 (self->max_hover ?
126 ob_rr_theme->a_hover_focused_max :
127 ob_rr_theme->a_focused_unpressed_max))));
128 n = self->a_icon;
129 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
130 ob_rr_theme->a_disabled_focused_iconify :
131 (self->iconify_press ?
132 ob_rr_theme->a_focused_pressed_iconify :
133 (self->iconify_hover ?
134 ob_rr_theme->a_hover_focused_iconify :
135 ob_rr_theme->a_focused_unpressed_iconify)));
136 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
137 ob_rr_theme->a_disabled_focused_desk :
138 (self->client->desktop == DESKTOP_ALL ?
139 (self->desk_press ?
140 ob_rr_theme->a_toggled_focused_pressed_desk :
141 (self->desk_hover ?
142 ob_rr_theme->a_toggled_hover_focused_desk :
143 ob_rr_theme->a_toggled_focused_unpressed_desk)) :
144 (self->desk_press ?
145 ob_rr_theme->a_focused_pressed_desk :
146 (self->desk_hover ?
147 ob_rr_theme->a_hover_focused_desk :
148 ob_rr_theme->a_focused_unpressed_desk))));
149 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
150 ob_rr_theme->a_disabled_focused_shade :
151 (self->client->shaded ?
152 (self->shade_press ?
153 ob_rr_theme->a_toggled_focused_pressed_shade :
154 (self->shade_hover ?
155 ob_rr_theme->a_toggled_hover_focused_shade :
156 ob_rr_theme->a_toggled_focused_unpressed_shade)) :
157 (self->shade_press ?
158 ob_rr_theme->a_focused_pressed_shade :
159 (self->shade_hover ?
160 ob_rr_theme->a_hover_focused_shade :
161 ob_rr_theme->a_focused_unpressed_shade))));
162 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
163 ob_rr_theme->a_disabled_focused_close :
164 (self->close_press ?
165 ob_rr_theme->a_focused_pressed_close :
166 (self->close_hover ?
167 ob_rr_theme->a_hover_focused_close :
168 ob_rr_theme->a_focused_unpressed_close)));
169 } else {
170 t = self->a_unfocused_title;
171 l = self->a_unfocused_label;
172 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
173 ob_rr_theme->a_disabled_unfocused_max :
174 (self->client->max_vert || self->client->max_horz ?
175 (self->max_press ?
176 ob_rr_theme->a_toggled_unfocused_pressed_max :
177 (self->max_hover ?
178 ob_rr_theme->a_toggled_hover_unfocused_max :
179 ob_rr_theme->a_toggled_unfocused_unpressed_max)) :
180 (self->max_press ?
181 ob_rr_theme->a_unfocused_pressed_max :
182 (self->max_hover ?
183 ob_rr_theme->a_hover_unfocused_max :
184 ob_rr_theme->a_unfocused_unpressed_max))));
185 n = self->a_icon;
186 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
187 ob_rr_theme->a_disabled_unfocused_iconify :
188 (self->iconify_press ?
189 ob_rr_theme->a_unfocused_pressed_iconify :
190 (self->iconify_hover ?
191 ob_rr_theme->a_hover_unfocused_iconify :
192 ob_rr_theme->a_unfocused_unpressed_iconify)));
193 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
194 ob_rr_theme->a_disabled_unfocused_desk :
195 (self->client->desktop == DESKTOP_ALL ?
196 (self->desk_press ?
197 ob_rr_theme->a_toggled_unfocused_pressed_desk :
198 (self->desk_hover ?
199 ob_rr_theme->a_toggled_hover_unfocused_desk :
200 ob_rr_theme->a_toggled_unfocused_unpressed_desk)) :
201 (self->desk_press ?
202 ob_rr_theme->a_unfocused_pressed_desk :
203 (self->desk_hover ?
204 ob_rr_theme->a_hover_unfocused_desk :
205 ob_rr_theme->a_unfocused_unpressed_desk))));
206 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
207 ob_rr_theme->a_disabled_unfocused_shade :
208 (self->client->shaded ?
209 (self->shade_press ?
210 ob_rr_theme->a_toggled_unfocused_pressed_shade :
211 (self->shade_hover ?
212 ob_rr_theme->a_toggled_hover_unfocused_shade :
213 ob_rr_theme->a_toggled_unfocused_unpressed_shade)) :
214 (self->shade_press ?
215 ob_rr_theme->a_unfocused_pressed_shade :
216 (self->shade_hover ?
217 ob_rr_theme->a_hover_unfocused_shade :
218 ob_rr_theme->a_unfocused_unpressed_shade))));
219 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
220 ob_rr_theme->a_disabled_unfocused_close :
221 (self->close_press ?
222 ob_rr_theme->a_unfocused_pressed_close :
223 (self->close_hover ?
224 ob_rr_theme->a_hover_unfocused_close :
225 ob_rr_theme->a_unfocused_unpressed_close)));
226 }
227 clear = ob_rr_theme->a_clear;
228
229 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
230
231 clear->surface.parent = t;
232 clear->surface.parenty = 0;
233
234 clear->surface.parentx = ob_rr_theme->grip_width;
235
236 RrPaint(clear, self->topresize,
237 self->width - ob_rr_theme->grip_width * 2,
238 ob_rr_theme->paddingy + 1);
239
240 clear->surface.parentx = 0;
241
242 if (ob_rr_theme->grip_width > 0)
243 RrPaint(clear, self->tltresize,
244 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
245 if (ob_rr_theme->title_height > 0)
246 RrPaint(clear, self->tllresize,
247 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
248
249 clear->surface.parentx = self->width - ob_rr_theme->grip_width;
250
251 if (ob_rr_theme->grip_width > 0)
252 RrPaint(clear, self->trtresize,
253 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
254
255 clear->surface.parentx = self->width - (ob_rr_theme->paddingx + 1);
256
257 if (ob_rr_theme->title_height > 0)
258 RrPaint(clear, self->trrresize,
259 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
260
261 /* set parents for any parent relative guys */
262 l->surface.parent = t;
263 l->surface.parentx = self->label_x;
264 l->surface.parenty = ob_rr_theme->paddingy;
265
266 m->surface.parent = t;
267 m->surface.parentx = self->max_x;
268 m->surface.parenty = ob_rr_theme->paddingy + 1;
269
270 n->surface.parent = t;
271 n->surface.parentx = self->icon_x;
272 n->surface.parenty = ob_rr_theme->paddingy;
273
274 i->surface.parent = t;
275 i->surface.parentx = self->iconify_x;
276 i->surface.parenty = ob_rr_theme->paddingy + 1;
277
278 d->surface.parent = t;
279 d->surface.parentx = self->desk_x;
280 d->surface.parenty = ob_rr_theme->paddingy + 1;
281
282 s->surface.parent = t;
283 s->surface.parentx = self->shade_x;
284 s->surface.parenty = ob_rr_theme->paddingy + 1;
285
286 c->surface.parent = t;
287 c->surface.parentx = self->close_x;
288 c->surface.parenty = ob_rr_theme->paddingy + 1;
289
290 framerender_label(self, l);
291 framerender_max(self, m);
292 framerender_icon(self, n);
293 framerender_iconify(self, i);
294 framerender_desk(self, d);
295 framerender_shade(self, s);
296 framerender_close(self, c);
297 }
298
299 if (self->decorations & OB_FRAME_DECOR_HANDLE &&
300 ob_rr_theme->handle_height > 0)
301 {
302 RrAppearance *h, *g;
303
304 h = (self->focused ?
305 self->a_focused_handle : self->a_unfocused_handle);
306
307 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
308
309 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
310 g = (self->focused ?
311 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
312
313 if (g->surface.grad == RR_SURFACE_PARENTREL)
314 g->surface.parent = h;
315
316 g->surface.parentx = 0;
317 g->surface.parenty = 0;
318
319 RrPaint(g, self->lgrip,
320 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
321
322 g->surface.parentx = self->width - ob_rr_theme->grip_width;
323 g->surface.parenty = 0;
324
325 RrPaint(g, self->rgrip,
326 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
327 }
328 }
329
330 XFlush(ob_display);
331 }
332
333 static void framerender_label(ObFrame *self, RrAppearance *a)
334 {
335 if (!self->label_on) return;
336 /* set the texture's text! */
337 a->texture[0].data.text.string = self->client->title;
338 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
339 }
340
341 static void framerender_icon(ObFrame *self, RrAppearance *a)
342 {
343 const ObClientIcon *icon;
344
345 if (!self->icon_on) return;
346
347 icon = client_icon(self->client,
348 ob_rr_theme->button_size + 2,
349 ob_rr_theme->button_size + 2);
350 if (icon) {
351 a->texture[0].type = RR_TEXTURE_RGBA;
352 a->texture[0].data.rgba.width = icon->width;
353 a->texture[0].data.rgba.height = icon->height;
354 a->texture[0].data.rgba.alpha = 0xff;
355 a->texture[0].data.rgba.data = icon->data;
356 } else
357 a->texture[0].type = RR_TEXTURE_NONE;
358
359 RrPaint(a, self->icon,
360 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
361 }
362
363 static void framerender_max(ObFrame *self, RrAppearance *a)
364 {
365 if (!self->max_on) return;
366 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
367 }
368
369 static void framerender_iconify(ObFrame *self, RrAppearance *a)
370 {
371 if (!self->iconify_on) return;
372 RrPaint(a, self->iconify,
373 ob_rr_theme->button_size, ob_rr_theme->button_size);
374 }
375
376 static void framerender_desk(ObFrame *self, RrAppearance *a)
377 {
378 if (!self->desk_on) return;
379 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
380 }
381
382 static void framerender_shade(ObFrame *self, RrAppearance *a)
383 {
384 if (!self->shade_on) return;
385 RrPaint(a, self->shade,
386 ob_rr_theme->button_size, ob_rr_theme->button_size);
387 }
388
389 static void framerender_close(ObFrame *self, RrAppearance *a)
390 {
391 if (!self->close_on) return;
392 RrPaint(a, self->close,
393 ob_rr_theme->button_size, ob_rr_theme->button_size);
394 }
This page took 0.050003 seconds and 4 git commands to generate.