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