graph, progressbar: fix bar/plot additions
[awesome.git] / titlebar.h
blobec23ddaaec7cd19683a6ec28d83e3e709a8fed0d
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 "structs.h"
26 #include "wibox.h"
28 client_t * client_getbytitlebar(wibox_t *);
29 client_t * client_getbytitlebarwin(xcb_window_t);
30 void titlebar_geometry_compute(client_t *, area_t, area_t *);
31 void titlebar_init(client_t *);
32 void titlebar_client_detach(client_t *);
33 void titlebar_client_attach(client_t *, wibox_t *);
35 int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t);
37 /** Add the titlebar geometry and border to a geometry.
38 * \param t The titlebar
39 * \param border The client border size.
40 * \param geometry The geometry
41 * \return A new geometry bigger if the titlebar is visible.
43 static inline area_t
44 titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
46 if(t)
47 switch(t->position)
49 case Top:
50 geometry.y -= t->sw.geometry.height + 2 * t->sw.border.width - border;
51 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
52 geometry.width += 2 * border;
53 break;
54 case Bottom:
55 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
56 geometry.width += 2 * border;
57 break;
58 case Left:
59 geometry.x -= t->sw.geometry.width + 2 * t->sw.border.width - border;
60 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
61 geometry.height += 2 * border;
62 break;
63 case Right:
64 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
65 geometry.height += 2 * border;
66 break;
67 default:
68 break;
70 else
72 geometry.width += 2 * border;
73 geometry.height += 2 * border;
76 return geometry;
79 /** Remove the titlebar geometry and border width to a geometry.
80 * \param t The titlebar.
81 * \param border The client border size.
82 * \param geometry The geometry.
83 * \return A new geometry smaller if the titlebar is visible.
85 static inline area_t
86 titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
88 if(t)
89 switch(t->position)
91 case Top:
92 geometry.y += t->sw.geometry.height + 2 * t->sw.border.width - border;
93 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
94 geometry.width -= 2 * border;
95 break;
96 case Bottom:
97 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
98 geometry.width -= 2 * border;
99 break;
100 case Left:
101 geometry.x += t->sw.geometry.width + 2 * t->sw.border.width - border;
102 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
103 geometry.height -= 2 * border;
104 break;
105 case Right:
106 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
107 geometry.height -= 2 * border;
108 break;
109 default:
110 break;
112 else
114 geometry.width -= 2 * border;
115 geometry.height -= 2 * border;
118 return geometry;
121 /** Update the titlebar geometry for a tiled client.
122 * \param c The client.
123 * \param geometry The geometry the client will receive.
125 static inline void
126 titlebar_update_geometry_tiled(client_t *c, area_t geometry)
128 area_t geom;
130 if(!c->titlebar)
131 return;
133 titlebar_geometry_compute(c, geometry, &geom);
134 wibox_moveresize(c->titlebar, geom);
137 /** Update the titlebar geometry for a floating client.
138 * \param c The client.
140 static inline void
141 titlebar_update_geometry_floating(client_t *c)
143 return titlebar_update_geometry_tiled(c, c->geometry);
146 #endif
147 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80