mouse: fix coords() set
[awesome.git] / titlebar.h
blob28ac222c7e3d2eb0cdb7311d57cc0852a492cad0
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(titlebar_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);
34 int luaA_titlebar_userdata_new(lua_State *, titlebar_t *);
36 /** Add the titlebar geometry 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(titlebar_t *t, int border, area_t geometry)
45 if(t && t->sw)
46 switch(t->position)
48 case Top:
49 geometry.y -= t->sw->geometry.height + 2 * t->border.width - border;
50 geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
51 break;
52 case Bottom:
53 geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
54 break;
55 case Left:
56 geometry.x -= t->sw->geometry.width + 2 * t->border.width - border;
57 geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
58 break;
59 case Right:
60 geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
61 break;
62 default:
63 break;
66 return geometry;
69 /** Remove the titlebar geometry to a geometry.
70 * \param t The titlebar.
71 * \param border The client border size.
72 * \param geometry The geometry.
73 * \return A new geometry smaller if the titlebar is visible.
75 static inline area_t
76 titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry)
78 if(t && t->sw)
79 switch(t->position)
81 case Top:
82 geometry.y += t->sw->geometry.height + 2 * t->border.width - border;
83 geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
84 break;
85 case Bottom:
86 geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
87 break;
88 case Left:
89 geometry.x += t->sw->geometry.width + 2 * t->border.width - border;
90 geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
91 break;
92 case Right:
93 geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
94 break;
95 default:
96 break;
99 return geometry;
102 /** Update the titlebar geometry for a floating client.
103 * \param c The client.
105 static inline void
106 titlebar_update_geometry_floating(client_t *c)
108 area_t geom;
110 if(!c->titlebar || !c->titlebar->sw)
111 return;
113 titlebar_geometry_compute(c, c->geometry, &geom);
114 simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
115 c->titlebar->need_update = true;
118 /** Update the titlebar geometry for a tiled client.
119 * \param c The client.
120 * \param geometry The geometry the client will receive.
122 static inline void
123 titlebar_update_geometry_tiled(client_t *c, area_t geometry)
125 area_t geom;
127 if(!c->titlebar || !c->titlebar->sw)
128 return;
130 titlebar_geometry_compute(c, geometry, &geom);
131 simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
132 c->titlebar->need_update = true;
135 #endif
136 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80