2 #include "../../kernel/openbox.h"
3 #include "../../kernel/screen.h"
5 static void render_label(ObFrame
*self
, Appearance
*a
);
6 static void render_max(ObFrame
*self
, Appearance
*a
);
7 static void render_icon(ObFrame
*self
, Appearance
*a
);
8 static void render_iconify(ObFrame
*self
, Appearance
*a
);
9 static void render_desk(ObFrame
*self
, Appearance
*a
);
10 static void render_close(ObFrame
*self
, Appearance
*a
);
12 void render_frame(ObFrame
*self
)
14 if (client_focused(self
->frame
.client
)) {
15 XSetWindowBorder(ob_display
, self
->frame
.plate
,
16 s_cb_focused_color
->pixel
);
18 XSetWindowBorder(ob_display
, self
->frame
.plate
,
19 s_cb_unfocused_color
->pixel
);
22 if (self
->frame
.client
->decorations
& Decor_Titlebar
) {
23 Appearance
*t
, *l
, *m
, *n
, *i
, *d
, *c
;
25 t
= (client_focused(self
->frame
.client
) ?
26 self
->a_focused_title
: self
->a_unfocused_title
);
27 l
= (client_focused(self
->frame
.client
) ?
28 self
->a_focused_label
: self
->a_unfocused_label
);
29 m
= (client_focused(self
->frame
.client
) ?
31 self
->frame
.client
->max_vert
|| self
->frame
.client
->max_horz
) ?
32 a_focused_pressed_max
: a_focused_unpressed_max
) :
34 self
->frame
.client
->max_vert
|| self
->frame
.client
->max_horz
) ?
35 a_unfocused_pressed_max
: a_unfocused_unpressed_max
));
37 i
= (client_focused(self
->frame
.client
) ?
38 (self
->iconify_press
?
39 a_focused_pressed_iconify
: a_focused_unpressed_iconify
) :
40 (self
->iconify_press
?
41 a_unfocused_pressed_iconify
: a_unfocused_unpressed_iconify
));
42 d
= (client_focused(self
->frame
.client
) ?
43 (self
->desk_press
|| self
->frame
.client
->desktop
== DESKTOP_ALL
?
44 a_focused_pressed_desk
: a_focused_unpressed_desk
) :
45 (self
->desk_press
|| self
->frame
.client
->desktop
== DESKTOP_ALL
?
46 a_unfocused_pressed_desk
: a_unfocused_unpressed_desk
));
47 c
= (client_focused(self
->frame
.client
) ?
49 a_focused_pressed_close
: a_focused_unpressed_close
) :
51 a_unfocused_pressed_close
: a_unfocused_unpressed_close
));
53 paint(self
->title
, t
);
55 /* set parents for any parent relative guys */
56 l
->surface
.data
.planar
.parent
= t
;
57 l
->surface
.data
.planar
.parentx
= self
->label_x
;
58 l
->surface
.data
.planar
.parenty
= s_bevel
;
60 m
->surface
.data
.planar
.parent
= t
;
61 m
->surface
.data
.planar
.parentx
= self
->max_x
;
62 m
->surface
.data
.planar
.parenty
= s_bevel
+ 1;
64 n
->surface
.data
.planar
.parent
= t
;
65 n
->surface
.data
.planar
.parentx
= self
->icon_x
;
66 n
->surface
.data
.planar
.parenty
= s_bevel
+ 1;
68 i
->surface
.data
.planar
.parent
= t
;
69 i
->surface
.data
.planar
.parentx
= self
->iconify_x
;
70 i
->surface
.data
.planar
.parenty
= s_bevel
+ 1;
72 d
->surface
.data
.planar
.parent
= t
;
73 d
->surface
.data
.planar
.parentx
= self
->desk_x
;
74 d
->surface
.data
.planar
.parenty
= s_bevel
+ 1;
76 c
->surface
.data
.planar
.parent
= t
;
77 c
->surface
.data
.planar
.parentx
= self
->close_x
;
78 c
->surface
.data
.planar
.parenty
= s_bevel
+ 1;
80 render_label(self
, l
);
83 render_iconify(self
, i
);
85 render_close(self
, c
);
88 if (self
->frame
.client
->decorations
& Decor_Handle
) {
91 h
= (client_focused(self
->frame
.client
) ?
92 self
->a_focused_handle
: self
->a_unfocused_handle
);
93 g
= (client_focused(self
->frame
.client
) ?
94 a_focused_grip
: a_unfocused_grip
);
96 if (g
->surface
.data
.planar
.grad
== Background_ParentRelative
) {
97 g
->surface
.data
.planar
.parent
= h
;
98 paint(self
->handle
, h
);
100 paint(self
->handle
, h
);
102 g
->surface
.data
.planar
.parentx
= 0;
103 g
->surface
.data
.planar
.parenty
= 0;
105 paint(self
->lgrip
, g
);
107 g
->surface
.data
.planar
.parentx
= self
->width
- GRIP_WIDTH
;
108 g
->surface
.data
.planar
.parenty
= 0;
110 paint(self
->rgrip
, g
);
114 static void render_label(ObFrame
*self
, Appearance
*a
)
116 if (self
->label_x
< 0) return;
119 /* set the texture's text! */
120 a
->texture
[0].data
.text
.string
= self
->frame
.client
->title
;
121 RECT_SET(a
->texture
[0].position
, 0, 0, self
->label_width
, LABEL_HEIGHT
);
123 paint(self
->label
, a
);
126 static void render_icon(ObFrame
*self
, Appearance
*a
)
128 if (self
->icon_x
< 0) return;
130 if (self
->frame
.client
->nicons
) {
131 Icon
*icon
= client_icon(self
->frame
.client
, BUTTON_SIZE
, BUTTON_SIZE
);
132 a
->texture
[0].type
= RGBA
;
133 a
->texture
[0].data
.rgba
.width
= icon
->width
;
134 a
->texture
[0].data
.rgba
.height
= icon
->height
;
135 a
->texture
[0].data
.rgba
.data
= icon
->data
;
136 RECT_SET(self
->a_icon
->texture
[0].position
, 0, 0,
137 BUTTON_SIZE
,BUTTON_SIZE
);
139 a
->texture
[0].type
= NoTexture
;
141 paint(self
->icon
, a
);
144 static void render_max(ObFrame
*self
, Appearance
*a
)
146 if (self
->max_x
< 0) return;
148 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
152 static void render_iconify(ObFrame
*self
, Appearance
*a
)
154 if (self
->iconify_x
< 0) return;
156 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
157 paint(self
->iconify
, a
);
160 static void render_desk(ObFrame
*self
, Appearance
*a
)
162 if (self
->desk_x
< 0) return;
164 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
165 paint(self
->desk
, a
);
168 static void render_close(ObFrame
*self
, Appearance
*a
)
170 if (self
->close_x
< 0) return;
172 RECT_SET(a
->texture
[0].position
, 0, 0, BUTTON_SIZE
,BUTTON_SIZE
);
173 paint(self
->close
, a
);
176 GQuark
get_context(Client
*client
, Window win
)
180 if (win
== ob_root
) return g_quark_try_string("root");
181 if (client
== NULL
) return g_quark_try_string("none");
182 if (win
== client
->window
) return g_quark_try_string("client");
184 self
= (ObFrame
*) client
->frame
;
185 if (win
== self
->frame
.window
) return g_quark_try_string("frame");
186 if (win
== self
->frame
.plate
) return g_quark_try_string("client");
187 if (win
== self
->title
) return g_quark_try_string("titlebar");
188 if (win
== self
->label
) return g_quark_try_string("titlebar");
189 if (win
== self
->handle
) return g_quark_try_string("handle");
190 if (win
== self
->lgrip
) return g_quark_try_string("blcorner");
191 if (win
== self
->rgrip
) return g_quark_try_string("brcorner");
192 if (win
== self
->max
) return g_quark_try_string("maximize");
193 if (win
== self
->iconify
) return g_quark_try_string("iconify");
194 if (win
== self
->close
) return g_quark_try_string("close");
195 if (win
== self
->icon
) return g_quark_try_string("icon");
196 if (win
== self
->desk
) return g_quark_try_string("alldesktops");
198 return g_quark_try_string("none");