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