client: add property hook
[awesome.git] / titlebar.h
blob55288a9c55bdd7bfd424317f38d0cb9d23fb9f3f
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"
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_draw(client_t *);
31 void titlebar_init(client_t *);
32 void titlebar_refresh(void);
33 void titlebar_client_detach(client_t *);
34 void titlebar_client_attach(client_t *, wibox_t *);
36 int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t);
38 /** Add the titlebar geometry and border to a geometry.
39 * \param t The titlebar
40 * \param border The client border size.
41 * \param geometry The geometry
42 * \return A new geometry bigger if the titlebar is visible.
44 static inline area_t
45 titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
47 if(t)
48 switch(t->position)
50 case Top:
51 geometry.y -= t->sw.geometry.height + 2 * t->sw.border.width - border;
52 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
53 geometry.width += 2 * border;
54 break;
55 case Bottom:
56 geometry.height += t->sw.geometry.height + 2 * t->sw.border.width - border;
57 geometry.width += 2 * border;
58 break;
59 case Left:
60 geometry.x -= t->sw.geometry.width + 2 * t->sw.border.width - border;
61 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
62 geometry.height += 2 * border;
63 break;
64 case Right:
65 geometry.width += t->sw.geometry.width + 2 * t->sw.border.width - border;
66 geometry.height += 2 * border;
67 break;
68 default:
69 break;
71 else
73 geometry.width += 2 * border;
74 geometry.height += 2 * border;
77 return geometry;
80 /** Remove the titlebar geometry and border width to a geometry.
81 * \param t The titlebar.
82 * \param border The client border size.
83 * \param geometry The geometry.
84 * \return A new geometry smaller if the titlebar is visible.
86 static inline area_t
87 titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
89 if(t)
90 switch(t->position)
92 case Top:
93 geometry.y += t->sw.geometry.height + 2 * t->sw.border.width - border;
94 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
95 geometry.width -= 2 * border;
96 break;
97 case Bottom:
98 geometry.height -= t->sw.geometry.height + 2 * t->sw.border.width - border;
99 geometry.width -= 2 * border;
100 break;
101 case Left:
102 geometry.x += t->sw.geometry.width + 2 * t->sw.border.width - border;
103 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
104 geometry.height -= 2 * border;
105 break;
106 case Right:
107 geometry.width -= t->sw.geometry.width + 2 * t->sw.border.width - border;
108 geometry.height -= 2 * border;
109 break;
110 default:
111 break;
113 else
115 geometry.width -= 2 * border;
116 geometry.height -= 2 * border;
119 return geometry;
122 /** Update the titlebar geometry for a floating client.
123 * \param c The client.
125 static inline void
126 titlebar_update_geometry_floating(client_t *c)
128 area_t geom;
130 if(!c->titlebar)
131 return;
133 titlebar_geometry_compute(c, c->geometry, &geom);
134 simplewindow_moveresize(&c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
135 c->titlebar->need_update = true;
138 /** Update the titlebar geometry for a tiled client.
139 * \param c The client.
140 * \param geometry The geometry the client will receive.
142 static inline void
143 titlebar_update_geometry_tiled(client_t *c, area_t geometry)
145 area_t geom;
147 if(!c->titlebar)
148 return;
150 titlebar_geometry_compute(c, geometry, &geom);
151 simplewindow_moveresize(&c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
152 c->titlebar->need_update = true;
155 #endif
156 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80