]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
themerc.xsd is not executable
[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 XSetWindowBackground(ob_display, self->inner, px);
44 XClearWindow(ob_display, self->inner);
45
46 px = (self->focused ?
47 RrColorPixel(ob_rr_theme->frame_focused_border_color) :
48 RrColorPixel(ob_rr_theme->frame_unfocused_border_color));
49 XSetWindowBorder(ob_display, self->window, px);
50 XSetWindowBorder(ob_display, self->inner, px);
51 XSetWindowBorder(ob_display, self->title, px);
52 XSetWindowBorder(ob_display, self->handle, px);
53 XSetWindowBorder(ob_display, self->rgrip, px);
54 XSetWindowBorder(ob_display, self->lgrip, px);
55 }
56
57 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
58 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c;
59 if (self->focused) {
60
61 t = self->a_focused_title;
62 l = self->a_focused_label;
63
64 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
65 ob_rr_theme->a_disabled_focused_max :
66 (self->client->max_vert || self->client->max_horz ?
67 (self->max_press ?
68 ob_rr_theme->a_toggled_focused_pressed_max :
69 (self->max_hover ?
70 ob_rr_theme->a_toggled_hover_focused_max :
71 ob_rr_theme->a_toggled_focused_unpressed_max)) :
72 (self->max_press ?
73 ob_rr_theme->a_focused_pressed_max :
74 (self->max_hover ?
75 ob_rr_theme->a_hover_focused_max :
76 ob_rr_theme->a_focused_unpressed_max))));
77 n = self->a_icon;
78 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
79 ob_rr_theme->a_disabled_focused_iconify :
80 (self->iconify_press ?
81 ob_rr_theme->a_focused_pressed_iconify :
82 (self->iconify_hover ?
83 ob_rr_theme->a_hover_focused_iconify :
84 ob_rr_theme->a_focused_unpressed_iconify)));
85 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
86 ob_rr_theme->a_disabled_focused_desk :
87 (self->client->desktop == DESKTOP_ALL ?
88 (self->desk_press ?
89 ob_rr_theme->a_toggled_focused_pressed_desk :
90 (self->desk_hover ?
91 ob_rr_theme->a_toggled_hover_focused_desk :
92 ob_rr_theme->a_toggled_focused_unpressed_desk)) :
93 (self->desk_press ?
94 ob_rr_theme->a_focused_pressed_desk :
95 (self->desk_hover ?
96 ob_rr_theme->a_hover_focused_desk :
97 ob_rr_theme->a_focused_unpressed_desk))));
98 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
99 ob_rr_theme->a_disabled_focused_shade :
100 (self->client->shaded ?
101 (self->shade_press ?
102 ob_rr_theme->a_toggled_focused_pressed_shade :
103 (self->shade_hover ?
104 ob_rr_theme->a_toggled_hover_focused_shade :
105 ob_rr_theme->a_toggled_focused_unpressed_shade)) :
106 (self->shade_press ?
107 ob_rr_theme->a_focused_pressed_shade :
108 (self->shade_hover ?
109 ob_rr_theme->a_hover_focused_shade :
110 ob_rr_theme->a_focused_unpressed_shade))));
111 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
112 ob_rr_theme->a_disabled_focused_close :
113 (self->close_press ?
114 ob_rr_theme->a_focused_pressed_close :
115 (self->close_hover ?
116 ob_rr_theme->a_hover_focused_close :
117 ob_rr_theme->a_focused_unpressed_close)));
118 } else {
119 t = self->a_unfocused_title;
120 l = self->a_unfocused_label;
121 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
122 ob_rr_theme->a_disabled_unfocused_max :
123 (self->client->max_vert || self->client->max_horz ?
124 (self->max_press ?
125 ob_rr_theme->a_toggled_unfocused_pressed_max :
126 (self->max_hover ?
127 ob_rr_theme->a_toggled_hover_unfocused_max :
128 ob_rr_theme->a_toggled_unfocused_unpressed_max)) :
129 (self->max_press ?
130 ob_rr_theme->a_unfocused_pressed_max :
131 (self->max_hover ?
132 ob_rr_theme->a_hover_unfocused_max :
133 ob_rr_theme->a_unfocused_unpressed_max))));
134 n = self->a_icon;
135 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
136 ob_rr_theme->a_disabled_unfocused_iconify :
137 (self->iconify_press ?
138 ob_rr_theme->a_unfocused_pressed_iconify :
139 (self->iconify_hover ?
140 ob_rr_theme->a_hover_unfocused_iconify :
141 ob_rr_theme->a_unfocused_unpressed_iconify)));
142 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
143 ob_rr_theme->a_disabled_unfocused_desk :
144 (self->client->desktop == DESKTOP_ALL ?
145 (self->desk_press ?
146 ob_rr_theme->a_toggled_unfocused_pressed_desk :
147 (self->desk_hover ?
148 ob_rr_theme->a_toggled_hover_unfocused_desk :
149 ob_rr_theme->a_toggled_unfocused_unpressed_desk)) :
150 (self->desk_press ?
151 ob_rr_theme->a_unfocused_pressed_desk :
152 (self->desk_hover ?
153 ob_rr_theme->a_hover_unfocused_desk :
154 ob_rr_theme->a_unfocused_unpressed_desk))));
155 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
156 ob_rr_theme->a_disabled_unfocused_shade :
157 (self->client->shaded ?
158 (self->shade_press ?
159 ob_rr_theme->a_toggled_unfocused_pressed_shade :
160 (self->shade_hover ?
161 ob_rr_theme->a_toggled_hover_unfocused_shade :
162 ob_rr_theme->a_toggled_unfocused_unpressed_shade)) :
163 (self->shade_press ?
164 ob_rr_theme->a_unfocused_pressed_shade :
165 (self->shade_hover ?
166 ob_rr_theme->a_hover_unfocused_shade :
167 ob_rr_theme->a_unfocused_unpressed_shade))));
168 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
169 ob_rr_theme->a_disabled_unfocused_close :
170 (self->close_press ?
171 ob_rr_theme->a_unfocused_pressed_close :
172 (self->close_hover ?
173 ob_rr_theme->a_hover_unfocused_close :
174 ob_rr_theme->a_unfocused_unpressed_close)));
175 }
176
177 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
178
179 ob_rr_theme->a_clear->surface.parent = t;
180 ob_rr_theme->a_clear->surface.parenty = 0;
181
182 ob_rr_theme->a_clear->surface.parentx = ob_rr_theme->grip_width +
183 self->bwidth;
184 RrPaint(ob_rr_theme->a_clear, self->topresize,
185 self->width - (ob_rr_theme->grip_width + self->bwidth) * 2,
186 ob_rr_theme->paddingy + 1);
187
188 ob_rr_theme->a_clear->surface.parentx = 0;
189
190 if (ob_rr_theme->grip_width > 0)
191 RrPaint(ob_rr_theme->a_clear, self->tltresize,
192 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
193 if (ob_rr_theme->title_height > 0)
194 RrPaint(ob_rr_theme->a_clear, self->tllresize,
195 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
196
197 ob_rr_theme->a_clear->surface.parentx =
198 self->width - ob_rr_theme->grip_width;
199
200 if (ob_rr_theme->grip_width > 0)
201 RrPaint(ob_rr_theme->a_clear, self->trtresize,
202 ob_rr_theme->grip_width, ob_rr_theme->paddingy + 1);
203
204 ob_rr_theme->a_clear->surface.parentx =
205 self->width - (ob_rr_theme->paddingx + 1);
206
207 if (ob_rr_theme->title_height > 0)
208 RrPaint(ob_rr_theme->a_clear, self->trrresize,
209 ob_rr_theme->paddingx + 1, ob_rr_theme->title_height);
210
211 /* set parents for any parent relative guys */
212 l->surface.parent = t;
213 l->surface.parentx = self->label_x;
214 l->surface.parenty = ob_rr_theme->paddingy;
215
216 m->surface.parent = t;
217 m->surface.parentx = self->max_x;
218 m->surface.parenty = ob_rr_theme->paddingy + 1;
219
220 n->surface.parent = t;
221 n->surface.parentx = self->icon_x;
222 n->surface.parenty = ob_rr_theme->paddingy;
223
224 i->surface.parent = t;
225 i->surface.parentx = self->iconify_x;
226 i->surface.parenty = ob_rr_theme->paddingy + 1;
227
228 d->surface.parent = t;
229 d->surface.parentx = self->desk_x;
230 d->surface.parenty = ob_rr_theme->paddingy + 1;
231
232 s->surface.parent = t;
233 s->surface.parentx = self->shade_x;
234 s->surface.parenty = ob_rr_theme->paddingy + 1;
235
236 c->surface.parent = t;
237 c->surface.parentx = self->close_x;
238 c->surface.parenty = ob_rr_theme->paddingy + 1;
239
240 framerender_label(self, l);
241 framerender_max(self, m);
242 framerender_icon(self, n);
243 framerender_iconify(self, i);
244 framerender_desk(self, d);
245 framerender_shade(self, s);
246 framerender_close(self, c);
247 }
248
249 if (self->decorations & OB_FRAME_DECOR_HANDLE &&
250 ob_rr_theme->handle_height > 0)
251 {
252 RrAppearance *h, *g;
253
254 h = (self->focused ?
255 self->a_focused_handle : self->a_unfocused_handle);
256
257 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
258
259 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
260 g = (self->focused ?
261 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
262
263 if (g->surface.grad == RR_SURFACE_PARENTREL)
264 g->surface.parent = h;
265
266 g->surface.parentx = 0;
267 g->surface.parenty = 0;
268
269 RrPaint(g, self->lgrip,
270 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
271
272 g->surface.parentx = self->width - ob_rr_theme->grip_width;
273 g->surface.parenty = 0;
274
275 RrPaint(g, self->rgrip,
276 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
277 }
278 }
279
280 XFlush(ob_display);
281 }
282
283 static void framerender_label(ObFrame *self, RrAppearance *a)
284 {
285 if (!self->label_on) return;
286 /* set the texture's text! */
287 a->texture[0].data.text.string = self->client->title;
288 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
289 }
290
291 static void framerender_icon(ObFrame *self, RrAppearance *a)
292 {
293 const ObClientIcon *icon;
294
295 if (!self->icon_on) return;
296
297 icon = client_icon(self->client,
298 ob_rr_theme->button_size + 2,
299 ob_rr_theme->button_size + 2);
300 if (icon) {
301 a->texture[0].type = RR_TEXTURE_RGBA;
302 a->texture[0].data.rgba.width = icon->width;
303 a->texture[0].data.rgba.height = icon->height;
304 a->texture[0].data.rgba.data = icon->data;
305 } else
306 a->texture[0].type = RR_TEXTURE_NONE;
307
308 RrPaint(a, self->icon,
309 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
310 }
311
312 static void framerender_max(ObFrame *self, RrAppearance *a)
313 {
314 if (!self->max_on) return;
315 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
316 }
317
318 static void framerender_iconify(ObFrame *self, RrAppearance *a)
319 {
320 if (!self->iconify_on) return;
321 RrPaint(a, self->iconify,
322 ob_rr_theme->button_size, ob_rr_theme->button_size);
323 }
324
325 static void framerender_desk(ObFrame *self, RrAppearance *a)
326 {
327 if (!self->desk_on) return;
328 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
329 }
330
331 static void framerender_shade(ObFrame *self, RrAppearance *a)
332 {
333 if (!self->shade_on) return;
334 RrPaint(a, self->shade,
335 ob_rr_theme->button_size, ob_rr_theme->button_size);
336 }
337
338 static void framerender_close(ObFrame *self, RrAppearance *a)
339 {
340 if (!self->close_on) return;
341 RrPaint(a, self->close,
342 ob_rr_theme->button_size, ob_rr_theme->button_size);
343 }
This page took 0.055372 seconds and 4 git commands to generate.