4 #include "framerender.h"
5 #include "render/theme.h"
7 static void framerender_label(ObFrame
*self
, RrAppearance
*a
);
8 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
);
9 static void framerender_max(ObFrame
*self
, RrAppearance
*a
);
10 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
);
11 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
);
12 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
);
13 static void framerender_close(ObFrame
*self
, RrAppearance
*a
);
15 void framerender_frame(ObFrame
*self
)
18 XSetWindowBorder(ob_display
, self
->plate
,
19 ob_rr_theme
->cb_focused_color
->pixel
);
21 XSetWindowBorder(ob_display
, self
->plate
,
22 ob_rr_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 ob_rr_theme
->a_focused_pressed_set_max
:
35 ob_rr_theme
->a_focused_pressed_max
:
36 ob_rr_theme
->a_focused_unpressed_max
)) :
37 (self
->client
->max_vert
|| self
->client
->max_horz
?
38 ob_rr_theme
->a_unfocused_pressed_set_max
:
40 ob_rr_theme
->a_unfocused_pressed_max
:
41 ob_rr_theme
->a_unfocused_unpressed_max
)));
44 (self
->iconify_press
?
45 ob_rr_theme
->a_focused_pressed_iconify
:
46 ob_rr_theme
->a_focused_unpressed_iconify
) :
47 (self
->iconify_press
?
48 ob_rr_theme
->a_unfocused_pressed_iconify
:
49 ob_rr_theme
->a_unfocused_unpressed_iconify
));
51 (self
->client
->desktop
== DESKTOP_ALL
?
52 ob_rr_theme
->a_focused_pressed_set_desk
:
54 ob_rr_theme
->a_focused_pressed_desk
:
55 ob_rr_theme
->a_focused_unpressed_desk
)) :
56 (self
->client
->desktop
== DESKTOP_ALL
?
57 ob_rr_theme
->a_unfocused_pressed_set_desk
:
59 ob_rr_theme
->a_unfocused_pressed_desk
:
60 ob_rr_theme
->a_unfocused_unpressed_desk
)));
62 (self
->client
->shaded
?
63 ob_rr_theme
->a_focused_pressed_set_shade
:
65 ob_rr_theme
->a_focused_pressed_shade
:
66 ob_rr_theme
->a_focused_unpressed_shade
)) :
67 (self
->client
->shaded
?
68 ob_rr_theme
->a_unfocused_pressed_set_shade
:
70 ob_rr_theme
->a_unfocused_pressed_shade
:
71 ob_rr_theme
->a_unfocused_unpressed_shade
)));
74 ob_rr_theme
->a_focused_pressed_close
:
75 ob_rr_theme
->a_focused_unpressed_close
) :
77 ob_rr_theme
->a_unfocused_pressed_close
:
78 ob_rr_theme
->a_unfocused_unpressed_close
));
80 RrPaint(t
, self
->title
, self
->width
, ob_rr_theme
->title_height
);
82 /* set parents for any parent relative guys */
83 l
->surface
.parent
= t
;
84 l
->surface
.parentx
= self
->label_x
;
85 l
->surface
.parenty
= ob_rr_theme
->bevel
;
87 m
->surface
.parent
= t
;
88 m
->surface
.parentx
= self
->max_x
;
89 m
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
91 n
->surface
.parent
= t
;
92 n
->surface
.parentx
= self
->icon_x
;
93 n
->surface
.parenty
= ob_rr_theme
->bevel
;
95 i
->surface
.parent
= t
;
96 i
->surface
.parentx
= self
->iconify_x
;
97 i
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
99 d
->surface
.parent
= t
;
100 d
->surface
.parentx
= self
->desk_x
;
101 d
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
103 s
->surface
.parent
= t
;
104 s
->surface
.parentx
= self
->shade_x
;
105 s
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
107 c
->surface
.parent
= t
;
108 c
->surface
.parentx
= self
->close_x
;
109 c
->surface
.parenty
= ob_rr_theme
->bevel
+ 1;
111 framerender_label(self
, l
);
112 framerender_max(self
, m
);
113 framerender_icon(self
, n
);
114 framerender_iconify(self
, i
);
115 framerender_desk(self
, d
);
116 framerender_shade(self
, s
);
117 framerender_close(self
, c
);
120 if (self
->client
->decorations
& Decor_Handle
) {
124 self
->a_focused_handle
: self
->a_unfocused_handle
);
126 RrPaint(h
, self
->handle
, self
->width
, ob_rr_theme
->handle_height
);
129 ob_rr_theme
->a_focused_grip
: ob_rr_theme
->a_unfocused_grip
);
131 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
132 g
->surface
.parent
= h
;
134 g
->surface
.parentx
= 0;
135 g
->surface
.parenty
= 0;
137 RrPaint(g
, self
->lgrip
,
138 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
140 g
->surface
.parentx
= self
->width
- ob_rr_theme
->grip_width
;
141 g
->surface
.parenty
= 0;
143 RrPaint(g
, self
->rgrip
,
144 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
148 static void framerender_label(ObFrame
*self
, RrAppearance
*a
)
150 if (self
->label_x
< 0) return;
151 /* set the texture's text! */
152 a
->texture
[0].data
.text
.string
= self
->client
->title
;
153 RrPaint(a
, self
->label
, self
->label_width
, ob_rr_theme
->label_height
);
156 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
)
158 if (self
->icon_x
< 0) return;
160 if (self
->client
->nicons
) {
161 ObClientIcon
*icon
= client_icon(self
->client
,
162 ob_rr_theme
->button_size
+ 2,
163 ob_rr_theme
->button_size
+ 2);
164 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
165 a
->texture
[0].data
.rgba
.width
= icon
->width
;
166 a
->texture
[0].data
.rgba
.height
= icon
->height
;
167 a
->texture
[0].data
.rgba
.data
= icon
->data
;
169 a
->texture
[0].type
= RR_TEXTURE_NONE
;
171 RrPaint(a
, self
->icon
,
172 ob_rr_theme
->button_size
+ 2, ob_rr_theme
->button_size
+ 2);
175 static void framerender_max(ObFrame
*self
, RrAppearance
*a
)
177 if (self
->max_x
< 0) return;
178 RrPaint(a
, self
->max
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
181 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
)
183 if (self
->iconify_x
< 0) return;
184 RrPaint(a
, self
->iconify
,
185 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
188 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
)
190 if (self
->desk_x
< 0) return;
191 RrPaint(a
, self
->desk
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
194 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
)
196 if (self
->shade_x
< 0) return;
197 RrPaint(a
, self
->shade
,
198 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
201 static void framerender_close(ObFrame
*self
, RrAppearance
*a
)
203 if (self
->close_x
< 0) return;
204 RrPaint(a
, self
->close
,
205 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);