2 #include "../../kernel/openbox.h"
3 #include "../../kernel/screen.h"
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_close(ObFrame *self, Appearance *a);
12 void obrender_frame(ObFrame *self)
14 if (client_focused(self->frame.client)) {
15 XSetWindowBorder(ob_display, self->frame.plate,
16 ob_s_cb_focused_color->pixel);
18 XSetWindowBorder(ob_display, self->frame.plate,
19 ob_s_cb_unfocused_color->pixel);
22 if (self->frame.client->decorations & Decor_Titlebar) {
23 Appearance *t, *l, *m, *n, *i, *d, *c;
25 t = (client_focused(self->frame.client) ?
26 self->a_focused_title : self->a_unfocused_title);
27 l = (client_focused(self->frame.client) ?
28 self->a_focused_label : self->a_unfocused_label);
29 m = (client_focused(self->frame.client) ?
30 (self->frame.client->max_vert || self->frame.client->max_horz ?
31 ob_a_focused_pressed_set_max :
33 ob_a_focused_pressed_max : ob_a_focused_unpressed_max)) :
34 (self->frame.client->max_vert || self->frame.client->max_horz ?
35 ob_a_unfocused_pressed_set_max :
37 ob_a_unfocused_pressed_max : ob_a_unfocused_unpressed_max)));
39 i = (client_focused(self->frame.client) ?
40 (self->iconify_press ?
41 ob_a_focused_pressed_iconify : ob_a_focused_unpressed_iconify) :
42 (self->iconify_press ?
43 ob_a_unfocused_pressed_iconify :
44 ob_a_unfocused_unpressed_iconify));
45 d = (client_focused(self->frame.client) ?
46 (self->frame.client->desktop == DESKTOP_ALL ?
47 ob_a_focused_pressed_set_desk :
49 ob_a_focused_pressed_desk : ob_a_focused_unpressed_desk)) :
50 (self->frame.client->desktop == DESKTOP_ALL ?
51 ob_a_unfocused_pressed_set_desk :
53 ob_a_unfocused_pressed_desk : ob_a_unfocused_unpressed_desk)));
54 c = (client_focused(self->frame.client) ?
56 ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
58 ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));
60 paint(self->title, t);
62 /* set parents for any parent relative guys */
63 l->surface.data.planar.parent = t;
64 l->surface.data.planar.parentx = self->label_x;
65 l->surface.data.planar.parenty = ob_s_bevel;
67 m->surface.data.planar.parent = t;
68 m->surface.data.planar.parentx = self->max_x;
69 m->surface.data.planar.parenty = ob_s_bevel + 1;
71 n->surface.data.planar.parent = t;
72 n->surface.data.planar.parentx = self->icon_x;
73 n->surface.data.planar.parenty = ob_s_bevel + 1;
75 i->surface.data.planar.parent = t;
76 i->surface.data.planar.parentx = self->iconify_x;
77 i->surface.data.planar.parenty = ob_s_bevel + 1;
79 d->surface.data.planar.parent = t;
80 d->surface.data.planar.parentx = self->desk_x;
81 d->surface.data.planar.parenty = ob_s_bevel + 1;
83 c->surface.data.planar.parent = t;
84 c->surface.data.planar.parentx = self->close_x;
85 c->surface.data.planar.parenty = ob_s_bevel + 1;
87 obrender_label(self, l);
88 obrender_max(self, m);
89 obrender_icon(self, n);
90 obrender_iconify(self, i);
91 obrender_desk(self, d);
92 obrender_close(self, c);
95 if (self->frame.client->decorations & Decor_Handle) {
98 h = (client_focused(self->frame.client) ?
99 self->a_focused_handle : self->a_unfocused_handle);
100 g = (client_focused(self->frame.client) ?
101 ob_a_focused_grip : ob_a_unfocused_grip);
103 if (g->surface.data.planar.grad == Background_ParentRelative) {
104 g->surface.data.planar.parent = h;
105 paint(self->handle, h);
107 paint(self->handle, h);
109 g->surface.data.planar.parentx = 0;
110 g->surface.data.planar.parenty = 0;
112 paint(self->lgrip, g);
114 g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
115 g->surface.data.planar.parenty = 0;
117 paint(self->rgrip, g);
121 static void obrender_label(ObFrame *self, Appearance *a)
123 if (self->label_x < 0) return;
126 /* set the texture's text! */
127 a->texture[0].data.text.string = self->frame.client->title;
128 RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT);
130 paint(self->label, a);
133 static void obrender_icon(ObFrame *self, Appearance *a)
135 if (self->icon_x < 0) return;
137 if (self->frame.client->nicons) {
138 Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
139 a->texture[0].type = RGBA;
140 a->texture[0].data.rgba.width = icon->width;
141 a->texture[0].data.rgba.height = icon->height;
142 a->texture[0].data.rgba.data = icon->data;
143 RECT_SET(self->a_icon->texture[0].position, 0, 0,
144 BUTTON_SIZE,BUTTON_SIZE);
146 a->texture[0].type = NoTexture;
148 paint(self->icon, a);
151 static void obrender_max(ObFrame *self, Appearance *a)
153 if (self->max_x < 0) return;
155 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
159 static void obrender_iconify(ObFrame *self, Appearance *a)
161 if (self->iconify_x < 0) return;
163 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
164 paint(self->iconify, a);
167 static void obrender_desk(ObFrame *self, Appearance *a)
169 if (self->desk_x < 0) return;
171 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
172 paint(self->desk, a);
175 static void obrender_close(ObFrame *self, Appearance *a)
177 if (self->close_x < 0) return;
179 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
180 paint(self->close, a);