2008-03-15 13:59:04 +01:00
|
|
|
/*
|
|
|
|
* titlebar.h - titlebar management header
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AWESOME_TITLEBAR_H
|
|
|
|
#define AWESOME_TITLEBAR_H
|
|
|
|
|
|
|
|
#include "structs.h"
|
|
|
|
|
2008-06-04 17:54:52 +02:00
|
|
|
client_t * client_getbytitlebar(titlebar_t *);
|
2008-06-04 11:50:21 +02:00
|
|
|
client_t * client_getbytitlebarwin(xcb_window_t);
|
2008-06-18 11:22:54 +02:00
|
|
|
void titlebar_geometry_compute(client_t *, area_t, area_t *);
|
2008-06-04 11:50:21 +02:00
|
|
|
void titlebar_draw(client_t *);
|
|
|
|
void titlebar_init(client_t *);
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2008-06-04 13:36:13 +02:00
|
|
|
int luaA_titlebar_userdata_new(titlebar_t *);
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
/** Add the titlebar geometry to a geometry.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param t The titlebar
|
2008-06-18 17:05:10 +02:00
|
|
|
* \param border The client border size.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param geometry The geometry
|
|
|
|
* \return A new geometry bigger if the titlebar is visible.
|
2008-05-20 15:39:47 +02:00
|
|
|
*/
|
|
|
|
static inline area_t
|
2008-06-18 17:05:10 +02:00
|
|
|
titlebar_geometry_add(titlebar_t *t, int border, area_t geometry)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-03 18:41:54 +02:00
|
|
|
if(t && t->sw)
|
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.y -= t->sw->geometry.height + 2 * t->border.width - border;
|
|
|
|
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Bottom:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.height += t->sw->geometry.height + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Left:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.x -= t->sw->geometry.width + 2 * t->border.width - border;
|
|
|
|
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Right:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.width += t->sw->geometry.width + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove the titlebar geometry to a geometry.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param t The titlebar.
|
2008-06-18 17:05:10 +02:00
|
|
|
* \param border The client border size.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param geometry The geometry.
|
|
|
|
* \return A new geometry smaller if the titlebar is visible.
|
2008-05-20 15:39:47 +02:00
|
|
|
*/
|
|
|
|
static inline area_t
|
2008-06-18 17:05:10 +02:00
|
|
|
titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-03 18:41:54 +02:00
|
|
|
if(t && t->sw)
|
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.y += t->sw->geometry.height + 2 * t->border.width - border;
|
|
|
|
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Bottom:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.height -= t->sw->geometry.height + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Left:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.x += t->sw->geometry.width + 2 * t->border.width - border;
|
|
|
|
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Right:
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry.width -= t->sw->geometry.width + 2 * t->border.width - border;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return geometry;
|
|
|
|
}
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-06-18 11:22:54 +02:00
|
|
|
/** Update the titlebar geometry for a floating client.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param c The client.
|
2008-06-18 11:22:54 +02:00
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
titlebar_update_geometry_floating(client_t *c)
|
|
|
|
{
|
|
|
|
area_t geom;
|
|
|
|
|
|
|
|
if(!c->titlebar || !c->titlebar->sw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
titlebar_geometry_compute(c, c->geometry, &geom);
|
|
|
|
simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
|
|
|
|
titlebar_draw(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Update the titlebar geometry for a tiled client.
|
|
|
|
* \param c The client.
|
|
|
|
* \param geometry The geometry the client will receive.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
titlebar_update_geometry_tiled(client_t *c, area_t geometry)
|
|
|
|
{
|
|
|
|
area_t geom;
|
|
|
|
|
|
|
|
if(!c->titlebar || !c->titlebar->sw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
titlebar_geometry_compute(c, geometry, &geom);
|
|
|
|
simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
|
|
|
|
titlebar_draw(c);
|
|
|
|
}
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
#endif
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|