config check: be more precise about what we check
[awesome.git] / titlebar.h
blob8294e3f841f19905d9466c1378d9fe75245881f7
1 /*
2 * titlebar.h - titlebar management header
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.
22 #ifndef AWESOME_TITLEBAR_H
23 #define AWESOME_TITLEBAR_H
25 #include "wibox.h"
27 client_t * client_getbytitlebar(wibox_t *);
28 client_t * client_getbytitlebarwin(xcb_window_t);
29 void titlebar_geometry_compute(client_t *, area_t, area_t *);
30 void titlebar_init(client_t *);
31 void titlebar_client_detach(client_t *);
32 void titlebar_client_attach(client_t *, wibox_t *);
34 int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t);
36 /** Add the titlebar geometry and border to a geometry.
37 * \param t The titlebar
38 * \param border The client border size.
39 * \param geometry The geometry
40 * \return A new geometry bigger if the titlebar is visible.
42 static inline area_t
43 titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
45 if(t)
46 switch(t->position)
48 case Top:
49 geometry.y -= t->sw.geometry.height + 2 * t->sw.border.width - border;
50 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
51 geometry.width += 2 * border;
52 break;
53 case Bottom:
54 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
55 geometry.width += 2 * border;
56 break;
57 case Left:
58 geometry.x -= t->sw.geometry.width + 2 * t->sw.border.width - border;
59 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
60 geometry.height += 2 * border;
61 break;
62 case Right:
63 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
64 geometry.height += 2 * border;
65 break;
66 default:
67 break;
69 else
71 geometry.width += 2 * border;
72 geometry.height += 2 * border;
75 return geometry;
78 /** Remove the titlebar geometry and border width to a geometry.
79 * \param t The titlebar.
80 * \param border The client border size.
81 * \param geometry The geometry.
82 * \return A new geometry smaller if the titlebar is visible.
84 static inline area_t
85 titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
87 if(t)
88 switch(t->position)
90 case Top:
91 geometry.y += t->sw.geometry.height + 2 * t->sw.border.width - border;
92 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
93 geometry.width -= 2 * border;
94 break;
95 case Bottom:
96 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
97 geometry.width -= 2 * border;
98 break;
99 case Left:
100 geometry.x += t->sw.geometry.width + 2 * t->sw.border.width - border;
101 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
102 geometry.height -= 2 * border;
103 break;
104 case Right:
105 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
106 geometry.height -= 2 * border;
107 break;
108 default:
109 break;
111 else
113 geometry.width -= 2 * border;
114 geometry.height -= 2 * border;
117 return geometry;
120 /** Update the titlebar geometry for a tiled client.
121 * \param c The client.
122 * \param geometry The geometry the client will receive.
124 static inline void
125 titlebar_update_geometry_tiled(client_t *c, area_t geometry)
127 area_t geom;
129 if(!c->titlebar)
130 return;
132 titlebar_geometry_compute(c, geometry, &geom);
133 wibox_moveresize(c->titlebar, geom);
136 /** Update the titlebar geometry for a floating client.
137 * \param c The client.
139 static inline void
140 titlebar_update_geometry_floating(client_t *c)
142 return titlebar_update_geometry_tiled(c, c->geometry);
145 #endif
146 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80