]> Dogcows Code - chaz/openbox/blob - openbox/framerender.c
add a func to find a menu entry from a submenu.
[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 ob_rr_theme->a_focused_unpressed_max)) :
42 (self->client->max_vert || self->client->max_horz ?
43 ob_rr_theme->a_unfocused_pressed_set_max :
44 (self->max_press ?
45 ob_rr_theme->a_unfocused_pressed_max :
46 ob_rr_theme->a_unfocused_unpressed_max))));
47 n = self->a_icon;
48 i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ?
49 (self->focused ?
50 ob_rr_theme->a_disabled_focused_iconify :
51 ob_rr_theme->a_disabled_unfocused_iconify) :
52 (self->focused ?
53 (self->iconify_press ?
54 ob_rr_theme->a_focused_pressed_iconify :
55 ob_rr_theme->a_focused_unpressed_iconify) :
56 (self->iconify_press ?
57 ob_rr_theme->a_unfocused_pressed_iconify :
58 ob_rr_theme->a_unfocused_unpressed_iconify)));
59 d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ?
60 (self->focused ?
61 ob_rr_theme->a_disabled_focused_desk :
62 ob_rr_theme->a_disabled_unfocused_desk) :
63 (self->focused ?
64 (self->client->desktop == DESKTOP_ALL ?
65 ob_rr_theme->a_focused_pressed_set_desk :
66 (self->desk_press ?
67 ob_rr_theme->a_focused_pressed_desk :
68 ob_rr_theme->a_focused_unpressed_desk)) :
69 (self->client->desktop == DESKTOP_ALL ?
70 ob_rr_theme->a_unfocused_pressed_set_desk :
71 (self->desk_press ?
72 ob_rr_theme->a_unfocused_pressed_desk :
73 ob_rr_theme->a_unfocused_unpressed_desk))));
74 s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ?
75 (self->focused ?
76 ob_rr_theme->a_disabled_focused_shade :
77 ob_rr_theme->a_disabled_unfocused_shade) :
78 (self->focused ?
79 (self->client->shaded ?
80 ob_rr_theme->a_focused_pressed_set_shade :
81 (self->shade_press ?
82 ob_rr_theme->a_focused_pressed_shade :
83 ob_rr_theme->a_focused_unpressed_shade)) :
84 (self->client->shaded ?
85 ob_rr_theme->a_unfocused_pressed_set_shade :
86 (self->shade_press ?
87 ob_rr_theme->a_unfocused_pressed_shade :
88 ob_rr_theme->a_unfocused_unpressed_shade))));
89 c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ?
90 (self->focused ?
91 ob_rr_theme->a_disabled_focused_close :
92 ob_rr_theme->a_disabled_unfocused_close) :
93 (self->focused ?
94 (self->close_press ?
95 ob_rr_theme->a_focused_pressed_close :
96 ob_rr_theme->a_focused_unpressed_close) :
97 (self->close_press ?
98 ob_rr_theme->a_unfocused_pressed_close :
99 ob_rr_theme->a_unfocused_unpressed_close)));
100
101 RrPaint(t, self->title, self->width, ob_rr_theme->title_height);
102
103 /* set parents for any parent relative guys */
104 l->surface.parent = t;
105 l->surface.parentx = self->label_x;
106 l->surface.parenty = ob_rr_theme->bevel;
107
108 m->surface.parent = t;
109 m->surface.parentx = self->max_x;
110 m->surface.parenty = ob_rr_theme->bevel + 1;
111
112 n->surface.parent = t;
113 n->surface.parentx = self->icon_x;
114 n->surface.parenty = ob_rr_theme->bevel;
115
116 i->surface.parent = t;
117 i->surface.parentx = self->iconify_x;
118 i->surface.parenty = ob_rr_theme->bevel + 1;
119
120 d->surface.parent = t;
121 d->surface.parentx = self->desk_x;
122 d->surface.parenty = ob_rr_theme->bevel + 1;
123
124 s->surface.parent = t;
125 s->surface.parentx = self->shade_x;
126 s->surface.parenty = ob_rr_theme->bevel + 1;
127
128 c->surface.parent = t;
129 c->surface.parentx = self->close_x;
130 c->surface.parenty = ob_rr_theme->bevel + 1;
131
132 framerender_label(self, l);
133 framerender_max(self, m);
134 framerender_icon(self, n);
135 framerender_iconify(self, i);
136 framerender_desk(self, d);
137 framerender_shade(self, s);
138 framerender_close(self, c);
139 }
140
141 if (self->decorations & OB_FRAME_DECOR_HANDLE) {
142 RrAppearance *h, *g;
143
144 h = (self->focused ?
145 self->a_focused_handle : self->a_unfocused_handle);
146
147 RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height);
148
149 if (self->decorations & OB_FRAME_DECOR_GRIPS) {
150 g = (self->focused ?
151 ob_rr_theme->a_focused_grip : ob_rr_theme->a_unfocused_grip);
152
153 if (g->surface.grad == RR_SURFACE_PARENTREL)
154 g->surface.parent = h;
155
156 g->surface.parentx = 0;
157 g->surface.parenty = 0;
158
159 RrPaint(g, self->lgrip,
160 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
161
162 g->surface.parentx = self->width - ob_rr_theme->grip_width;
163 g->surface.parenty = 0;
164
165 RrPaint(g, self->rgrip,
166 ob_rr_theme->grip_width, ob_rr_theme->handle_height);
167 }
168 }
169 }
170
171 static void framerender_label(ObFrame *self, RrAppearance *a)
172 {
173 if (self->label_x < 0) return;
174 /* set the texture's text! */
175 a->texture[0].data.text.string = self->client->title;
176 RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height);
177 }
178
179 static void framerender_icon(ObFrame *self, RrAppearance *a)
180 {
181 if (self->icon_x < 0) return;
182
183 if (self->client->nicons) {
184 ObClientIcon *icon = client_icon(self->client,
185 ob_rr_theme->button_size + 2,
186 ob_rr_theme->button_size + 2);
187 a->texture[0].type = RR_TEXTURE_RGBA;
188 a->texture[0].data.rgba.width = icon->width;
189 a->texture[0].data.rgba.height = icon->height;
190 a->texture[0].data.rgba.data = icon->data;
191 } else
192 a->texture[0].type = RR_TEXTURE_NONE;
193
194 RrPaint(a, self->icon,
195 ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2);
196 }
197
198 static void framerender_max(ObFrame *self, RrAppearance *a)
199 {
200 if (self->max_x < 0) return;
201 RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size);
202 }
203
204 static void framerender_iconify(ObFrame *self, RrAppearance *a)
205 {
206 if (self->iconify_x < 0) return;
207 RrPaint(a, self->iconify,
208 ob_rr_theme->button_size, ob_rr_theme->button_size);
209 }
210
211 static void framerender_desk(ObFrame *self, RrAppearance *a)
212 {
213 if (self->desk_x < 0) return;
214 RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size);
215 }
216
217 static void framerender_shade(ObFrame *self, RrAppearance *a)
218 {
219 if (self->shade_x < 0) return;
220 RrPaint(a, self->shade,
221 ob_rr_theme->button_size, ob_rr_theme->button_size);
222 }
223
224 static void framerender_close(ObFrame *self, RrAppearance *a)
225 {
226 if (self->close_x < 0) return;
227 RrPaint(a, self->close,
228 ob_rr_theme->button_size, ob_rr_theme->button_size);
229 }
This page took 0.046233 seconds and 4 git commands to generate.