1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 frame_default_render.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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.
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.
17 See the COPYING file for a copy of the GNU General Public License.
23 #include "openbox/screen.h"
25 static void framerender_label(ObDefaultFrame *self, RrAppearance *a);
26 static void framerender_icon(ObDefaultFrame *self, RrAppearance *a);
27 static void framerender_max(ObDefaultFrame *self, RrAppearance *a);
28 static void framerender_iconify(ObDefaultFrame *self, RrAppearance *a);
29 static void framerender_desk(ObDefaultFrame *self, RrAppearance *a);
30 static void framerender_shade(ObDefaultFrame *self, RrAppearance *a);
31 static void framerender_close(ObDefaultFrame *self, RrAppearance *a);
33 void frame_update_skin(gpointer _self)
35 ObDefaultFrame * self = (ObDefaultFrame *) _self;
43 px = (self->focused ? RrColorPixel(theme_config.cb_focused_color)
44 : RrColorPixel(theme_config.cb_unfocused_color));
46 XSetWindowBackground(obp_display, self->backback, px);
47 XClearWindow(obp_display, self->backback);
48 XSetWindowBackground(obp_display, self->innerleft, px);
49 XClearWindow(obp_display, self->innerleft);
50 XSetWindowBackground(obp_display, self->innertop, px);
51 XClearWindow(obp_display, self->innertop);
52 XSetWindowBackground(obp_display, self->innerright, px);
53 XClearWindow(obp_display, self->innerright);
54 XSetWindowBackground(obp_display, self->innerbottom, px);
55 XClearWindow(obp_display, self->innerbottom);
56 XSetWindowBackground(obp_display, self->innerbll, px);
57 XClearWindow(obp_display, self->innerbll);
58 XSetWindowBackground(obp_display, self->innerbrr, px);
59 XClearWindow(obp_display, self->innerbrr);
60 XSetWindowBackground(obp_display, self->innerblb, px);
61 XClearWindow(obp_display, self->innerblb);
62 XSetWindowBackground(obp_display, self->innerbrb, px);
63 XClearWindow(obp_display, self->innerbrb);
66 = (self->focused ? RrColorPixel(theme_config.frame_focused_border_color)
67 : RrColorPixel(theme_config.frame_unfocused_border_color));
69 XSetWindowBackground(obp_display, self->left, px);
70 XClearWindow(obp_display, self->left);
71 XSetWindowBackground(obp_display, self->right, px);
72 XClearWindow(obp_display, self->right);
74 XSetWindowBackground(obp_display, self->titleleft, px);
75 XClearWindow(obp_display, self->titleleft);
76 XSetWindowBackground(obp_display, self->titletop, px);
77 XClearWindow(obp_display, self->titletop);
78 XSetWindowBackground(obp_display, self->titletopleft, px);
79 XClearWindow(obp_display, self->titletopleft);
80 XSetWindowBackground(obp_display, self->titletopright, px);
81 XClearWindow(obp_display, self->titletopright);
82 XSetWindowBackground(obp_display, self->titleright, px);
83 XClearWindow(obp_display, self->titleright);
85 XSetWindowBackground(obp_display, self->handleleft, px);
86 XClearWindow(obp_display, self->handleleft);
87 XSetWindowBackground(obp_display, self->handletop, px);
88 XClearWindow(obp_display, self->handletop);
89 XSetWindowBackground(obp_display, self->handleright, px);
90 XClearWindow(obp_display, self->handleright);
91 XSetWindowBackground(obp_display, self->handlebottom, px);
92 XClearWindow(obp_display, self->handlebottom);
94 XSetWindowBackground(obp_display, self->lgripleft, px);
95 XClearWindow(obp_display, self->lgripleft);
96 XSetWindowBackground(obp_display, self->lgriptop, px);
97 XClearWindow(obp_display, self->lgriptop);
98 XSetWindowBackground(obp_display, self->lgripbottom, px);
99 XClearWindow(obp_display, self->lgripbottom);
101 XSetWindowBackground(obp_display, self->rgripright, px);
102 XClearWindow(obp_display, self->rgripright);
103 XSetWindowBackground(obp_display, self->rgriptop, px);
104 XClearWindow(obp_display, self->rgriptop);
105 XSetWindowBackground(obp_display, self->rgripbottom, px);
106 XClearWindow(obp_display, self->rgripbottom);
108 /* don't use the separator color for shaded windows */
111 = (self->focused ? RrColorPixel(theme_config.title_separator_focused_color)
112 : RrColorPixel(theme_config.title_separator_unfocused_color));
114 XSetWindowBackground(obp_display, self->titlebottom, px);
115 XClearWindow(obp_display, self->titlebottom);
118 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
119 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c, *clear;
122 t = self->a_focused_title;
123 l = self->a_focused_label;
126 = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? theme_config.a_disabled_focused_max
127 : (self->max_vert || self->max_horz ? (self->press_flag
128 == OB_BUTTON_MAX ? theme_config.a_toggled_focused_pressed_max
129 : (self->hover_flag == OB_BUTTON_MAX ? theme_config.a_toggled_hover_focused_max
130 : theme_config.a_toggled_focused_unpressed_max))
131 : (self->press_flag == OB_BUTTON_MAX ? theme_config.a_focused_pressed_max
133 == OB_BUTTON_MAX ? theme_config.a_hover_focused_max
134 : theme_config.a_focused_unpressed_max))));
137 = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? theme_config.a_disabled_focused_iconify
138 : (self->press_flag == OB_BUTTON_ICONIFY ? theme_config.a_focused_pressed_iconify
139 : (self->hover_flag == OB_BUTTON_ICONIFY ? theme_config.a_hover_focused_iconify
140 : theme_config.a_focused_unpressed_iconify)));
142 = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ? theme_config.a_disabled_focused_desk
143 : (self->client->desktop == DESKTOP_ALL ? (self->press_flag
144 == OB_BUTTON_DESK ? theme_config.a_toggled_focused_pressed_desk
145 : (self->hover_flag == OB_BUTTON_DESK ? theme_config.a_toggled_hover_focused_desk
146 : theme_config.a_toggled_focused_unpressed_desk))
147 : (self->press_flag == OB_BUTTON_DESK ? theme_config.a_focused_pressed_desk
149 == OB_BUTTON_DESK ? theme_config.a_hover_focused_desk
150 : theme_config.a_focused_unpressed_desk))));
152 = (!(self->decorations & OB_FRAME_DECOR_SHADE) ? theme_config.a_disabled_focused_shade
153 : (self->shaded ? (self->press_flag
154 == OB_BUTTON_SHADE ? theme_config.a_toggled_focused_pressed_shade
155 : (self->hover_flag == OB_BUTTON_SHADE ? theme_config.a_toggled_hover_focused_shade
156 : theme_config.a_toggled_focused_unpressed_shade))
157 : (self->press_flag == OB_BUTTON_SHADE ? theme_config.a_focused_pressed_shade
159 == OB_BUTTON_SHADE ? theme_config.a_hover_focused_shade
160 : theme_config.a_focused_unpressed_shade))));
162 = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ? theme_config.a_disabled_focused_close
163 : (self->press_flag == OB_BUTTON_CLOSE ? theme_config.a_focused_pressed_close
164 : (self->hover_flag == OB_BUTTON_CLOSE ? theme_config.a_hover_focused_close
165 : theme_config.a_focused_unpressed_close)));
168 t = self->a_unfocused_title;
169 l = self->a_unfocused_label;
171 = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? theme_config.a_disabled_unfocused_max
172 : (self->max_vert || self->max_horz ? (self->press_flag
173 == OB_BUTTON_MAX ? theme_config.a_toggled_unfocused_pressed_max
174 : (self->hover_flag == OB_BUTTON_MAX ? theme_config.a_toggled_hover_unfocused_max
175 : theme_config.a_toggled_unfocused_unpressed_max))
176 : (self->press_flag == OB_BUTTON_MAX ? theme_config.a_unfocused_pressed_max
178 == OB_BUTTON_MAX ? theme_config.a_hover_unfocused_max
179 : theme_config.a_unfocused_unpressed_max))));
182 = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? theme_config.a_disabled_unfocused_iconify
183 : (self->press_flag == OB_BUTTON_ICONIFY ? theme_config.a_unfocused_pressed_iconify
184 : (self->hover_flag == OB_BUTTON_ICONIFY ? theme_config.a_hover_unfocused_iconify
185 : theme_config.a_unfocused_unpressed_iconify)));
187 = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ? theme_config.a_disabled_unfocused_desk
188 : (self->client->desktop == DESKTOP_ALL ? (self->press_flag
189 == OB_BUTTON_DESK ? theme_config.a_toggled_unfocused_pressed_desk
190 : (self->hover_flag == OB_BUTTON_DESK ? theme_config.a_toggled_hover_unfocused_desk
191 : theme_config.a_toggled_unfocused_unpressed_desk))
192 : (self->hover_flag == OB_BUTTON_DESK ? theme_config.a_unfocused_pressed_desk
194 == OB_BUTTON_DESK ? theme_config.a_hover_unfocused_desk
195 : theme_config.a_unfocused_unpressed_desk))));
197 = (!(self->decorations & OB_FRAME_DECOR_SHADE) ? theme_config.a_disabled_unfocused_shade
198 : (self->shaded ? (self->press_flag
199 == OB_BUTTON_SHADE ? theme_config.a_toggled_unfocused_pressed_shade
200 : (self->hover_flag == OB_BUTTON_SHADE ? theme_config.a_toggled_hover_unfocused_shade
201 : theme_config.a_toggled_unfocused_unpressed_shade))
202 : (self->press_flag == OB_BUTTON_SHADE ? theme_config.a_unfocused_pressed_shade
204 == OB_BUTTON_SHADE ? theme_config.a_hover_unfocused_shade
205 : theme_config.a_unfocused_unpressed_shade))));
207 = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ? theme_config.a_disabled_unfocused_close
208 : (self->press_flag == OB_BUTTON_CLOSE ? theme_config.a_unfocused_pressed_close
209 : (self->hover_flag == OB_BUTTON_CLOSE ? theme_config.a_hover_unfocused_close
210 : theme_config.a_unfocused_unpressed_close)));
212 clear = theme_config.a_clear;
214 RrPaint(t, self->title, self->width, theme_config.title_height);
216 clear->surface.parent = t;
217 clear->surface.parenty = 0;
219 clear->surface.parentx = theme_config.grip_width;
221 RrPaint(clear, self->topresize, self->width - theme_config.grip_width
222 * 2, theme_config.paddingy + 1);
224 clear->surface.parentx = 0;
226 if (theme_config.grip_width > 0)
227 RrPaint(clear, self->tltresize, theme_config.grip_width,
228 theme_config.paddingy + 1);
229 if (theme_config.title_height > 0)
230 RrPaint(clear, self->tllresize, theme_config.paddingx + 1,
231 theme_config.title_height);
233 clear->surface.parentx = self->width - theme_config.grip_width;
235 if (theme_config.grip_width > 0)
236 RrPaint(clear, self->trtresize, theme_config.grip_width,
237 theme_config.paddingy + 1);
239 clear->surface.parentx = self->width - (theme_config.paddingx + 1);
241 if (theme_config.title_height > 0)
242 RrPaint(clear, self->trrresize, theme_config.paddingx + 1,
243 theme_config.title_height);
245 /* set parents for any parent relative guys */
246 l->surface.parent = t;
247 l->surface.parentx = self->label_x;
248 l->surface.parenty = theme_config.paddingy;
250 m->surface.parent = t;
251 m->surface.parentx = self->max_x;
252 m->surface.parenty = theme_config.paddingy + 1;
254 n->surface.parent = t;
255 n->surface.parentx = self->icon_x;
256 n->surface.parenty = theme_config.paddingy;
258 i->surface.parent = t;
259 i->surface.parentx = self->iconify_x;
260 i->surface.parenty = theme_config.paddingy + 1;
262 d->surface.parent = t;
263 d->surface.parentx = self->desk_x;
264 d->surface.parenty = theme_config.paddingy + 1;
266 s->surface.parent = t;
267 s->surface.parentx = self->shade_x;
268 s->surface.parenty = theme_config.paddingy + 1;
270 c->surface.parent = t;
271 c->surface.parentx = self->close_x;
272 c->surface.parenty = theme_config.paddingy + 1;
274 framerender_label(self, l);
275 framerender_max(self, m);
276 framerender_icon(self, n);
277 framerender_iconify(self, i);
278 framerender_desk(self, d);
279 framerender_shade(self, s);
280 framerender_close(self, c);
283 if (self->decorations & OB_FRAME_DECOR_HANDLE && theme_config.handle_height
287 h = (self->focused ? self->a_focused_handle : self->a_unfocused_handle);
289 RrPaint(h, self->handle, self->width, theme_config.handle_height);
291 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
292 g = (self->focused ? theme_config.a_focused_grip
293 : theme_config.a_unfocused_grip);
295 if (g->surface.grad == RR_SURFACE_PARENTREL)
296 g->surface.parent = h;
298 g->surface.parentx = 0;
299 g->surface.parenty = 0;
301 RrPaint(g, self->lgrip, theme_config.grip_width,
302 theme_config.handle_height);
304 g->surface.parentx = self->width - theme_config.grip_width;
305 g->surface.parenty = 0;
307 RrPaint(g, self->rgrip, theme_config.grip_width,
308 theme_config.handle_height);
315 static void framerender_label(ObDefaultFrame *self, RrAppearance *a)
319 /* set the texture's text! */
320 a->texture[0].data.text.string = self->stitle;
321 RrPaint(a, self->label, self->label_width, theme_config.label_height);
324 static void framerender_icon(ObDefaultFrame *self, RrAppearance *a)
326 const ObClientIcon *icon;
331 icon = client_icon(self->client, theme_config.button_size + 2,
332 theme_config.button_size + 2);
334 a->texture[0].type = RR_TEXTURE_RGBA;
335 a->texture[0].data.rgba.width = icon->width;
336 a->texture[0].data.rgba.height = icon->height;
337 a->texture[0].data.rgba.alpha = 0xff;
338 a->texture[0].data.rgba.data = icon->data;
341 a->texture[0].type = RR_TEXTURE_NONE;
343 RrPaint(a, self->icon, theme_config.button_size + 2,
344 theme_config.button_size + 2);
347 static void framerender_max(ObDefaultFrame *self, RrAppearance *a)
351 RrPaint(a, self->max, theme_config.button_size, theme_config.button_size);
354 static void framerender_iconify(ObDefaultFrame *self, RrAppearance *a)
356 if (!self->iconify_on)
358 RrPaint(a, self->iconify, theme_config.button_size,
359 theme_config.button_size);
362 static void framerender_desk(ObDefaultFrame *self, RrAppearance *a)
366 RrPaint(a, self->desk, theme_config.button_size, theme_config.button_size);
369 static void framerender_shade(ObDefaultFrame *self, RrAppearance *a)
373 RrPaint(a, self->shade, theme_config.button_size, theme_config.button_size);
376 static void framerender_close(ObDefaultFrame *self, RrAppearance *a)
380 RrPaint(a, self->close, theme_config.button_size, theme_config.button_size);