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) ?
31 self->frame.client->max_vert || self->frame.client->max_horz) ?
32 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_max : ob_a_unfocused_unpressed_max));
37 i = (client_focused(self->frame.client) ?
38 (self->iconify_press ?
39 ob_a_focused_pressed_iconify : ob_a_focused_unpressed_iconify) :
40 (self->iconify_press ?
41 ob_a_unfocused_pressed_iconify :
42 ob_a_unfocused_unpressed_iconify));
43 d = (client_focused(self->frame.client) ?
44 (self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
45 ob_a_focused_pressed_desk : ob_a_focused_unpressed_desk) :
46 (self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
47 ob_a_unfocused_pressed_desk : ob_a_unfocused_unpressed_desk));
48 c = (client_focused(self->frame.client) ?
50 ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
52 ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));
54 paint(self->title, t);
56 /* set parents for any parent relative guys */
57 l->surface.data.planar.parent = t;
58 l->surface.data.planar.parentx = self->label_x;
59 l->surface.data.planar.parenty = ob_s_bevel;
61 m->surface.data.planar.parent = t;
62 m->surface.data.planar.parentx = self->max_x;
63 m->surface.data.planar.parenty = ob_s_bevel + 1;
65 n->surface.data.planar.parent = t;
66 n->surface.data.planar.parentx = self->icon_x;
67 n->surface.data.planar.parenty = ob_s_bevel + 1;
69 i->surface.data.planar.parent = t;
70 i->surface.data.planar.parentx = self->iconify_x;
71 i->surface.data.planar.parenty = ob_s_bevel + 1;
73 d->surface.data.planar.parent = t;
74 d->surface.data.planar.parentx = self->desk_x;
75 d->surface.data.planar.parenty = ob_s_bevel + 1;
77 c->surface.data.planar.parent = t;
78 c->surface.data.planar.parentx = self->close_x;
79 c->surface.data.planar.parenty = ob_s_bevel + 1;
81 obrender_label(self, l);
82 obrender_max(self, m);
83 obrender_icon(self, n);
84 obrender_iconify(self, i);
85 obrender_desk(self, d);
86 obrender_close(self, c);
89 if (self->frame.client->decorations & Decor_Handle) {
92 h = (client_focused(self->frame.client) ?
93 self->a_focused_handle : self->a_unfocused_handle);
94 g = (client_focused(self->frame.client) ?
95 ob_a_focused_grip : ob_a_unfocused_grip);
97 if (g->surface.data.planar.grad == Background_ParentRelative) {
98 g->surface.data.planar.parent = h;
99 paint(self->handle, h);
101 paint(self->handle, h);
103 g->surface.data.planar.parentx = 0;
104 g->surface.data.planar.parenty = 0;
106 paint(self->lgrip, g);
108 g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
109 g->surface.data.planar.parenty = 0;
111 paint(self->rgrip, g);
115 static void obrender_label(ObFrame *self, Appearance *a)
117 if (self->label_x < 0) return;
120 /* set the texture's text! */
121 a->texture[0].data.text.string = self->frame.client->title;
122 RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT);
124 paint(self->label, a);
127 static void obrender_icon(ObFrame *self, Appearance *a)
129 if (self->icon_x < 0) return;
131 if (self->frame.client->nicons) {
132 Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
133 a->texture[0].type = RGBA;
134 a->texture[0].data.rgba.width = icon->width;
135 a->texture[0].data.rgba.height = icon->height;
136 a->texture[0].data.rgba.data = icon->data;
137 RECT_SET(self->a_icon->texture[0].position, 0, 0,
138 BUTTON_SIZE,BUTTON_SIZE);
140 a->texture[0].type = NoTexture;
142 paint(self->icon, a);
145 static void obrender_max(ObFrame *self, Appearance *a)
147 if (self->max_x < 0) return;
149 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
153 static void obrender_iconify(ObFrame *self, Appearance *a)
155 if (self->iconify_x < 0) return;
157 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
158 paint(self->iconify, a);
161 static void obrender_desk(ObFrame *self, Appearance *a)
163 if (self->desk_x < 0) return;
165 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
166 paint(self->desk, a);
169 static void obrender_close(ObFrame *self, Appearance *a)
171 if (self->close_x < 0) return;
173 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
174 paint(self->close, a);