2 * titlebar.c - titlebar management
4 * Copyright © 2008 Julien Danjou <julien@danjou.info>
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 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 extern AwesomeConf globalconf
;
30 titlebar_init(Client
*c
)
34 if(c
->titlebar
.position
== Off
35 || c
->titlebar
.position
== Auto
)
37 c
->titlebar
.position
= Off
;
41 titlebar_height
= 1.5 * MAX(c
->titlebar
.styles
.normal
.font
->height
,
42 MAX(c
->titlebar
.styles
.focus
.font
->height
,
43 c
->titlebar
.styles
.urgent
.font
->height
));
45 switch(c
->titlebar
.position
)
48 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
51 c
->geometry
.y
- titlebar_height
,
52 c
->geometry
.width
+ 2 * c
->border
,
57 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
60 c
->geometry
.y
+ c
->geometry
.height
+ 2 * c
->border
,
61 c
->geometry
.width
+ 2 * c
->border
,
66 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
68 c
->geometry
.x
- titlebar_height
,
71 c
->geometry
.width
+ 2 * c
->border
,
75 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
77 c
->geometry
.x
+ c
->geometry
.width
+ 2 * c
->border
,
80 c
->geometry
.width
+ 2 * c
->border
,
89 titlebar_update(Client
*c
)
99 switch(c
->titlebar
.position
)
105 dw
= XCreatePixmap(globalconf
.display
,
106 RootWindow(globalconf
.display
, c
->titlebar
.sw
->phys_screen
),
107 c
->titlebar
.sw
->geometry
.height
,
108 c
->titlebar
.sw
->geometry
.width
,
109 DefaultDepth(globalconf
.display
, c
->titlebar
.sw
->phys_screen
));
110 ctx
= draw_context_new(globalconf
.display
, c
->titlebar
.sw
->phys_screen
,
111 c
->titlebar
.sw
->geometry
.height
,
112 c
->titlebar
.sw
->geometry
.width
,
114 geometry
.width
= c
->titlebar
.sw
->geometry
.height
;
115 geometry
.height
= c
->titlebar
.sw
->geometry
.width
;
118 ctx
= draw_context_new(globalconf
.display
, c
->titlebar
.sw
->phys_screen
,
119 c
->titlebar
.sw
->geometry
.width
,
120 c
->titlebar
.sw
->geometry
.height
,
121 c
->titlebar
.sw
->drawable
);
122 geometry
= c
->titlebar
.sw
->geometry
;
128 style
= c
->titlebar
.styles
.urgent
;
129 else if(globalconf
.focus
->client
== c
)
130 style
= c
->titlebar
.styles
.focus
;
132 style
= c
->titlebar
.styles
.normal
;
134 geometry
.x
= geometry
.y
= 0;
136 draw_text(ctx
, geometry
, c
->titlebar
.text_align
, style
.font
->height
/ 2,
139 switch(c
->titlebar
.position
)
142 draw_rotate(ctx
, c
->titlebar
.sw
->drawable
, ctx
->height
, ctx
->width
,
143 - M_PI_2
, 0, c
->titlebar
.sw
->geometry
.height
);
144 XFreePixmap(globalconf
.display
, dw
);
147 draw_rotate(ctx
, c
->titlebar
.sw
->drawable
, ctx
->height
, ctx
->width
,
148 M_PI_2
, c
->titlebar
.sw
->geometry
.width
, 0);
149 XFreePixmap(globalconf
.display
, dw
);
154 simplewindow_refresh_drawable(c
->titlebar
.sw
, c
->titlebar
.sw
->phys_screen
);
156 draw_context_delete(&ctx
);
160 titlebar_update_geometry_floating(Client
*c
)
165 switch(c
->titlebar
.position
)
170 simplewindow_move_resize(c
->titlebar
.sw
,
172 c
->geometry
.y
- c
->titlebar
.sw
->geometry
.height
,
173 c
->geometry
.width
+ 2 * c
->border
,
174 c
->titlebar
.sw
->geometry
.height
);
177 simplewindow_move_resize(c
->titlebar
.sw
,
179 c
->geometry
.y
+ c
->geometry
.height
+ 2 * c
->border
,
180 c
->geometry
.width
+ 2 * c
->border
,
181 c
->titlebar
.sw
->geometry
.height
);
184 simplewindow_move_resize(c
->titlebar
.sw
,
185 c
->geometry
.x
- c
->titlebar
.sw
->geometry
.width
,
187 c
->titlebar
.sw
->geometry
.width
,
188 c
->geometry
.height
+ 2 * c
->border
);
191 simplewindow_move_resize(c
->titlebar
.sw
,
192 c
->geometry
.x
+ c
->geometry
.width
+ 2 * c
->border
,
194 c
->titlebar
.sw
->geometry
.width
,
195 c
->geometry
.height
+ 2 * c
->border
);
203 titlebar_update_geometry(Client
*c
, area_t geometry
)
208 switch(c
->titlebar
.position
)
213 simplewindow_move_resize(c
->titlebar
.sw
,
216 geometry
.width
+ 2 * c
->border
,
217 c
->titlebar
.sw
->geometry
.height
);
218 geometry
.y
+= c
->titlebar
.sw
->geometry
.height
;
219 geometry
.height
-= c
->titlebar
.sw
->geometry
.height
;
222 geometry
.height
-= c
->titlebar
.sw
->geometry
.height
;
223 simplewindow_move_resize(c
->titlebar
.sw
,
225 geometry
.y
+ geometry
.height
+ 2 * c
->border
,
226 geometry
.width
+ 2 * c
->border
,
227 c
->titlebar
.sw
->geometry
.height
);
230 simplewindow_move_resize(c
->titlebar
.sw
,
233 c
->titlebar
.sw
->geometry
.width
,
234 geometry
.height
+ 2 * c
->border
);
235 geometry
.width
-= c
->titlebar
.sw
->geometry
.width
;
236 geometry
.x
+= c
->titlebar
.sw
->geometry
.width
;
239 geometry
.width
-= c
->titlebar
.sw
->geometry
.width
;
240 simplewindow_move_resize(c
->titlebar
.sw
,
241 geometry
.x
+ geometry
.width
+ 2 * c
->border
,
243 c
->titlebar
.sw
->geometry
.width
,
244 geometry
.height
+ 2 * c
->border
);
253 /** Toggle window titlebar visibility
254 * \param screen screen number (unused)
255 * \param arg unused argument
256 * \ingroup ui_callback
259 uicb_client_toggletitlebar(int screen
__attribute__ ((unused
)),
260 char *arg
__attribute__ ((unused
)))
262 Client
*c
= globalconf
.focus
->client
;
264 if(!c
|| !c
->titlebar
.sw
)
267 if(!c
->titlebar
.position
)
268 c
->titlebar
.position
= c
->titlebar
.dposition
;
271 c
->titlebar
.position
= Off
;
272 XUnmapWindow(globalconf
.display
, c
->titlebar
.sw
->window
);
275 globalconf
.screens
[c
->screen
].need_arrange
= True
;
278 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80