1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 framerender.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
23 #include "framerender.h"
24 #include "render/theme.h"
26 static void framerender_label(ObFrame
*self
, RrAppearance
*a
);
27 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
);
28 static void framerender_max(ObFrame
*self
, RrAppearance
*a
);
29 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
);
30 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
);
31 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
);
32 static void framerender_close(ObFrame
*self
, RrAppearance
*a
);
34 void framerender_frame(ObFrame
*self
)
40 RrColorPixel(ob_rr_theme
->cb_focused_color
) :
41 RrColorPixel(ob_rr_theme
->cb_unfocused_color
));
42 XSetWindowBackground(ob_display
, self
->plate
, px
);
43 XClearWindow(ob_display
, self
->plate
);
46 if (self
->decorations
& OB_FRAME_DECOR_TITLEBAR
) {
47 RrAppearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
50 self
->a_focused_title
: self
->a_unfocused_title
);
52 self
->a_focused_label
: self
->a_unfocused_label
);
53 m
= (!(self
->decorations
& OB_FRAME_DECOR_MAXIMIZE
) ?
55 ob_rr_theme
->a_disabled_focused_max
:
56 ob_rr_theme
->a_disabled_unfocused_max
) :
58 (self
->client
->max_vert
|| self
->client
->max_horz
?
59 ob_rr_theme
->a_toggled_focused_max
:
61 ob_rr_theme
->a_focused_pressed_max
:
63 ob_rr_theme
->a_hover_focused_max
:
64 ob_rr_theme
->a_focused_unpressed_max
))) :
65 (self
->client
->max_vert
|| self
->client
->max_horz
?
66 ob_rr_theme
->a_toggled_unfocused_max
:
68 ob_rr_theme
->a_unfocused_pressed_max
:
70 ob_rr_theme
->a_hover_unfocused_max
:
71 ob_rr_theme
->a_unfocused_unpressed_max
)))));
73 i
= (!(self
->decorations
& OB_FRAME_DECOR_ICONIFY
) ?
75 ob_rr_theme
->a_disabled_focused_iconify
:
76 ob_rr_theme
->a_disabled_unfocused_iconify
) :
78 (self
->iconify_press
?
79 ob_rr_theme
->a_focused_pressed_iconify
:
80 (self
->iconify_hover
?
81 ob_rr_theme
->a_hover_focused_iconify
:
82 ob_rr_theme
->a_focused_unpressed_iconify
)) :
83 (self
->iconify_press
?
84 ob_rr_theme
->a_unfocused_pressed_iconify
:
85 (self
->iconify_hover
?
86 ob_rr_theme
->a_hover_unfocused_iconify
:
87 ob_rr_theme
->a_unfocused_unpressed_iconify
))));
88 d
= (!(self
->decorations
& OB_FRAME_DECOR_ALLDESKTOPS
) ?
90 ob_rr_theme
->a_disabled_focused_desk
:
91 ob_rr_theme
->a_disabled_unfocused_desk
) :
93 (self
->client
->desktop
== DESKTOP_ALL
?
94 ob_rr_theme
->a_toggled_focused_desk
:
96 ob_rr_theme
->a_focused_pressed_desk
:
98 ob_rr_theme
->a_hover_focused_desk
:
99 ob_rr_theme
->a_focused_unpressed_desk
))) :
100 (self
->client
->desktop
== DESKTOP_ALL
?
101 ob_rr_theme
->a_toggled_unfocused_desk
:
103 ob_rr_theme
->a_unfocused_pressed_desk
:
105 ob_rr_theme
->a_hover_unfocused_desk
:
106 ob_rr_theme
->a_unfocused_unpressed_desk
)))));
107 s
= (!(self
->decorations
& OB_FRAME_DECOR_SHADE
) ?
109 ob_rr_theme
->a_disabled_focused_shade
:
110 ob_rr_theme
->a_disabled_unfocused_shade
) :
112 (self
->client
->shaded
?
113 ob_rr_theme
->a_toggled_focused_shade
:
115 ob_rr_theme
->a_focused_pressed_shade
:
117 ob_rr_theme
->a_hover_focused_shade
:
118 ob_rr_theme
->a_focused_unpressed_shade
))) :
119 (self
->client
->shaded
?
120 ob_rr_theme
->a_toggled_unfocused_shade
:
122 ob_rr_theme
->a_unfocused_pressed_shade
:
124 ob_rr_theme
->a_hover_unfocused_shade
:
125 ob_rr_theme
->a_unfocused_unpressed_shade
)))));
126 c
= (!(self
->decorations
& OB_FRAME_DECOR_CLOSE
) ?
128 ob_rr_theme
->a_disabled_focused_close
:
129 ob_rr_theme
->a_disabled_unfocused_close
) :
132 ob_rr_theme
->a_focused_pressed_close
:
134 ob_rr_theme
->a_hover_focused_close
:
135 ob_rr_theme
->a_focused_unpressed_close
)) :
137 ob_rr_theme
->a_unfocused_pressed_close
:
139 ob_rr_theme
->a_hover_unfocused_close
:
140 ob_rr_theme
->a_unfocused_unpressed_close
))));
142 RrPaint(t
, self
->title
, self
->width
, ob_rr_theme
->title_height
);
144 ob_rr_theme
->a_clear
->surface
.parent
= t
;
145 ob_rr_theme
->a_clear
->surface
.parentx
= 0;
146 ob_rr_theme
->a_clear
->surface
.parenty
= 0;
148 RrPaint(ob_rr_theme
->a_clear
, self
->tlresize
,
149 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
151 ob_rr_theme
->a_clear
->surface
.parentx
=
152 self
->width
- ob_rr_theme
->grip_width
;
154 RrPaint(ob_rr_theme
->a_clear
, self
->trresize
,
155 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
158 /* set parents for any parent relative guys */
159 l
->surface
.parent
= t
;
160 l
->surface
.parentx
= self
->label_x
;
161 l
->surface
.parenty
= ob_rr_theme
->padding
;
163 m
->surface
.parent
= t
;
164 m
->surface
.parentx
= self
->max_x
;
165 m
->surface
.parenty
= ob_rr_theme
->padding
+ 1;
167 n
->surface
.parent
= t
;
168 n
->surface
.parentx
= self
->icon_x
;
169 n
->surface
.parenty
= ob_rr_theme
->padding
;
171 i
->surface
.parent
= t
;
172 i
->surface
.parentx
= self
->iconify_x
;
173 i
->surface
.parenty
= ob_rr_theme
->padding
+ 1;
175 d
->surface
.parent
= t
;
176 d
->surface
.parentx
= self
->desk_x
;
177 d
->surface
.parenty
= ob_rr_theme
->padding
+ 1;
179 s
->surface
.parent
= t
;
180 s
->surface
.parentx
= self
->shade_x
;
181 s
->surface
.parenty
= ob_rr_theme
->padding
+ 1;
183 c
->surface
.parent
= t
;
184 c
->surface
.parentx
= self
->close_x
;
185 c
->surface
.parenty
= ob_rr_theme
->padding
+ 1;
187 framerender_label(self
, l
);
188 framerender_max(self
, m
);
189 framerender_icon(self
, n
);
190 framerender_iconify(self
, i
);
191 framerender_desk(self
, d
);
192 framerender_shade(self
, s
);
193 framerender_close(self
, c
);
196 if (self
->decorations
& OB_FRAME_DECOR_HANDLE
) {
200 self
->a_focused_handle
: self
->a_unfocused_handle
);
202 RrPaint(h
, self
->handle
, self
->width
, ob_rr_theme
->handle_height
);
204 if (self
->decorations
& OB_FRAME_DECOR_GRIPS
) {
206 ob_rr_theme
->a_focused_grip
: ob_rr_theme
->a_unfocused_grip
);
208 if (g
->surface
.grad
== RR_SURFACE_PARENTREL
)
209 g
->surface
.parent
= h
;
211 g
->surface
.parentx
= 0;
212 g
->surface
.parenty
= 0;
214 RrPaint(g
, self
->lgrip
,
215 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
217 g
->surface
.parentx
= self
->width
- ob_rr_theme
->grip_width
;
218 g
->surface
.parenty
= 0;
220 RrPaint(g
, self
->rgrip
,
221 ob_rr_theme
->grip_width
, ob_rr_theme
->handle_height
);
228 static void framerender_label(ObFrame
*self
, RrAppearance
*a
)
230 if (self
->label_x
< 0) return;
231 /* set the texture's text! */
232 a
->texture
[0].data
.text
.string
= self
->client
->title
;
233 RrPaint(a
, self
->label
, self
->label_width
, ob_rr_theme
->label_height
);
236 static void framerender_icon(ObFrame
*self
, RrAppearance
*a
)
238 if (self
->icon_x
< 0) return;
240 if (self
->client
->nicons
) {
241 ObClientIcon
*icon
= client_icon(self
->client
,
242 ob_rr_theme
->button_size
+ 2,
243 ob_rr_theme
->button_size
+ 2);
244 a
->texture
[0].type
= RR_TEXTURE_RGBA
;
245 a
->texture
[0].data
.rgba
.width
= icon
->width
;
246 a
->texture
[0].data
.rgba
.height
= icon
->height
;
247 a
->texture
[0].data
.rgba
.data
= icon
->data
;
249 a
->texture
[0].type
= RR_TEXTURE_NONE
;
251 RrPaint(a
, self
->icon
,
252 ob_rr_theme
->button_size
+ 2, ob_rr_theme
->button_size
+ 2);
255 static void framerender_max(ObFrame
*self
, RrAppearance
*a
)
257 if (self
->max_x
< 0) return;
258 RrPaint(a
, self
->max
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
261 static void framerender_iconify(ObFrame
*self
, RrAppearance
*a
)
263 if (self
->iconify_x
< 0) return;
264 RrPaint(a
, self
->iconify
,
265 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
268 static void framerender_desk(ObFrame
*self
, RrAppearance
*a
)
270 if (self
->desk_x
< 0) return;
271 RrPaint(a
, self
->desk
, ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
274 static void framerender_shade(ObFrame
*self
, RrAppearance
*a
)
276 if (self
->shade_x
< 0) return;
277 RrPaint(a
, self
->shade
,
278 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);
281 static void framerender_close(ObFrame
*self
, RrAppearance
*a
)
283 if (self
->close_x
< 0) return;
284 RrPaint(a
, self
->close
,
285 ob_rr_theme
->button_size
, ob_rr_theme
->button_size
);