]> Dogcows Code - chaz/openbox/blob - engines/openbox/obrender.c
better prefix symbols to reduce clashes
[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_close(ObFrame *self, Appearance *a);
11
12 void obrender_frame(ObFrame *self)
13 {
14 if (client_focused(self->frame.client)) {
15 XSetWindowBorder(ob_display, self->frame.plate,
16 ob_s_cb_focused_color->pixel);
17 } else {
18 XSetWindowBorder(ob_display, self->frame.plate,
19 ob_s_cb_unfocused_color->pixel);
20 }
21
22 if (self->frame.client->decorations & Decor_Titlebar) {
23 Appearance *t, *l, *m, *n, *i, *d, *c;
24
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->max_press ||
31 self->frame.client->max_vert || self->frame.client->max_horz) ?
32 ob_a_focused_pressed_max : ob_a_focused_unpressed_max) :
33 ((self->max_press ||
34 self->frame.client->max_vert || self->frame.client->max_horz) ?
35 ob_a_unfocused_pressed_max : ob_a_unfocused_unpressed_max));
36 n = self->a_icon;
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) ?
49 (self->close_press ?
50 ob_a_focused_pressed_close : ob_a_focused_unpressed_close) :
51 (self->close_press ?
52 ob_a_unfocused_pressed_close : ob_a_unfocused_unpressed_close));
53
54 paint(self->title, t);
55
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;
60
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;
64
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;
68
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;
72
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;
76
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;
80
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);
87 }
88
89 if (self->frame.client->decorations & Decor_Handle) {
90 Appearance *h, *g;
91
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);
96
97 if (g->surface.data.planar.grad == Background_ParentRelative) {
98 g->surface.data.planar.parent = h;
99 paint(self->handle, h);
100 } else
101 paint(self->handle, h);
102
103 g->surface.data.planar.parentx = 0;
104 g->surface.data.planar.parenty = 0;
105
106 paint(self->lgrip, g);
107
108 g->surface.data.planar.parentx = self->width - GRIP_WIDTH;
109 g->surface.data.planar.parenty = 0;
110
111 paint(self->rgrip, g);
112 }
113 }
114
115 static void obrender_label(ObFrame *self, Appearance *a)
116 {
117 if (self->label_x < 0) return;
118
119
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);
123
124 paint(self->label, a);
125 }
126
127 static void obrender_icon(ObFrame *self, Appearance *a)
128 {
129 if (self->icon_x < 0) return;
130
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);
139 } else
140 a->texture[0].type = NoTexture;
141
142 paint(self->icon, a);
143 }
144
145 static void obrender_max(ObFrame *self, Appearance *a)
146 {
147 if (self->max_x < 0) return;
148
149 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
150 paint(self->max, a);
151 }
152
153 static void obrender_iconify(ObFrame *self, Appearance *a)
154 {
155 if (self->iconify_x < 0) return;
156
157 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
158 paint(self->iconify, a);
159 }
160
161 static void obrender_desk(ObFrame *self, Appearance *a)
162 {
163 if (self->desk_x < 0) return;
164
165 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
166 paint(self->desk, a);
167 }
168
169 static void obrender_close(ObFrame *self, Appearance *a)
170 {
171 if (self->close_x < 0) return;
172
173 RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
174 paint(self->close, a);
175 }
This page took 0.050525 seconds and 5 git commands to generate.