]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
i am the king of copy/paste errors
[chaz/openbox] / openbox / framerender.c
1 #include "frame.h"
2 #include "openbox.h"
3 #include "screen.h"
4 #include "client.h"
5 #include "framerender.h"
6 #include "render/theme.h"
7
8 static void framerender_label(ObFrame *self, RrAppearance *a);
9 static void framerender_icon(ObFrame *self, RrAppearance *a);
10 static void framerender_max(ObFrame *self, RrAppearance *a);
11 static void framerender_iconify(ObFrame *self, RrAppearance *a);
12 static void framerender_desk(ObFrame *self, RrAppearance *a);
13 static void framerender_shade(ObFrame *self, RrAppearance *a);
14 static void framerender_close(ObFrame *self, RrAppearance *a);
15
16 void framerender_frame(ObFrame *self)
17 {
18 if (self->focused)
19 XSetWindowBorder(ob_display, self->plate,
20 RrColorPixel(ob_rr_theme->cb_focused_color));
21 else
22 XSetWindowBorder(ob_display, self->plate,
23 RrColorPixel(ob_rr_theme->cb_unfocused_color));
24
25 if (self->decorations & OB_FRAME_DECOR_TITLEBAR) {
26 RrAppearance *t, *l, *m, *n, *i, *d, *s, *c;
27
28 t = (self->focused ?
29 self->a_focused_title : self->a_unfocused_title);
30 l = (self->focused ?
31 self->a_focused_label : self->a_unfocused_label);
32 m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ?
33 (self->focused ?
34 ob_rr_theme->a_disabled_focused_max :
35 ob_rr_theme->a_disabled_unfocused_max) :
36 (self->focused ?
37 (self->client->max_vert || self->client->max_horz ?
38 ob_rr_theme->a_focused_pressed_set_max :
39 (self->max_press ?
40 ob_rr_theme->a_focused_pressed_max :
41 (self->max_hover ?
42 ob_rr_theme->a_hover_focused_max :
43 ob_rr_theme->a_focused_unpressed_max))) :
44 (self->client->max_vert || self->client->max_horz ?
45 ob_rr_theme->a_unfocused_pressed_set_max :
46 (self->max_press ?
47 ob_rr_theme->a_unfocused_pressed_max :
48 (self->max_hover ?
49 ob_rr_theme->a_hover_unfocused_max :
50 ob_rr_theme->a_unfocused_unpressed_max)))));
51 n = self->a_icon;
52 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
53 (self->focused ?
54 ob_rr_theme->a_disabled_focused_iconify :
55 ob_rr_theme->a_disabled_unfocused_iconify) :
56 (self->focused ?
57 (self->iconify_press ?
58 ob_rr_theme->a_focused_pressed_iconify :
59 (self->iconify_hover ?
60 ob_rr_theme->a_hover_focused_iconify :
61 ob_rr_theme->a_focused_unpressed_iconify)) :
62 (self->iconify_press ?
63 ob_rr_theme->a_unfocused_pressed_iconify :
64 (self->iconify_hover ?
65 ob_rr_theme->a_hover_unfocused_iconify :
66 ob_rr_theme->a_unfocused_unpressed_iconify))));
67 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
68 (self->focused ?
69 ob_rr_theme->a_disabled_focused_desk :
70 ob_rr_theme->a_disabled_unfocused_desk) :
71 (self->focused ?
72 (self->client->desktop == DESKTOP_ALL ?
73 ob_rr_theme->a_focused_pressed_set_desk :
74 (self->desk_press ?
75 ob_rr_theme->a_focused_pressed_desk :
76 (self->desk_hover ?
77 ob_rr_theme->a_hover_focused_desk :
78 ob_rr_theme->a_focused_unpressed_desk))) :
79 (self->client->desktop == DESKTOP_ALL ?
80 ob_rr_theme->a_unfocused_pressed_set_desk :
81 (self->desk_press ?
82 ob_rr_theme->a_unfocused_pressed_desk :
83 (self->desk_hover ?
84 ob_rr_theme->a_hover_unfocused_desk :
85 ob_rr_theme->a_unfocused_unpressed_desk)))));
86 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
87 (self->focused ?
88 ob_rr_theme->a_disabled_focused_shade :
89 ob_rr_theme->a_disabled_unfocused_shade) :
90 (self->focused ?
91 (self->client->shaded ?
92 ob_rr_theme->a_focused_pressed_set_shade :
93 (self->shade_press ?
94 ob_rr_theme->a_focused_pressed_shade :
95 (self->shade_hover ?
96 ob_rr_theme->a_hover_focused_shade :
97 ob_rr_theme->a_focused_unpressed_shade))) :
98 (self->client->shaded ?
99 ob_rr_theme->a_unfocused_pressed_set_shade :
100 (self->shade_press ?
101 ob_rr_theme->a_unfocused_pressed_shade :
102 (self->shade_hover ?
103 ob_rr_theme->a_hover_unfocused_shade :
104 ob_rr_theme->a_unfocused_unpressed_shade)))));
105 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
106 (self->focused ?
107 ob_rr_theme->a_disabled_focused_close :
108 ob_rr_theme->a_disabled_unfocused_close) :
109 (self->focused ?
110 (self->close_press ?
111 ob_rr_theme->a_focused_pressed_close :
112 (self->close_hover ?
113 ob_rr_theme->a_hover_focused_close :
114 ob_rr_theme->a_focused_unpressed_close)) :
115 (self->close_press ?
116 ob_rr_theme->a_unfocused_pressed_close :
117 (self->close_hover ?
118 ob_rr_theme->a_hover_unfocused_close :
119 ob_rr_theme->a_unfocused_unpressed_close))));
120
121 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
122
123 /* set parents for any parent relative guys */
124 l->surface.parent = t;
125 l->surface.parentx = self->label_x;
126 l->surface.parenty = ob_rr_theme->bevel;
127
128 m->surface.parent = t;
129 m->surface.parentx = self->max_x;
130 m->surface.parenty = ob_rr_theme->bevel + 1;
131
132 n->surface.parent = t;
133 n->surface.parentx = self->icon_x;
134 n->surface.parenty = ob_rr_theme->bevel;
135
136 i->surface.parent = t;
137 i->surface.parentx = self->iconify_x;
138 i->surface.parenty = ob_rr_theme->bevel + 1;
139
140 d->surface.parent = t;
141 d->surface.parentx = self->desk_x;
142 d->surface.parenty = ob_rr_theme->bevel + 1;
143
144 s->surface.parent = t;
145 s->surface.parentx = self->shade_x;
146 s->surface.parenty = ob_rr_theme->bevel + 1;
147
148 c->surface.parent = t;
149 c->surface.parentx = self->close_x;
150 c->surface.parenty = ob_rr_theme->bevel + 1;
151
152 framerender_label(self, l);
153 framerender_max(self, m);
154 framerender_icon(self, n);
155 framerender_iconify(self, i);
156 framerender_desk(self, d);
157 framerender_shade(self, s);
158 framerender_close(self, c);
159 }
160
161 if (self->decorations & OB_FRAME_DECOR_HANDLE) {
162 RrAppearance *h, *g;
163
164 h = (self->focused ?
165 self->a_focused_handle : self->a_unfocused_handle);
166
167 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
168
169 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
170 g = (self->focused ?
171 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
172
173 if (g->surface.grad == RR_SURFACE_PARENTREL)
174 g->surface.parent = h;
175
176 g->surface.parentx = 0;
177 g->surface.parenty = 0;
178
179 RrPaint(g, self->lgrip,
180 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
181
182 g->surface.parentx = self->width - ob_rr_theme->grip_width;
183 g->surface.parenty = 0;
184
185 RrPaint(g, self->rgrip,
186 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
187 }
188 }
189 }
190
191 static void framerender_label(ObFrame *self, RrAppearance *a)
192 {
193 if (self->label_x < 0) return;
194 /* set the texture's text! */
195 a->texture[0].data.text.string = self->client->title;
196 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
197 }
198
199 static void framerender_icon(ObFrame *self, RrAppearance *a)
200 {
201 if (self->icon_x < 0) return;
202
203 if (self->client->nicons) {
204 ObClientIcon *icon = client_icon(self->client,
205 ob_rr_theme->button_size + 2,
206 ob_rr_theme->button_size + 2);
207 a->texture[0].type = RR_TEXTURE_RGBA;
208 a->texture[0].data.rgba.width = icon->width;
209 a->texture[0].data.rgba.height = icon->height;
210 a->texture[0].data.rgba.data = icon->data;
211 } else
212 a->texture[0].type = RR_TEXTURE_NONE;
213
214 RrPaint(a, self->icon,
215 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
216 }
217
218 static void framerender_max(ObFrame *self, RrAppearance *a)
219 {
220 if (self->max_x < 0) return;
221 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
222 }
223
224 static void framerender_iconify(ObFrame *self, RrAppearance *a)
225 {
226 if (self->iconify_x < 0) return;
227 RrPaint(a, self->iconify,
228 ob_rr_theme->button_size, ob_rr_theme->button_size);
229 }
230
231 static void framerender_desk(ObFrame *self, RrAppearance *a)
232 {
233 if (self->desk_x < 0) return;
234 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
235 }
236
237 static void framerender_shade(ObFrame *self, RrAppearance *a)
238 {
239 if (self->shade_x < 0) return;
240 RrPaint(a, self->shade,
241 ob_rr_theme->button_size, ob_rr_theme->button_size);
242 }
243
244 static void framerender_close(ObFrame *self, RrAppearance *a)
245 {
246 if (self->close_x < 0) return;
247 RrPaint(a, self->close,
248 ob_rr_theme->button_size, ob_rr_theme->button_size);
249 }
This page took 0.045898 seconds and 4 git commands to generate.