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_shade(ObFrame
*self
, Appearance
*a
);
11 static void obrender_close(ObFrame
*self
, Appearance
*a
);
13 void obrender_frame(ObFrame
*self
)
15 if (client_focused(self
->frame
.client
)) {
16 XSetWindowBorder(ob_display
, self
->frame
.plate
,
17 ob_s_cb_focused_color
->pixel
);
19 XSetWindowBorder(ob_display
, self
->frame
.plate
,
20 ob_s_cb_unfocused_color
->pixel
);
23 if (self
->frame
.client
->decorations
& Decor_Titlebar
) {
24 Appearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
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
:
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
:
38 ob_a_unfocused_pressed_max
: ob_a_unfocused_unpressed_max
)));
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
:
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
:
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
:
59 ob_a_focused_pressed_shade
: ob_a_focused_unpressed_shade
)) :
60 (self
->frame
.client
->shaded
?
61 ob_a_unfocused_pressed_set_shade
:
63 ob_a_unfocused_pressed_shade
:ob_a_unfocused_unpressed_shade
)));
64 c
= (client_focused(self
->frame
.client
) ?
66 ob_a_focused_pressed_close
: ob_a_focused_unpressed_close
) :
68 ob_a_unfocused_pressed_close
: ob_a_unfocused_unpressed_close
));
70 paint(self
->title
, t
);
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
;
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;
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;
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;
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;
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;
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;
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
);
110 if (self
->frame
.client
->decorations
& Decor_Handle
) {
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
);
118 if (g
->surface
.data
.planar
.grad
== Background_ParentRelative
) {
119 g
->surface
.data
.planar
.parent
= h
;
120 paint(self
->handle
, h
);
122 paint(self
->handle
, h
);
124 g
->surface
.data
.planar
.parentx
= 0;
125 g
->surface
.data
.planar
.parenty
= 0;
127 paint(self
->lgrip
, g
);
129 g
->surface
.data
.planar
.parentx
= self
->width
- GRIP_WIDTH
;
130 g
->surface
.data
.planar
.parenty
= 0;
132 paint(self
->rgrip
, g
);
136 static void obrender_label(ObFrame
*self
, Appearance
*a
)
138 if (self
->label_x
< 0) return;
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
);
145 paint(self
->label
, a
);
148 static void obrender_icon(ObFrame
*self
, Appearance
*a
)
150 if (self
->icon_x
< 0) return;
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
);
161 a
->texture
[0].type
= NoTexture
;
163 paint(self
->icon
, a
);
166 static void obrender_max(ObFrame
*self
, Appearance
*a
)
168 if (self
->max_x
< 0) return;
170 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
174 static void obrender_iconify(ObFrame
*self
, Appearance
*a
)
176 if (self
->iconify_x
< 0) return;
178 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
179 paint(self
->iconify
, a
);
182 static void obrender_desk(ObFrame
*self
, Appearance
*a
)
184 if (self
->desk_x
< 0) return;
186 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
187 paint(self
->desk
, a
);
190 static void obrender_shade(ObFrame
*self
, Appearance
*a
)
192 if (self
->shade_x
< 0) return;
194 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
195 paint(self
->shade
, a
);
198 static void obrender_close(ObFrame
*self
, Appearance
*a
)
200 if (self
->close_x
< 0) return;
202 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
203 paint(self
->close
, a
);