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
)
32 int titlebar_height
= 1.5 * MAX(globalconf
.screens
[c
->screen
].styles
.normal
.font
->height
,
33 MAX(globalconf
.screens
[c
->screen
].styles
.focus
.font
->height
,
34 globalconf
.screens
[c
->screen
].styles
.urgent
.font
->height
));
35 int phys_screen
= get_phys_screen(c
->screen
);
37 switch(c
->titlebar
.position
)
40 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
43 c
->geometry
.y
- titlebar_height
,
44 c
->geometry
.width
+ 2 * c
->border
,
49 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
52 c
->geometry
.y
+ c
->geometry
.height
+ 2 * c
->border
,
53 c
->geometry
.width
+ 2 * c
->border
,
58 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
60 c
->geometry
.x
- titlebar_height
,
63 c
->geometry
.width
+ 2 * c
->border
,
67 c
->titlebar
.sw
= simplewindow_new(globalconf
.display
,
69 c
->geometry
.x
+ c
->geometry
.width
+ 2 * c
->border
,
72 c
->geometry
.width
+ 2 * c
->border
,
78 c
->titlebar
.position
= Off
;
84 titlebar_update(Client
*c
)
94 switch(c
->titlebar
.position
)
100 XFreePixmap(globalconf
.display
, c
->titlebar
.sw
->drawable
);
101 c
->titlebar
.sw
->drawable
=
102 XCreatePixmap(globalconf
.display
,
103 RootWindow(globalconf
.display
, c
->titlebar
.sw
->phys_screen
),
104 c
->titlebar
.sw
->geometry
.height
,
105 c
->titlebar
.sw
->geometry
.width
,
106 DefaultDepth(globalconf
.display
, c
->titlebar
.sw
->phys_screen
));
107 ctx
= draw_context_new(globalconf
.display
, c
->titlebar
.sw
->phys_screen
,
108 c
->titlebar
.sw
->geometry
.height
,
109 c
->titlebar
.sw
->geometry
.width
,
110 c
->titlebar
.sw
->drawable
);
111 geometry
.width
= c
->titlebar
.sw
->geometry
.height
;
112 geometry
.height
= c
->titlebar
.sw
->geometry
.width
;
115 ctx
= draw_context_new(globalconf
.display
, c
->titlebar
.sw
->phys_screen
,
116 c
->titlebar
.sw
->geometry
.width
,
117 c
->titlebar
.sw
->geometry
.height
,
118 c
->titlebar
.sw
->drawable
);
119 geometry
= c
->titlebar
.sw
->geometry
;
125 style
= globalconf
.screens
[c
->screen
].styles
.urgent
;
126 else if(globalconf
.focus
->client
== c
)
127 style
= globalconf
.screens
[c
->screen
].styles
.focus
;
129 style
= globalconf
.screens
[c
->screen
].styles
.normal
;
131 geometry
.x
= geometry
.y
= 0;
133 draw_text(ctx
, geometry
, c
->titlebar
.text_align
, style
.font
->height
/ 2,
136 switch(c
->titlebar
.position
)
139 d
= draw_rotate(ctx
, c
->titlebar
.sw
->phys_screen
, - M_PI_2
,
140 0, c
->titlebar
.sw
->geometry
.height
);
141 XFreePixmap(globalconf
.display
, c
->titlebar
.sw
->drawable
);
142 c
->titlebar
.sw
->drawable
= d
;
145 d
= draw_rotate(ctx
, c
->titlebar
.sw
->phys_screen
, M_PI_2
,
146 c
->titlebar
.sw
->geometry
.width
, 0);
147 XFreePixmap(globalconf
.display
, c
->titlebar
.sw
->drawable
);
148 c
->titlebar
.sw
->drawable
= d
;
153 simplewindow_refresh_drawable(c
->titlebar
.sw
, c
->titlebar
.sw
->phys_screen
);
155 draw_context_delete(ctx
);
159 titlebar_update_geometry_floating(Client
*c
)
164 switch(c
->titlebar
.position
)
169 simplewindow_move_resize(c
->titlebar
.sw
,
171 c
->geometry
.y
- c
->titlebar
.sw
->geometry
.height
,
172 c
->geometry
.width
+ 2 * c
->border
,
173 c
->titlebar
.sw
->geometry
.height
);
176 simplewindow_move_resize(c
->titlebar
.sw
,
178 c
->geometry
.y
+ c
->geometry
.height
+ 2 * c
->border
,
179 c
->geometry
.width
+ 2 * c
->border
,
180 c
->titlebar
.sw
->geometry
.height
);
183 simplewindow_move_resize(c
->titlebar
.sw
,
184 c
->geometry
.x
- c
->titlebar
.sw
->geometry
.width
,
186 c
->titlebar
.sw
->geometry
.width
,
187 c
->geometry
.height
+ 2 * c
->border
);
190 simplewindow_move_resize(c
->titlebar
.sw
,
191 c
->geometry
.x
+ c
->geometry
.width
+ 2 * c
->border
,
193 c
->titlebar
.sw
->geometry
.width
,
194 c
->geometry
.height
+ 2 * c
->border
);
202 titlebar_update_geometry(Client
*c
, area_t geometry
)
207 switch(c
->titlebar
.position
)
212 simplewindow_move_resize(c
->titlebar
.sw
,
215 geometry
.width
+ 2 * c
->border
,
216 c
->titlebar
.sw
->geometry
.height
);
217 geometry
.y
+= c
->titlebar
.sw
->geometry
.height
;
218 geometry
.height
-= c
->titlebar
.sw
->geometry
.height
;
221 geometry
.height
-= c
->titlebar
.sw
->geometry
.height
;
222 simplewindow_move_resize(c
->titlebar
.sw
,
224 geometry
.y
+ geometry
.height
+ 2 * c
->border
,
225 geometry
.width
+ 2 * c
->border
,
226 c
->titlebar
.sw
->geometry
.height
);
229 simplewindow_move_resize(c
->titlebar
.sw
,
232 c
->titlebar
.sw
->geometry
.width
,
233 geometry
.height
+ 2 * c
->border
);
234 geometry
.width
-= c
->titlebar
.sw
->geometry
.width
;
235 geometry
.x
+= c
->titlebar
.sw
->geometry
.width
;
238 geometry
.width
-= c
->titlebar
.sw
->geometry
.width
;
239 simplewindow_move_resize(c
->titlebar
.sw
,
240 geometry
.x
+ geometry
.width
+ 2 * c
->border
,
242 c
->titlebar
.sw
->geometry
.width
,
243 geometry
.height
+ 2 * c
->border
);
252 /** Toggle window titlebar visibility
253 * \param screen screen number (unused)
254 * \param arg unused argument
255 * \ingroup ui_callback
258 uicb_client_toggletitlebar(int screen
__attribute__ ((unused
)),
259 char *arg
__attribute__ ((unused
)))
261 Client
*c
= globalconf
.focus
->client
;
263 if(!c
|| !c
->titlebar
.sw
)
266 if(!c
->titlebar
.position
)
267 c
->titlebar
.position
= c
->titlebar
.dposition
;
270 c
->titlebar
.position
= Off
;
271 XUnmapWindow(globalconf
.display
, c
->titlebar
.sw
->window
);
274 globalconf
.screens
[c
->screen
].need_arrange
= True
;
277 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80