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
)
22 RrColorPixel(ob_rr_theme
->cb_focused_color
) :
23 RrColorPixel(ob_rr_theme
->cb_unfocused_color
));
24 XSetWindowBackground(ob_display
, self
->plate
, px
);
25 XClearWindow(ob_display
, self
->plate
);
28 if (self
->decorations
& OB_FRAME_DECOR_TITLEBAR
) {
29 RrAppearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
32 self
->a_focused_title
: self
->a_unfocused_title
);
34 self
->a_focused_label
: self
->a_unfocused_label
);
35 m
= (!(self
->decorations
& OB_FRAME_DECOR_MAXIMIZE
) ?
37 ob_rr_theme
->a_disabled_focused_max
:
38 ob_rr_theme
->a_disabled_unfocused_max
) :
40 (self
->client
->max_vert
|| self
->client
->max_horz
?
41 ob_rr_theme
->a_toggled_focused_max
:
43 ob_rr_theme
->a_focused_pressed_max
:
45 ob_rr_theme
->a_hover_focused_max
:
46 ob_rr_theme
->a_focused_unpressed_max
))) :
47 (self
->client
->max_vert
|| self
->client
->max_horz
?
48 ob_rr_theme
->a_toggled_unfocused_max
:
50 ob_rr_theme
->a_unfocused_pressed_max
:
52 ob_rr_theme
->a_hover_unfocused_max
:
53 ob_rr_theme
->a_unfocused_unpressed_max
)))));
55 i
= (!(self
->decorations
& OB_FRAME_DECOR_ICONIFY
) ?
57 ob_rr_theme
->a_disabled_focused_iconify
:
58 ob_rr_theme
->a_disabled_unfocused_iconify
) :
60 (self
->iconify_press
?
61 ob_rr_theme
->a_focused_pressed_iconify
:
62 (self
->iconify_hover
?
63 ob_rr_theme
->a_hover_focused_iconify
:
64 ob_rr_theme
->a_focused_unpressed_iconify
)) :
65 (self
->iconify_press
?
66 ob_rr_theme
->a_unfocused_pressed_iconify
:
67 (self
->iconify_hover
?
68 ob_rr_theme
->a_hover_unfocused_iconify
:
69 ob_rr_theme
->a_unfocused_unpressed_iconify
))));
70 d
= (!(self
->decorations
& OB_FRAME_DECOR_ALLDESKTOPS
) ?
72 ob_rr_theme
->a_disabled_focused_desk
:
73 ob_rr_theme
->a_disabled_unfocused_desk
) :
75 (self
->client
->desktop
== DESKTOP_ALL
?
76 ob_rr_theme
->a_toggled_focused_desk
:
78 ob_rr_theme
->a_focused_pressed_desk
:
80 ob_rr_theme
->a_hover_focused_desk
:
81 ob_rr_theme
->a_focused_unpressed_desk
))) :
82 (self
->client
->desktop
== DESKTOP_ALL
?
83 ob_rr_theme
->a_toggled_unfocused_desk
:
85 ob_rr_theme
->a_unfocused_pressed_desk
:
87 ob_rr_theme
->a_hover_unfocused_desk
:
88 ob_rr_theme
->a_unfocused_unpressed_desk
)))));
89 s
= (!(self
->decorations
& OB_FRAME_DECOR_SHADE
) ?
91 ob_rr_theme
->a_disabled_focused_shade
:
92 ob_rr_theme
->a_disabled_unfocused_shade
) :
94 (self
->client
->shaded
?
95 ob_rr_theme
->a_toggled_focused_shade
:
97 ob_rr_theme
->a_focused_pressed_shade
:
99 ob_rr_theme
->a_hover_focused_shade
:
100 ob_rr_theme
->a_focused_unpressed_shade
))) :
101 (self
->client
->shaded
?
102 ob_rr_theme
->a_toggled_unfocused_shade
:
104 ob_rr_theme
->a_unfocused_pressed_shade
:
106 ob_rr_theme
->a_hover_unfocused_shade
:
107 ob_rr_theme
->a_unfocused_unpressed_shade
)))));
108 c
= (!(self
->decorations
& OB_FRAME_DECOR_CLOSE
) ?
110 ob_rr_theme
->a_disabled_focused_close
:
111 ob_rr_theme
->a_disabled_unfocused_close
) :
114 ob_rr_theme
->a_focused_pressed_close
:
116 ob_rr_theme
->a_hover_focused_close
:
117 ob_rr_theme
->a_focused_unpressed_close
)) :
119 ob_rr_theme
->a_unfocused_pressed_close
:
121 ob_rr_theme
->a_hover_unfocused_close
:
122 ob_rr_theme
->a_unfocused_unpressed_close
))));
124 RrPaint(t
, self
->title
, self
->width
, ob_rr_theme
->title_height
);
126 ob_rr_theme
->a_clear
->surface
.parent
= t
;
127 ob_rr_theme
->a_clear
->surface
.parentx
= 0;
128 ob_rr_theme
->a_clear
->surface
.parenty
= 0;
130 RrPaint(ob_rr_theme
->a_clear
, self
->tlresize
,
131 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
133 ob_rr_theme
->a_clear
->surface
.parentx
=
134 self
->width
- ob_rr_theme
->grip_width
;
136 RrPaint(ob_rr_theme
->a_clear
, self
->trresize
,
137 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
140 /* set parents for any parent relative guys */
141 l
->surface
.parent
= t
;
142 l
->surface
.parentx
= self
->label_x
;
143 l
->surface
.parenty
= ob_rr_theme
->bevel
;
145 m
->surface
.parent
= t
;
146 m
->surface
.parentx
= self
->max_x
;
147 m
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
149 n
->surface
.parent
= t
;
150 n
->surface
.parentx
= self
->icon_x
;
151 n
->surface
.parenty
= ob_rr_theme
->bevel
;
153 i
->surface
.parent
= t
;
154 i
->surface
.parentx
= self
->iconify_x
;
155 i
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
157 d
->surface
.parent
= t
;
158 d
->surface
.parentx
= self
->desk_x
;
159 d
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
161 s
->surface
.parent
= t
;
162 s
->surface
.parentx
= self
->shade_x
;
163 s
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
165 c
->surface
.parent
= t
;
166 c
->surface
.parentx
= self
->close_x
;
167 c
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
169 framerender_label(self
, l
);
170 framerender_max(self
, m
);
171 framerender_icon(self
, n
);
172 framerender_iconify(self
, i
);
173 framerender_desk(self
, d
);
174 framerender_shade(self
, s
);
175 framerender_close(self
, c
);
178 if (self
->decorations
& OB_FRAME_DECOR_HANDLE
) {
182 self
->a_focused_handle
: self
->a_unfocused_handle
);
184 RrPaint(h
, self
->handle
, self
->width
, ob_rr_theme
->handle_height
);
186 if (self
->decorations
& OB_FRAME_DECOR_GRIPS
) {
188 ob_rr_theme
->a_focused_grip
: ob_rr_theme
->a_unfocused_grip
);
190 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
191 g
->surface
.parent
= h
;
193 g
->surface
.parentx
= 0;
194 g
->surface
.parenty
= 0;
196 RrPaint(g
, self
->lgrip
,
197 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
199 g
->surface
.parentx
= self
->width
- ob_rr_theme
->grip_width
;
200 g
->surface
.parenty
= 0;
202 RrPaint(g
, self
->rgrip
,
203 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
208 static void framerender_label(ObFrame
*self
, RrAppearance
*a
)
210 if (self
->label_x
< 0) return;
211 /* set the texture's text! */
212 a
->texture
[0].data
.text
.string
= self
->client
->title
;
213 RrPaint(a
, self
->label
, self
->label_width
, ob_rr_theme
->label_height
);
216 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
)
218 if (self
->icon_x
< 0) return;
220 if (self
->client
->nicons
) {
221 ObClientIcon
*icon
= client_icon(self
->client
,
222 ob_rr_theme
->button_size
+ 2,
223 ob_rr_theme
->button_size
+ 2);
224 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
225 a
->texture
[0].data
.rgba
.width
= icon
->width
;
226 a
->texture
[0].data
.rgba
.height
= icon
->height
;
227 a
->texture
[0].data
.rgba
.data
= icon
->data
;
229 a
->texture
[0].type
= RR_TEXTURE_NONE
;
231 RrPaint(a
, self
->icon
,
232 ob_rr_theme
->button_size
+ 2, ob_rr_theme
->button_size
+ 2);
235 static void framerender_max(ObFrame
*self
, RrAppearance
*a
)
237 if (self
->max_x
< 0) return;
238 RrPaint(a
, self
->max
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
241 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
)
243 if (self
->iconify_x
< 0) return;
244 RrPaint(a
, self
->iconify
,
245 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
248 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
)
250 if (self
->desk_x
< 0) return;
251 RrPaint(a
, self
->desk
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
254 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
)
256 if (self
->shade_x
< 0) return;
257 RrPaint(a
, self
->shade
,
258 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
261 static void framerender_close(ObFrame
*self
, RrAppearance
*a
)
263 if (self
->close_x
< 0) return;
264 RrPaint(a
, self
->close
,
265 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);