]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
maybe this makes everyone happy, only select first entry in menus if it's not a subme...
[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) 2003 Ben Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "frame.h"
20 #include "openbox.h"
21 #include "screen.h"
22 #include "client.h"
23 #include "framerender.h"
24 #include "render/theme.h"
25
26 static void framerender_label(ObFrame *self, RrAppearance *a);
27 static void framerender_icon(ObFrame *self, RrAppearance *a);
28 static void framerender_max(ObFrame *self, RrAppearance *a);
29 static void framerender_iconify(ObFrame *self, RrAppearance *a);
30 static void framerender_desk(ObFrame *self, RrAppearance *a);
31 static void framerender_shade(ObFrame *self, RrAppearance *a);
32 static void framerender_close(ObFrame *self, RrAppearance *a);
33
34 void framerender_frame(ObFrame *self)
35 {
36 {
37 gulong px;
38
39 px = (self->focused ?
40 RrColorPixel(ob_rr_theme->cb_focused_color) :
41 RrColorPixel(ob_rr_theme->cb_unfocused_color));
42 XSetWindowBackground(ob_display, self->plate, px);
43 XClearWindow(ob_display, self->plate);
44 }
45
46 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
47 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c;
48 if (self->focused) {
49
50 t = self->a_focused_title;
51 l = self->a_focused_label;
52 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
53 ob_rr_theme->a_disabled_focused_max :
54 (self->client->max_vert || self->client->max_horz ?
55 ob_rr_theme->a_toggled_focused_max :
56 (self->max_press ?
57 ob_rr_theme->a_focused_pressed_max :
58 (self->max_hover ?
59 ob_rr_theme->a_hover_focused_max :
60 ob_rr_theme->a_focused_unpressed_max))));
61 n = self->a_icon;
62 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
63 ob_rr_theme->a_disabled_focused_iconify :
64 (self->iconify_press ?
65 ob_rr_theme->a_focused_pressed_iconify :
66 (self->iconify_hover ?
67 ob_rr_theme->a_hover_focused_iconify :
68 ob_rr_theme->a_focused_unpressed_iconify)));
69 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
70 ob_rr_theme->a_disabled_focused_desk :
71 (self->client->desktop == DESKTOP_ALL ?
72 ob_rr_theme->a_toggled_focused_desk :
73 (self->desk_press ?
74 ob_rr_theme->a_focused_pressed_desk :
75 (self->desk_hover ?
76 ob_rr_theme->a_hover_focused_desk :
77 ob_rr_theme->a_focused_unpressed_desk))));
78 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
79 ob_rr_theme->a_disabled_focused_shade :
80 (self->client->shaded ?
81 ob_rr_theme->a_toggled_focused_shade :
82 (self->shade_press ?
83 ob_rr_theme->a_focused_pressed_shade :
84 (self->shade_hover ?
85 ob_rr_theme->a_hover_focused_shade :
86 ob_rr_theme->a_focused_unpressed_shade))));
87 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
88 ob_rr_theme->a_disabled_focused_close :
89 (self->close_press ?
90 ob_rr_theme->a_focused_pressed_close :
91 (self->close_hover ?
92 ob_rr_theme->a_hover_focused_close :
93 ob_rr_theme->a_focused_unpressed_close)));
94 } else {
95
96 t = self->a_unfocused_title;
97 l = self->a_unfocused_label;
98 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
99 ob_rr_theme->a_disabled_unfocused_max :
100 (self->client->max_vert || self->client->max_horz ?
101 ob_rr_theme->a_toggled_unfocused_max :
102 (self->max_press ?
103 ob_rr_theme->a_unfocused_pressed_max :
104 (self->max_hover ?
105 ob_rr_theme->a_hover_unfocused_max :
106 ob_rr_theme->a_unfocused_unpressed_max))));
107 n = self->a_icon;
108 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
109 ob_rr_theme->a_disabled_unfocused_iconify :
110 (self->iconify_press ?
111 ob_rr_theme->a_unfocused_pressed_iconify :
112 (self->iconify_hover ?
113 ob_rr_theme->a_hover_unfocused_iconify :
114 ob_rr_theme->a_unfocused_unpressed_iconify)));
115 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
116 ob_rr_theme->a_disabled_unfocused_desk :
117 (self->client->desktop == DESKTOP_ALL ?
118 ob_rr_theme->a_toggled_unfocused_desk :
119 (self->desk_press ?
120 ob_rr_theme->a_unfocused_pressed_desk :
121 (self->desk_hover ?
122 ob_rr_theme->a_hover_unfocused_desk :
123 ob_rr_theme->a_unfocused_unpressed_desk))));
124 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
125 ob_rr_theme->a_disabled_unfocused_shade :
126 (self->client->shaded ?
127 ob_rr_theme->a_toggled_unfocused_shade :
128 (self->shade_press ?
129 ob_rr_theme->a_unfocused_pressed_shade :
130 (self->shade_hover ?
131 ob_rr_theme->a_hover_unfocused_shade :
132 ob_rr_theme->a_unfocused_unpressed_shade))));
133 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
134 ob_rr_theme->a_disabled_unfocused_close :
135 (self->close_press ?
136 ob_rr_theme->a_unfocused_pressed_close :
137 (self->close_hover ?
138 ob_rr_theme->a_hover_unfocused_close :
139 ob_rr_theme->a_unfocused_unpressed_close)));
140 }
141
142 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
143
144 ob_rr_theme->a_clear->surface.parent = t;
145 ob_rr_theme->a_clear->surface.parentx = 0;
146 ob_rr_theme->a_clear->surface.parenty = 0;
147
148 RrPaint(ob_rr_theme->a_clear, self->tlresize,
149 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
150
151 ob_rr_theme->a_clear->surface.parentx =
152 self->width - ob_rr_theme->grip_width;
153
154 RrPaint(ob_rr_theme->a_clear, self->trresize,
155 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
156
157
158 /* set parents for any parent relative guys */
159 l->surface.parent = t;
160 l->surface.parentx = self->label_x;
161 l->surface.parenty = ob_rr_theme->padding;
162
163 m->surface.parent = t;
164 m->surface.parentx = self->max_x;
165 m->surface.parenty = ob_rr_theme->padding + 1;
166
167 n->surface.parent = t;
168 n->surface.parentx = self->icon_x;
169 n->surface.parenty = ob_rr_theme->padding;
170
171 i->surface.parent = t;
172 i->surface.parentx = self->iconify_x;
173 i->surface.parenty = ob_rr_theme->padding + 1;
174
175 d->surface.parent = t;
176 d->surface.parentx = self->desk_x;
177 d->surface.parenty = ob_rr_theme->padding + 1;
178
179 s->surface.parent = t;
180 s->surface.parentx = self->shade_x;
181 s->surface.parenty = ob_rr_theme->padding + 1;
182
183 c->surface.parent = t;
184 c->surface.parentx = self->close_x;
185 c->surface.parenty = ob_rr_theme->padding + 1;
186
187 framerender_label(self, l);
188 framerender_max(self, m);
189 framerender_icon(self, n);
190 framerender_iconify(self, i);
191 framerender_desk(self, d);
192 framerender_shade(self, s);
193 framerender_close(self, c);
194 }
195
196 if (self->decorations & OB_FRAME_DECOR_HANDLE) {
197 RrAppearance *h, *g;
198
199 h = (self->focused ?
200 self->a_focused_handle : self->a_unfocused_handle);
201
202 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
203
204 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
205 g = (self->focused ?
206 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
207
208 if (g->surface.grad == RR_SURFACE_PARENTREL)
209 g->surface.parent = h;
210
211 g->surface.parentx = 0;
212 g->surface.parenty = 0;
213
214 RrPaint(g, self->lgrip,
215 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
216
217 g->surface.parentx = self->width - ob_rr_theme->grip_width;
218 g->surface.parenty = 0;
219
220 RrPaint(g, self->rgrip,
221 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
222 }
223 }
224
225 XFlush(ob_display);
226 }
227
228 static void framerender_label(ObFrame *self, RrAppearance *a)
229 {
230 if (self->label_x < 0) return;
231 /* set the texture's text! */
232 a->texture[0].data.text.string = self->client->title;
233 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
234 }
235
236 static void framerender_icon(ObFrame *self, RrAppearance *a)
237 {
238 const ObClientIcon *icon;
239
240 if (self->icon_x < 0) return;
241
242 icon = client_icon(self->client,
243 ob_rr_theme->button_size + 2,
244 ob_rr_theme->button_size + 2);
245 if (icon) {
246 a->texture[0].type = RR_TEXTURE_RGBA;
247 a->texture[0].data.rgba.width = icon->width;
248 a->texture[0].data.rgba.height = icon->height;
249 a->texture[0].data.rgba.data = icon->data;
250 } else
251 a->texture[0].type = RR_TEXTURE_NONE;
252
253 RrPaint(a, self->icon,
254 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
255 }
256
257 static void framerender_max(ObFrame *self, RrAppearance *a)
258 {
259 if (self->max_x < 0) return;
260 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
261 }
262
263 static void framerender_iconify(ObFrame *self, RrAppearance *a)
264 {
265 if (self->iconify_x < 0) return;
266 RrPaint(a, self->iconify,
267 ob_rr_theme->button_size, ob_rr_theme->button_size);
268 }
269
270 static void framerender_desk(ObFrame *self, RrAppearance *a)
271 {
272 if (self->desk_x < 0) return;
273 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
274 }
275
276 static void framerender_shade(ObFrame *self, RrAppearance *a)
277 {
278 if (self->shade_x < 0) return;
279 RrPaint(a, self->shade,
280 ob_rr_theme->button_size, ob_rr_theme->button_size);
281 }
282
283 static void framerender_close(ObFrame *self, RrAppearance *a)
284 {
285 if (self->close_x < 0) return;
286 RrPaint(a, self->close,
287 ob_rr_theme->button_size, ob_rr_theme->button_size);
288 }
This page took 0.045346 seconds and 4 git commands to generate.