4 #include "framerender.h"
5 #include "render/theme.h"
7 static void framerender_label(Frame
*self
, RrAppearance
*a
);
8 static void framerender_icon(Frame
*self
, RrAppearance
*a
);
9 static void framerender_max(Frame
*self
, RrAppearance
*a
);
10 static void framerender_iconify(Frame
*self
, RrAppearance
*a
);
11 static void framerender_desk(Frame
*self
, RrAppearance
*a
);
12 static void framerender_shade(Frame
*self
, RrAppearance
*a
);
13 static void framerender_close(Frame
*self
, RrAppearance
*a
);
15 void framerender_frame(Frame
*self
)
18 XSetWindowBorder(ob_display
, self
->plate
,
19 theme_cb_focused_color
->pixel
);
21 XSetWindowBorder(ob_display
, self
->plate
,
22 theme_cb_unfocused_color
->pixel
);
24 if (self
->client
->decorations
& Decor_Titlebar
) {
25 RrAppearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
28 self
->a_focused_title
: self
->a_unfocused_title
);
30 self
->a_focused_label
: self
->a_unfocused_label
);
32 (self
->client
->max_vert
|| self
->client
->max_horz
?
33 theme_a_focused_pressed_set_max
:
35 theme_a_focused_pressed_max
: theme_a_focused_unpressed_max
)) :
36 (self
->client
->max_vert
|| self
->client
->max_horz
?
37 theme_a_unfocused_pressed_set_max
:
39 theme_a_unfocused_pressed_max
:
40 theme_a_unfocused_unpressed_max
)));
43 (self
->iconify_press
?
44 theme_a_focused_pressed_iconify
:
45 theme_a_focused_unpressed_iconify
) :
46 (self
->iconify_press
?
47 theme_a_unfocused_pressed_iconify
:
48 theme_a_unfocused_unpressed_iconify
));
50 (self
->client
->desktop
== DESKTOP_ALL
?
51 theme_a_focused_pressed_set_desk
:
53 theme_a_focused_pressed_desk
:
54 theme_a_focused_unpressed_desk
)) :
55 (self
->client
->desktop
== DESKTOP_ALL
?
56 theme_a_unfocused_pressed_set_desk
:
58 theme_a_unfocused_pressed_desk
:
59 theme_a_unfocused_unpressed_desk
)));
61 (self
->client
->shaded
?
62 theme_a_focused_pressed_set_shade
:
64 theme_a_focused_pressed_shade
:
65 theme_a_focused_unpressed_shade
)) :
66 (self
->client
->shaded
?
67 theme_a_unfocused_pressed_set_shade
:
69 theme_a_unfocused_pressed_shade
:
70 theme_a_unfocused_unpressed_shade
)));
73 theme_a_focused_pressed_close
:
74 theme_a_focused_unpressed_close
) :
76 theme_a_unfocused_pressed_close
:
77 theme_a_unfocused_unpressed_close
));
79 RrPaint(t
, self
->title
, self
->width
, theme_title_height
);
81 /* set parents for any parent relative guys */
82 l
->surface
.parent
= t
;
83 l
->surface
.parentx
= self
->label_x
;
84 l
->surface
.parenty
= theme_bevel
;
86 m
->surface
.parent
= t
;
87 m
->surface
.parentx
= self
->max_x
;
88 m
->surface
.parenty
= theme_bevel
+ 1;
90 n
->surface
.parent
= t
;
91 n
->surface
.parentx
= self
->icon_x
;
92 n
->surface
.parenty
= theme_bevel
;
94 i
->surface
.parent
= t
;
95 i
->surface
.parentx
= self
->iconify_x
;
96 i
->surface
.parenty
= theme_bevel
+ 1;
98 d
->surface
.parent
= t
;
99 d
->surface
.parentx
= self
->desk_x
;
100 d
->surface
.parenty
= theme_bevel
+ 1;
102 s
->surface
.parent
= t
;
103 s
->surface
.parentx
= self
->shade_x
;
104 s
->surface
.parenty
= theme_bevel
+ 1;
106 c
->surface
.parent
= t
;
107 c
->surface
.parentx
= self
->close_x
;
108 c
->surface
.parenty
= theme_bevel
+ 1;
110 framerender_label(self
, l
);
111 framerender_max(self
, m
);
112 framerender_icon(self
, n
);
113 framerender_iconify(self
, i
);
114 framerender_desk(self
, d
);
115 framerender_shade(self
, s
);
116 framerender_close(self
, c
);
119 if (self
->client
->decorations
& Decor_Handle
) {
123 self
->a_focused_handle
: self
->a_unfocused_handle
);
125 RrPaint(h
, self
->handle
, self
->width
, theme_handle_height
);
128 theme_a_focused_grip
: theme_a_unfocused_grip
);
130 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
131 g
->surface
.parent
= h
;
133 g
->surface
.parentx
= 0;
134 g
->surface
.parenty
= 0;
136 RrPaint(g
, self
->lgrip
, theme_grip_width
, theme_handle_height
);
138 g
->surface
.parentx
= self
->width
- theme_grip_width
;
139 g
->surface
.parenty
= 0;
141 RrPaint(g
, self
->rgrip
, theme_grip_width
, theme_handle_height
);
145 static void framerender_label(Frame
*self
, RrAppearance
*a
)
147 if (self
->label_x
< 0) return;
148 /* set the texture's text! */
149 a
->texture
[0].data
.text
.string
= self
->client
->title
;
150 RrPaint(a
, self
->label
, self
->label_width
, theme_label_height
);
153 static void framerender_icon(Frame
*self
, RrAppearance
*a
)
155 if (self
->icon_x
< 0) return;
157 if (self
->client
->nicons
) {
158 Icon
*icon
= client_icon(self
->client
,
159 theme_button_size
+ 2, theme_button_size
+ 2);
160 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
161 a
->texture
[0].data
.rgba
.width
= icon
->width
;
162 a
->texture
[0].data
.rgba
.height
= icon
->height
;
163 a
->texture
[0].data
.rgba
.data
= icon
->data
;
165 a
->texture
[0].type
= RR_TEXTURE_NONE
;
167 RrPaint(a
, self
->icon
, theme_button_size
+ 2, theme_button_size
+ 2);
170 static void framerender_max(Frame
*self
, RrAppearance
*a
)
172 if (self
->max_x
< 0) return;
173 RrPaint(a
, self
->max
, theme_button_size
, theme_button_size
);
176 static void framerender_iconify(Frame
*self
, RrAppearance
*a
)
178 if (self
->iconify_x
< 0) return;
179 RrPaint(a
, self
->iconify
, theme_button_size
, theme_button_size
);
182 static void framerender_desk(Frame
*self
, RrAppearance
*a
)
184 if (self
->desk_x
< 0) return;
185 RrPaint(a
, self
->desk
, theme_button_size
, theme_button_size
);
188 static void framerender_shade(Frame
*self
, RrAppearance
*a
)
190 if (self
->shade_x
< 0) return;
191 RrPaint(a
, self
->shade
, theme_button_size
, theme_button_size
);
194 static void framerender_close(Frame
*self
, RrAppearance
*a
)
196 if (self
->close_x
< 0) return;
197 RrPaint(a
, self
->close
, theme_button_size
, theme_button_size
);