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