]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
Make the focus cycle indicator follow target fallback in the popup
[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 if (frame_iconify_animating(self))
38 return; /* delay redrawing until the animation is done */
39 if (!self->need_render)
40 return;
41 if (!self->visible)
42 return;
43 self->need_render = FALSE;
44
45 {
46 gulong px;
47
48 px = (self->focused ?
49 RrColorPixel(ob_rr_theme->cb_focused_color) :
50 RrColorPixel(ob_rr_theme->cb_unfocused_color));
51
52 XSetWindowBackground(ob_display, self->backback, px);
53 XClearWindow(ob_display, self->backback);
54 XSetWindowBackground(ob_display, self->innerleft, px);
55 XClearWindow(ob_display, self->innerleft);
56 XSetWindowBackground(ob_display, self->innertop, px);
57 XClearWindow(ob_display, self->innertop);
58 XSetWindowBackground(ob_display, self->innerright, px);
59 XClearWindow(ob_display, self->innerright);
60 XSetWindowBackground(ob_display, self->innerbottom, px);
61 XClearWindow(ob_display, self->innerbottom);
62 XSetWindowBackground(ob_display, self->innerbll, px);
63 XClearWindow(ob_display, self->innerbll);
64 XSetWindowBackground(ob_display, self->innerbrr, px);
65 XClearWindow(ob_display, self->innerbrr);
66 XSetWindowBackground(ob_display, self->innerblb, px);
67 XClearWindow(ob_display, self->innerblb);
68 XSetWindowBackground(ob_display, self->innerbrb, px);
69 XClearWindow(ob_display, self->innerbrb);
70
71 px = (self->focused ?
72 RrColorPixel(ob_rr_theme->frame_focused_border_color) :
73 RrColorPixel(ob_rr_theme->frame_unfocused_border_color));
74
75 XSetWindowBackground(ob_display, self->left, px);
76 XClearWindow(ob_display, self->left);
77 XSetWindowBackground(ob_display, self->right, px);
78 XClearWindow(ob_display, self->right);
79
80 XSetWindowBackground(ob_display, self->titleleft, px);
81 XClearWindow(ob_display, self->titleleft);
82 XSetWindowBackground(ob_display, self->titletop, px);
83 XClearWindow(ob_display, self->titletop);
84 XSetWindowBackground(ob_display, self->titletopleft, px);
85 XClearWindow(ob_display, self->titletopleft);
86 XSetWindowBackground(ob_display, self->titletopright, px);
87 XClearWindow(ob_display, self->titletopright);
88 XSetWindowBackground(ob_display, self->titleright, px);
89 XClearWindow(ob_display, self->titleright);
90
91 XSetWindowBackground(ob_display, self->handleleft, px);
92 XClearWindow(ob_display, self->handleleft);
93 XSetWindowBackground(ob_display, self->handletop, px);
94 XClearWindow(ob_display, self->handletop);
95 XSetWindowBackground(ob_display, self->handleright, px);
96 XClearWindow(ob_display, self->handleright);
97 XSetWindowBackground(ob_display, self->handlebottom, px);
98 XClearWindow(ob_display, self->handlebottom);
99
100 XSetWindowBackground(ob_display, self->lgripleft, px);
101 XClearWindow(ob_display, self->lgripleft);
102 XSetWindowBackground(ob_display, self->lgriptop, px);
103 XClearWindow(ob_display, self->lgriptop);
104 XSetWindowBackground(ob_display, self->lgripbottom, px);
105 XClearWindow(ob_display, self->lgripbottom);
106
107 XSetWindowBackground(ob_display, self->rgripright, px);
108 XClearWindow(ob_display, self->rgripright);
109 XSetWindowBackground(ob_display, self->rgriptop, px);
110 XClearWindow(ob_display, self->rgriptop);
111 XSetWindowBackground(ob_display, self->rgripbottom, px);
112 XClearWindow(ob_display, self->rgripbottom);
113
114 /* don't use the separator color for shaded windows */
115 if (!self->client->shaded)
116 px = (self->focused ?
117 RrColorPixel(ob_rr_theme->title_separator_focused_color) :
118 RrColorPixel(ob_rr_theme->title_separator_unfocused_color));
119
120 XSetWindowBackground(ob_display, self->titlebottom, px);
121 XClearWindow(ob_display, self->titlebottom);
122 }
123
124 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
125 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c, *clear;
126 if (self->focused) {
127 t = ob_rr_theme->a_focused_title;
128 l = ob_rr_theme->a_focused_label;
129 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
130 ob_rr_theme->a_disabled_focused_max :
131 (self->client->max_vert || self->client->max_horz ?
132 (self->max_press ?
133 ob_rr_theme->a_toggled_focused_pressed_max :
134 (self->max_hover ?
135 ob_rr_theme->a_toggled_hover_focused_max :
136 ob_rr_theme->a_toggled_focused_unpressed_max)) :
137 (self->max_press ?
138 ob_rr_theme->a_focused_pressed_max :
139 (self->max_hover ?
140 ob_rr_theme->a_hover_focused_max :
141 ob_rr_theme->a_focused_unpressed_max))));
142 n = ob_rr_theme->a_icon;
143 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
144 ob_rr_theme->a_disabled_focused_iconify :
145 (self->iconify_press ?
146 ob_rr_theme->a_focused_pressed_iconify :
147 (self->iconify_hover ?
148 ob_rr_theme->a_hover_focused_iconify :
149 ob_rr_theme->a_focused_unpressed_iconify)));
150 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
151 ob_rr_theme->a_disabled_focused_desk :
152 (self->client->desktop == DESKTOP_ALL ?
153 (self->desk_press ?
154 ob_rr_theme->a_toggled_focused_pressed_desk :
155 (self->desk_hover ?
156 ob_rr_theme->a_toggled_hover_focused_desk :
157 ob_rr_theme->a_toggled_focused_unpressed_desk)) :
158 (self->desk_press ?
159 ob_rr_theme->a_focused_pressed_desk :
160 (self->desk_hover ?
161 ob_rr_theme->a_hover_focused_desk :
162 ob_rr_theme->a_focused_unpressed_desk))));
163 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
164 ob_rr_theme->a_disabled_focused_shade :
165 (self->client->shaded ?
166 (self->shade_press ?
167 ob_rr_theme->a_toggled_focused_pressed_shade :
168 (self->shade_hover ?
169 ob_rr_theme->a_toggled_hover_focused_shade :
170 ob_rr_theme->a_toggled_focused_unpressed_shade)) :
171 (self->shade_press ?
172 ob_rr_theme->a_focused_pressed_shade :
173 (self->shade_hover ?
174 ob_rr_theme->a_hover_focused_shade :
175 ob_rr_theme->a_focused_unpressed_shade))));
176 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
177 ob_rr_theme->a_disabled_focused_close :
178 (self->close_press ?
179 ob_rr_theme->a_focused_pressed_close :
180 (self->close_hover ?
181 ob_rr_theme->a_hover_focused_close :
182 ob_rr_theme->a_focused_unpressed_close)));
183 } else {
184 t = ob_rr_theme->a_unfocused_title;
185 l = ob_rr_theme->a_unfocused_label;
186 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
187 ob_rr_theme->a_disabled_unfocused_max :
188 (self->client->max_vert || self->client->max_horz ?
189 (self->max_press ?
190 ob_rr_theme->a_toggled_unfocused_pressed_max :
191 (self->max_hover ?
192 ob_rr_theme->a_toggled_hover_unfocused_max :
193 ob_rr_theme->a_toggled_unfocused_unpressed_max)) :
194 (self->max_press ?
195 ob_rr_theme->a_unfocused_pressed_max :
196 (self->max_hover ?
197 ob_rr_theme->a_hover_unfocused_max :
198 ob_rr_theme->a_unfocused_unpressed_max))));
199 n = ob_rr_theme->a_icon;
200 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
201 ob_rr_theme->a_disabled_unfocused_iconify :
202 (self->iconify_press ?
203 ob_rr_theme->a_unfocused_pressed_iconify :
204 (self->iconify_hover ?
205 ob_rr_theme->a_hover_unfocused_iconify :
206 ob_rr_theme->a_unfocused_unpressed_iconify)));
207 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
208 ob_rr_theme->a_disabled_unfocused_desk :
209 (self->client->desktop == DESKTOP_ALL ?
210 (self->desk_press ?
211 ob_rr_theme->a_toggled_unfocused_pressed_desk :
212 (self->desk_hover ?
213 ob_rr_theme->a_toggled_hover_unfocused_desk :
214 ob_rr_theme->a_toggled_unfocused_unpressed_desk)) :
215 (self->desk_press ?
216 ob_rr_theme->a_unfocused_pressed_desk :
217 (self->desk_hover ?
218 ob_rr_theme->a_hover_unfocused_desk :
219 ob_rr_theme->a_unfocused_unpressed_desk))));
220 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
221 ob_rr_theme->a_disabled_unfocused_shade :
222 (self->client->shaded ?
223 (self->shade_press ?
224 ob_rr_theme->a_toggled_unfocused_pressed_shade :
225 (self->shade_hover ?
226 ob_rr_theme->a_toggled_hover_unfocused_shade :
227 ob_rr_theme->a_toggled_unfocused_unpressed_shade)) :
228 (self->shade_press ?
229 ob_rr_theme->a_unfocused_pressed_shade :
230 (self->shade_hover ?
231 ob_rr_theme->a_hover_unfocused_shade :
232 ob_rr_theme->a_unfocused_unpressed_shade))));
233 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
234 ob_rr_theme->a_disabled_unfocused_close :
235 (self->close_press ?
236 ob_rr_theme->a_unfocused_pressed_close :
237 (self->close_hover ?
238 ob_rr_theme->a_hover_unfocused_close :
239 ob_rr_theme->a_unfocused_unpressed_close)));
240 }
241 clear = ob_rr_theme->a_clear;
242
243 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
244
245 clear->surface.parent = t;
246 clear->surface.parenty = 0;
247
248 clear->surface.parentx = ob_rr_theme->grip_width;
249
250 RrPaint(clear, self->topresize,
251 self->width - ob_rr_theme->grip_width * 2,
252 ob_rr_theme->paddingy + 1);
253
254 clear->surface.parentx = 0;
255
256 if (ob_rr_theme->grip_width > 0)
257 RrPaint(clear, self->tltresize,
258 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
259 if (ob_rr_theme->title_height > 0)
260 RrPaint(clear, self->tllresize,
261 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
262
263 clear->surface.parentx = self->width - ob_rr_theme->grip_width;
264
265 if (ob_rr_theme->grip_width > 0)
266 RrPaint(clear, self->trtresize,
267 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
268
269 clear->surface.parentx = self->width - (ob_rr_theme->paddingx + 1);
270
271 if (ob_rr_theme->title_height > 0)
272 RrPaint(clear, self->trrresize,
273 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
274
275 /* set parents for any parent relative guys */
276 l->surface.parent = t;
277 l->surface.parentx = self->label_x;
278 l->surface.parenty = ob_rr_theme->paddingy;
279
280 m->surface.parent = t;
281 m->surface.parentx = self->max_x;
282 m->surface.parenty = ob_rr_theme->paddingy + 1;
283
284 n->surface.parent = t;
285 n->surface.parentx = self->icon_x;
286 n->surface.parenty = ob_rr_theme->paddingy;
287
288 i->surface.parent = t;
289 i->surface.parentx = self->iconify_x;
290 i->surface.parenty = ob_rr_theme->paddingy + 1;
291
292 d->surface.parent = t;
293 d->surface.parentx = self->desk_x;
294 d->surface.parenty = ob_rr_theme->paddingy + 1;
295
296 s->surface.parent = t;
297 s->surface.parentx = self->shade_x;
298 s->surface.parenty = ob_rr_theme->paddingy + 1;
299
300 c->surface.parent = t;
301 c->surface.parentx = self->close_x;
302 c->surface.parenty = ob_rr_theme->paddingy + 1;
303
304 framerender_label(self, l);
305 framerender_max(self, m);
306 framerender_icon(self, n);
307 framerender_iconify(self, i);
308 framerender_desk(self, d);
309 framerender_shade(self, s);
310 framerender_close(self, c);
311 }
312
313 if (self->decorations & OB_FRAME_DECOR_HANDLE &&
314 ob_rr_theme->handle_height > 0)
315 {
316 RrAppearance *h, *g;
317
318 h = (self->focused ?
319 ob_rr_theme->a_focused_handle : ob_rr_theme->a_unfocused_handle);
320
321 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
322
323 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
324 g = (self->focused ?
325 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
326
327 if (g->surface.grad == RR_SURFACE_PARENTREL)
328 g->surface.parent = h;
329
330 g->surface.parentx = 0;
331 g->surface.parenty = 0;
332
333 RrPaint(g, self->lgrip,
334 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
335
336 g->surface.parentx = self->width - ob_rr_theme->grip_width;
337 g->surface.parenty = 0;
338
339 RrPaint(g, self->rgrip,
340 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
341 }
342 }
343
344 XFlush(ob_display);
345 }
346
347 static void framerender_label(ObFrame *self, RrAppearance *a)
348 {
349 if (!self->label_on) return;
350 /* set the texture's text! */
351 a->texture[0].data.text.string = self->client->title;
352 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
353 }
354
355 static void framerender_icon(ObFrame *self, RrAppearance *a)
356 {
357 RrImage *icon;
358
359 if (!self->icon_on) return;
360
361 icon = client_icon(self->client);
362
363 if (icon) {
364 RrAppearanceClearTextures(a);
365 a->texture[0].type = RR_TEXTURE_IMAGE;
366 a->texture[0].data.image.alpha = 0xff;
367 a->texture[0].data.image.image = icon;
368 } else {
369 RrAppearanceClearTextures(a);
370 a->texture[0].type = RR_TEXTURE_NONE;
371 }
372
373 RrPaint(a, self->icon,
374 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
375 }
376
377 static void framerender_max(ObFrame *self, RrAppearance *a)
378 {
379 if (!self->max_on) return;
380 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
381 }
382
383 static void framerender_iconify(ObFrame *self, RrAppearance *a)
384 {
385 if (!self->iconify_on) return;
386 RrPaint(a, self->iconify,
387 ob_rr_theme->button_size, ob_rr_theme->button_size);
388 }
389
390 static void framerender_desk(ObFrame *self, RrAppearance *a)
391 {
392 if (!self->desk_on) return;
393 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
394 }
395
396 static void framerender_shade(ObFrame *self, RrAppearance *a)
397 {
398 if (!self->shade_on) return;
399 RrPaint(a, self->shade,
400 ob_rr_theme->button_size, ob_rr_theme->button_size);
401 }
402
403 static void framerender_close(ObFrame *self, RrAppearance *a)
404 {
405 if (!self->close_on) return;
406 RrPaint(a, self->close,
407 ob_rr_theme->button_size, ob_rr_theme->button_size);
408 }
This page took 0.056467 seconds and 4 git commands to generate.