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
:
41 ob_rr_theme
->a_focused_unpressed_max
)) :
42 (self
->client
->max_vert
|| self
->client
->max_horz
?
43 ob_rr_theme
->a_unfocused_pressed_set_max
:
45 ob_rr_theme
->a_unfocused_pressed_max
:
46 ob_rr_theme
->a_unfocused_unpressed_max
))));
48 i
= (!(self
->decorations
& OB_FRAME_DECOR_ICONIFY
) ?
50 ob_rr_theme
->a_disabled_focused_iconify
:
51 ob_rr_theme
->a_disabled_unfocused_iconify
) :
53 (self
->iconify_press
?
54 ob_rr_theme
->a_focused_pressed_iconify
:
55 ob_rr_theme
->a_focused_unpressed_iconify
) :
56 (self
->iconify_press
?
57 ob_rr_theme
->a_unfocused_pressed_iconify
:
58 ob_rr_theme
->a_unfocused_unpressed_iconify
)));
59 d
= (!(self
->decorations
& OB_FRAME_DECOR_ALLDESKTOPS
) ?
61 ob_rr_theme
->a_disabled_focused_desk
:
62 ob_rr_theme
->a_disabled_unfocused_desk
) :
64 (self
->client
->desktop
== DESKTOP_ALL
?
65 ob_rr_theme
->a_focused_pressed_set_desk
:
67 ob_rr_theme
->a_focused_pressed_desk
:
68 ob_rr_theme
->a_focused_unpressed_desk
)) :
69 (self
->client
->desktop
== DESKTOP_ALL
?
70 ob_rr_theme
->a_unfocused_pressed_set_desk
:
72 ob_rr_theme
->a_unfocused_pressed_desk
:
73 ob_rr_theme
->a_unfocused_unpressed_desk
))));
74 s
= (!(self
->decorations
& OB_FRAME_DECOR_SHADE
) ?
76 ob_rr_theme
->a_disabled_focused_shade
:
77 ob_rr_theme
->a_disabled_unfocused_shade
) :
79 (self
->client
->shaded
?
80 ob_rr_theme
->a_focused_pressed_set_shade
:
82 ob_rr_theme
->a_focused_pressed_shade
:
83 ob_rr_theme
->a_focused_unpressed_shade
)) :
84 (self
->client
->shaded
?
85 ob_rr_theme
->a_unfocused_pressed_set_shade
:
87 ob_rr_theme
->a_unfocused_pressed_shade
:
88 ob_rr_theme
->a_unfocused_unpressed_shade
))));
89 c
= (!(self
->decorations
& OB_FRAME_DECOR_CLOSE
) ?
91 ob_rr_theme
->a_disabled_focused_close
:
92 ob_rr_theme
->a_disabled_unfocused_close
) :
95 ob_rr_theme
->a_focused_pressed_close
:
96 ob_rr_theme
->a_focused_unpressed_close
) :
98 ob_rr_theme
->a_unfocused_pressed_close
:
99 ob_rr_theme
->a_unfocused_unpressed_close
)));
101 RrPaint(t
, self
->title
, self
->width
, ob_rr_theme
->title_height
);
103 /* set parents for any parent relative guys */
104 l
->surface
.parent
= t
;
105 l
->surface
.parentx
= self
->label_x
;
106 l
->surface
.parenty
= ob_rr_theme
->bevel
;
108 m
->surface
.parent
= t
;
109 m
->surface
.parentx
= self
->max_x
;
110 m
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
112 n
->surface
.parent
= t
;
113 n
->surface
.parentx
= self
->icon_x
;
114 n
->surface
.parenty
= ob_rr_theme
->bevel
;
116 i
->surface
.parent
= t
;
117 i
->surface
.parentx
= self
->iconify_x
;
118 i
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
120 d
->surface
.parent
= t
;
121 d
->surface
.parentx
= self
->desk_x
;
122 d
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
124 s
->surface
.parent
= t
;
125 s
->surface
.parentx
= self
->shade_x
;
126 s
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
128 c
->surface
.parent
= t
;
129 c
->surface
.parentx
= self
->close_x
;
130 c
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
132 framerender_label(self
, l
);
133 framerender_max(self
, m
);
134 framerender_icon(self
, n
);
135 framerender_iconify(self
, i
);
136 framerender_desk(self
, d
);
137 framerender_shade(self
, s
);
138 framerender_close(self
, c
);
141 if (self
->decorations
& OB_FRAME_DECOR_HANDLE
) {
145 self
->a_focused_handle
: self
->a_unfocused_handle
);
147 RrPaint(h
, self
->handle
, self
->width
, ob_rr_theme
->handle_height
);
149 if (self
->decorations
& OB_FRAME_DECOR_GRIPS
) {
151 ob_rr_theme
->a_focused_grip
: ob_rr_theme
->a_unfocused_grip
);
153 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
154 g
->surface
.parent
= h
;
156 g
->surface
.parentx
= 0;
157 g
->surface
.parenty
= 0;
159 RrPaint(g
, self
->lgrip
,
160 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
162 g
->surface
.parentx
= self
->width
- ob_rr_theme
->grip_width
;
163 g
->surface
.parenty
= 0;
165 RrPaint(g
, self
->rgrip
,
166 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
171 static void framerender_label(ObFrame
*self
, RrAppearance
*a
)
173 if (self
->label_x
< 0) return;
174 /* set the texture's text! */
175 a
->texture
[0].data
.text
.string
= self
->client
->title
;
176 RrPaint(a
, self
->label
, self
->label_width
, ob_rr_theme
->label_height
);
179 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
)
181 if (self
->icon_x
< 0) return;
183 if (self
->client
->nicons
) {
184 ObClientIcon
*icon
= client_icon(self
->client
,
185 ob_rr_theme
->button_size
+ 2,
186 ob_rr_theme
->button_size
+ 2);
187 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
188 a
->texture
[0].data
.rgba
.width
= icon
->width
;
189 a
->texture
[0].data
.rgba
.height
= icon
->height
;
190 a
->texture
[0].data
.rgba
.data
= icon
->data
;
192 a
->texture
[0].type
= RR_TEXTURE_NONE
;
194 RrPaint(a
, self
->icon
,
195 ob_rr_theme
->button_size
+ 2, ob_rr_theme
->button_size
+ 2);
198 static void framerender_max(ObFrame
*self
, RrAppearance
*a
)
200 if (self
->max_x
< 0) return;
201 RrPaint(a
, self
->max
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
204 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
)
206 if (self
->iconify_x
< 0) return;
207 RrPaint(a
, self
->iconify
,
208 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
211 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
)
213 if (self
->desk_x
< 0) return;
214 RrPaint(a
, self
->desk
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
217 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
)
219 if (self
->shade_x
< 0) return;
220 RrPaint(a
, self
->shade
,
221 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
224 static void framerender_close(ObFrame
*self
, RrAppearance
*a
)
226 if (self
->close_x
< 0) return;
227 RrPaint(a
, self
->close
,
228 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);