]> Dogcows Code - chaz/openbox/blob - engines/openbox/obrender.c
not using quarks, using an array and a Context enum for contexts
[chaz/openbox] / engines / openbox / obrender.c
1 #include "obengine.h"
2 #include "../../kernel/openbox.h"
3 #include "../../kernel/screen.h"
4
5 static void obrender_label(ObFrame *self, Appearance *a);
6 static void obrender_max(ObFrame *self, Appearance *a);
7 static void obrender_icon(ObFrame *self, Appearance *a);
8 static void obrender_iconify(ObFrame *self, Appearance *a);
9 static void obrender_desk(ObFrame *self, Appearance *a);
10 static void obrender_shade(ObFrame *self, Appearance *a);
11 static void obrender_close(ObFrame *self, Appearance *a);
12
13 void obrender_frame(ObFrame *self)
14 {
15 if (client_focused(self->frame.client)) {
16 XSetWindowBorder(ob_display, self->frame.plate,
17 ob_s_cb_focused_color->pixel);
18 } else {
19 XSetWindowBorder(ob_display, self->frame.plate,
20 ob_s_cb_unfocused_color->pixel);
21 }
22
23 if (self->frame.client->decorations & Decor_Titlebar) {
24 Appearance *t, *l, *m, *n, *i, *d, *s, *c;
25
26 t = (client_focused(self->frame.client) ?
27 self->a_focused_title : self->a_unfocused_title);
28 l = (client_focused(self->frame.client) ?
29 self->a_focused_label : self->a_unfocused_label);
30 m = (client_focused(self->frame.client) ?
31 (self->frame.client->max_vert || self->frame.client->max_horz ?
32 ob_a_focused_pressed_set_max :
33 (self->max_press ?
34 ob_a_focused_pressed_max : ob_a_focused_unpressed_max)) :
35 (self->frame.client->max_vert || self->frame.client->max_horz ?
36 ob_a_unfocused_pressed_set_max :
37 (self->max_press ?
38 ob_a_unfocused_pressed_max : ob_a_unfocused_unpressed_max)));
39 n = self->a_icon;
40 i = (client_focused(self->frame.client) ?
41 (self->iconify_press ?
42 ob_a_focused_pressed_iconify : ob_a_focused_unpressed_iconify) :
43 (self->iconify_press ?
44 ob_a_unfocused_pressed_iconify :
45 ob_a_unfocused_unpressed_iconify));
46 d = (client_focused(self->frame.client) ?
47 (self->frame.client->desktop == DESKTOP_ALL ?
48 ob_a_focused_pressed_set_desk :
49 (self->desk_press ?
50 ob_a_focused_pressed_desk : ob_a_focused_unpressed_desk)) :
51 (self->frame.client->desktop == DESKTOP_ALL ?
52 ob_a_unfocused_pressed_set_desk :
53 (self->desk_press ?
54 ob_a_unfocused_pressed_desk : ob_a_unfocused_unpressed_desk)));
55 s = (client_focused(self->frame.client) ?
56 (self->frame.client->shaded ?
57 ob_a_focused_pressed_set_shade :
58 (self->shade_press ?
59 ob_a_focused_pressed_shade : ob_a_focused_unpressed_shade)) :
60 (self->frame.client->shaded ?
61 ob_a_unfocused_pressed_set_shade :
62 (self->shade_press ?
63 ob_a_unfocused_pressed_shade :ob_a_unfocused_unpressed_shade)));
64 c = (client_focused(self->frame.client) ?
65 (self->close_press ?
66 ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
67 (self->close_press ?
68 ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));
69
70 paint(self->title, t);
71
72 /* set parents for any parent relative guys */
73 l->surface.data.planar.parent = t;
74 l->surface.data.planar.parentx = self->label_x;
75 l->surface.data.planar.parenty = ob_s_bevel;
76
77 m->surface.data.planar.parent = t;
78 m->surface.data.planar.parentx = self->max_x;
79 m->surface.data.planar.parenty = ob_s_bevel + 1;
80
81 n->surface.data.planar.parent = t;
82 n->surface.data.planar.parentx = self->icon_x;
83 n->surface.data.planar.parenty = ob_s_bevel + 1;
84
85 i->surface.data.planar.parent = t;
86 i->surface.data.planar.parentx = self->iconify_x;
87 i->surface.data.planar.parenty = ob_s_bevel + 1;
88
89 d->surface.data.planar.parent = t;
90 d->surface.data.planar.parentx = self->desk_x;
91 d->surface.data.planar.parenty = ob_s_bevel + 1;
92
93 s->surface.data.planar.parent = t;
94 s->surface.data.planar.parentx = self->shade_x;
95 s->surface.data.planar.parenty = ob_s_bevel + 1;
96
97 c->surface.data.planar.parent = t;
98 c->surface.data.planar.parentx = self->close_x;
99 c->surface.data.planar.parenty = ob_s_bevel + 1;
100
101 obrender_label(self, l);
102 obrender_max(self, m);
103 obrender_icon(self, n);
104 obrender_iconify(self, i);
105 obrender_desk(self, d);
106 obrender_shade(self, s);
107 obrender_close(self, c);
108 }
109
110 if (self->frame.client->decorations & Decor_Handle) {
111 Appearance *h, *g;
112
113 h = (client_focused(self->frame.client) ?
114 self->a_focused_handle : self->a_unfocused_handle);
115 g = (client_focused(self->frame.client) ?
116 ob_a_focused_grip : ob_a_unfocused_grip);
117
118 if (g->surface.data.planar.grad == Background_ParentRelative) {
119 g->surface.data.planar.parent = h;
120 paint(self->handle, h);
121 } else
122 paint(self->handle, h);
123
124 g->surface.data.planar.parentx = 0;
125 g->surface.data.planar.parenty = 0;
126
127 paint(self->lgrip, g);
128
129 g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
130 g->surface.data.planar.parenty = 0;
131
132 paint(self->rgrip, g);
133 }
134 }
135
136 static void obrender_label(ObFrame *self, Appearance *a)
137 {
138 if (self->label_x < 0) return;
139
140
141 /* set the texture's text! */
142 a->texture[0].data.text.string = self->frame.client->title;
143 RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT);
144
145 paint(self->label, a);
146 }
147
148 static void obrender_icon(ObFrame *self, Appearance *a)
149 {
150 if (self->icon_x < 0) return;
151
152 if (self->frame.client->nicons) {
153 Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
154 a->texture[0].type = RGBA;
155 a->texture[0].data.rgba.width = icon->width;
156 a->texture[0].data.rgba.height = icon->height;
157 a->texture[0].data.rgba.data = icon->data;
158 RECT_SET(self->a_icon->texture[0].position, 0, 0,
159 BUTTON_SIZE,BUTTON_SIZE);
160 } else
161 a->texture[0].type = NoTexture;
162
163 paint(self->icon, a);
164 }
165
166 static void obrender_max(ObFrame *self, Appearance *a)
167 {
168 if (self->max_x < 0) return;
169
170 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
171 paint(self->max, a);
172 }
173
174 static void obrender_iconify(ObFrame *self, Appearance *a)
175 {
176 if (self->iconify_x < 0) return;
177
178 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
179 paint(self->iconify, a);
180 }
181
182 static void obrender_desk(ObFrame *self, Appearance *a)
183 {
184 if (self->desk_x < 0) return;
185
186 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
187 paint(self->desk, a);
188 }
189
190 static void obrender_shade(ObFrame *self, Appearance *a)
191 {
192 if (self->shade_x < 0) return;
193
194 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
195 paint(self->shade, a);
196 }
197
198 static void obrender_close(ObFrame *self, Appearance *a)
199 {
200 if (self->close_x < 0) return;
201
202 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
203 paint(self->close, a);
204 }
This page took 0.054498 seconds and 4 git commands to generate.