5 #include "framerender.h"
6 #include "render/theme.h"
8 static void framerender_label(ObFrame
*self
, RrAppearance
*a
);
9 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
);
10 static void framerender_max(ObFrame
*self
, RrAppearance
*a
);
11 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
);
12 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
);
13 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
);
14 static void framerender_close(ObFrame
*self
, RrAppearance
*a
);
16 void framerender_frame(ObFrame
*self
)
19 XSetWindowBorder(ob_display
, self
->plate
,
20 RrColorPixel(ob_rr_theme
->cb_focused_color
));
22 XSetWindowBorder(ob_display
, self
->plate
,
23 RrColorPixel(ob_rr_theme
->cb_unfocused_color
));
25 if (self
->decorations
& OB_FRAME_DECOR_TITLEBAR
) {
26 RrAppearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
29 self
->a_focused_title
: self
->a_unfocused_title
);
31 self
->a_focused_label
: self
->a_unfocused_label
);
32 m
= (!(self
->decorations
& OB_FRAME_DECOR_MAXIMIZE
) ?
34 ob_rr_theme
->a_disabled_focused_max
:
35 ob_rr_theme
->a_disabled_unfocused_max
) :
37 (self
->client
->max_vert
|| self
->client
->max_horz
?
38 ob_rr_theme
->a_focused_pressed_set_max
:
40 ob_rr_theme
->a_focused_pressed_max
:
42 ob_rr_theme
->a_hover_focused_max
:
43 ob_rr_theme
->a_focused_unpressed_max
))) :
44 (self
->client
->max_vert
|| self
->client
->max_horz
?
45 ob_rr_theme
->a_unfocused_pressed_set_max
:
47 ob_rr_theme
->a_unfocused_pressed_max
:
49 ob_rr_theme
->a_hover_unfocused_max
:
50 ob_rr_theme
->a_unfocused_unpressed_max
)))));
52 i
= (!(self
->decorations
& OB_FRAME_DECOR_ICONIFY
) ?
54 ob_rr_theme
->a_disabled_focused_iconify
:
55 ob_rr_theme
->a_disabled_unfocused_iconify
) :
57 (self
->iconify_press
?
58 ob_rr_theme
->a_focused_pressed_iconify
:
59 (self
->iconify_hover
?
60 ob_rr_theme
->a_hover_focused_iconify
:
61 ob_rr_theme
->a_focused_unpressed_iconify
)) :
62 (self
->iconify_press
?
63 ob_rr_theme
->a_unfocused_pressed_iconify
:
64 (self
->iconify_hover
?
65 ob_rr_theme
->a_hover_unfocused_iconify
:
66 ob_rr_theme
->a_unfocused_unpressed_iconify
))));
67 d
= (!(self
->decorations
& OB_FRAME_DECOR_ALLDESKTOPS
) ?
69 ob_rr_theme
->a_disabled_focused_desk
:
70 ob_rr_theme
->a_disabled_unfocused_desk
) :
72 (self
->client
->desktop
== DESKTOP_ALL
?
73 ob_rr_theme
->a_focused_pressed_set_desk
:
75 ob_rr_theme
->a_focused_pressed_desk
:
77 ob_rr_theme
->a_hover_focused_desk
:
78 ob_rr_theme
->a_focused_unpressed_desk
))) :
79 (self
->client
->desktop
== DESKTOP_ALL
?
80 ob_rr_theme
->a_unfocused_pressed_set_desk
:
82 ob_rr_theme
->a_unfocused_pressed_desk
:
84 ob_rr_theme
->a_hover_unfocused_desk
:
85 ob_rr_theme
->a_unfocused_unpressed_desk
)))));
86 s
= (!(self
->decorations
& OB_FRAME_DECOR_SHADE
) ?
88 ob_rr_theme
->a_disabled_focused_shade
:
89 ob_rr_theme
->a_disabled_unfocused_shade
) :
91 (self
->client
->shaded
?
92 ob_rr_theme
->a_focused_pressed_set_shade
:
94 ob_rr_theme
->a_focused_pressed_shade
:
96 ob_rr_theme
->a_hover_focused_shade
:
97 ob_rr_theme
->a_focused_unpressed_shade
))) :
98 (self
->client
->shaded
?
99 ob_rr_theme
->a_unfocused_pressed_set_shade
:
101 ob_rr_theme
->a_unfocused_pressed_shade
:
103 ob_rr_theme
->a_hover_unfocused_shade
:
104 ob_rr_theme
->a_unfocused_unpressed_shade
)))));
105 c
= (!(self
->decorations
& OB_FRAME_DECOR_CLOSE
) ?
107 ob_rr_theme
->a_disabled_focused_close
:
108 ob_rr_theme
->a_disabled_unfocused_close
) :
111 ob_rr_theme
->a_focused_pressed_close
:
113 ob_rr_theme
->a_hover_focused_close
:
114 ob_rr_theme
->a_focused_unpressed_close
)) :
116 ob_rr_theme
->a_unfocused_pressed_close
:
118 ob_rr_theme
->a_hover_unfocused_close
:
119 ob_rr_theme
->a_unfocused_unpressed_close
))));
121 RrPaint(t
, self
->title
, self
->width
, ob_rr_theme
->title_height
);
123 /* set parents for any parent relative guys */
124 l
->surface
.parent
= t
;
125 l
->surface
.parentx
= self
->label_x
;
126 l
->surface
.parenty
= ob_rr_theme
->bevel
;
128 m
->surface
.parent
= t
;
129 m
->surface
.parentx
= self
->max_x
;
130 m
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
132 n
->surface
.parent
= t
;
133 n
->surface
.parentx
= self
->icon_x
;
134 n
->surface
.parenty
= ob_rr_theme
->bevel
;
136 i
->surface
.parent
= t
;
137 i
->surface
.parentx
= self
->iconify_x
;
138 i
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
140 d
->surface
.parent
= t
;
141 d
->surface
.parentx
= self
->desk_x
;
142 d
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
144 s
->surface
.parent
= t
;
145 s
->surface
.parentx
= self
->shade_x
;
146 s
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
148 c
->surface
.parent
= t
;
149 c
->surface
.parentx
= self
->close_x
;
150 c
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
152 framerender_label(self
, l
);
153 framerender_max(self
, m
);
154 framerender_icon(self
, n
);
155 framerender_iconify(self
, i
);
156 framerender_desk(self
, d
);
157 framerender_shade(self
, s
);
158 framerender_close(self
, c
);
161 if (self
->decorations
& OB_FRAME_DECOR_HANDLE
) {
165 self
->a_focused_handle
: self
->a_unfocused_handle
);
167 RrPaint(h
, self
->handle
, self
->width
, ob_rr_theme
->handle_height
);
169 if (self
->decorations
& OB_FRAME_DECOR_GRIPS
) {
171 ob_rr_theme
->a_focused_grip
: ob_rr_theme
->a_unfocused_grip
);
173 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
174 g
->surface
.parent
= h
;
176 g
->surface
.parentx
= 0;
177 g
->surface
.parenty
= 0;
179 RrPaint(g
, self
->lgrip
,
180 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
182 g
->surface
.parentx
= self
->width
- ob_rr_theme
->grip_width
;
183 g
->surface
.parenty
= 0;
185 RrPaint(g
, self
->rgrip
,
186 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
191 static void framerender_label(ObFrame
*self
, RrAppearance
*a
)
193 if (self
->label_x
< 0) return;
194 /* set the texture's text! */
195 a
->texture
[0].data
.text
.string
= self
->client
->title
;
196 RrPaint(a
, self
->label
, self
->label_width
, ob_rr_theme
->label_height
);
199 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
)
201 if (self
->icon_x
< 0) return;
203 if (self
->client
->nicons
) {
204 ObClientIcon
*icon
= client_icon(self
->client
,
205 ob_rr_theme
->button_size
+ 2,
206 ob_rr_theme
->button_size
+ 2);
207 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
208 a
->texture
[0].data
.rgba
.width
= icon
->width
;
209 a
->texture
[0].data
.rgba
.height
= icon
->height
;
210 a
->texture
[0].data
.rgba
.data
= icon
->data
;
212 a
->texture
[0].type
= RR_TEXTURE_NONE
;
214 RrPaint(a
, self
->icon
,
215 ob_rr_theme
->button_size
+ 2, ob_rr_theme
->button_size
+ 2);
218 static void framerender_max(ObFrame
*self
, RrAppearance
*a
)
220 if (self
->max_x
< 0) return;
221 RrPaint(a
, self
->max
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
224 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
)
226 if (self
->iconify_x
< 0) return;
227 RrPaint(a
, self
->iconify
,
228 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
231 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
)
233 if (self
->desk_x
< 0) return;
234 RrPaint(a
, self
->desk
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
237 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
)
239 if (self
->shade_x
< 0) return;
240 RrPaint(a
, self
->shade
,
241 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
244 static void framerender_close(ObFrame
*self
, RrAppearance
*a
)
246 if (self
->close_x
< 0) return;
247 RrPaint(a
, self
->close
,
248 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);