2008-03-15 13:59:04 +01:00
|
|
|
/*
|
|
|
|
* titlebar.h - titlebar management header
|
|
|
|
*
|
2009-09-14 20:31:27 +02:00
|
|
|
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
2008-03-15 13:59:04 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2009-09-14 20:31:27 +02:00
|
|
|
#include "objects/wibox.h"
|
2009-09-14 20:22:12 +02:00
|
|
|
#include "objects/client.h"
|
2009-03-26 22:13:42 +01:00
|
|
|
#include "window.h"
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-09-21 10:13:21 +02:00
|
|
|
client_t * client_getbytitlebar(wibox_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_init(client_t *);
|
2008-09-21 20:39:23 +02:00
|
|
|
void titlebar_client_detach(client_t *);
|
2009-04-11 00:27:06 +02:00
|
|
|
void titlebar_client_attach(client_t *);
|
2009-02-05 17:55:59 +01:00
|
|
|
void titlebar_set_visible(wibox_t *, bool);
|
|
|
|
void titlebar_ban(wibox_t *);
|
2009-03-26 22:13:42 +01:00
|
|
|
void titlebar_unban(wibox_t *);
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
int luaA_titlebar_set_position(lua_State *, int);
|
2008-06-04 13:36:13 +02:00
|
|
|
|
2009-03-26 22:13:42 +01:00
|
|
|
static inline bool
|
2009-04-17 16:14:09 +02:00
|
|
|
titlebar_isvisible(client_t *c, screen_t *screen)
|
2009-03-26 22:13:42 +01:00
|
|
|
{
|
|
|
|
if(client_isvisible(c, screen))
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->fullscreen)
|
2009-03-26 22:13:42 +01:00
|
|
|
return false;
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!c->titlebar || !c->titlebar->visible)
|
2009-03-26 22:13:42 +01:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-26 16:02:43 +02:00
|
|
|
/** Add the titlebar geometry and border 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-09-21 10:13:21 +02:00
|
|
|
titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-12-10 21:40:56 +01:00
|
|
|
/* We need to add titlebar border to the total width and height.
|
2009-08-30 07:26:19 +02:00
|
|
|
* This can then be subtracted/added to the width/height/x/y.
|
2008-12-10 21:40:56 +01:00
|
|
|
* In this case the border is included, because it belongs to a different window.
|
|
|
|
*/
|
2009-08-17 16:56:03 +02:00
|
|
|
if(t && t->visible)
|
2008-06-03 18:41:54 +02:00
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.y -= t->geometry.height;
|
|
|
|
geometry.height += t->geometry.height;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Bottom:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.height += t->geometry.height;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Left:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.x -= t->geometry.width;
|
|
|
|
geometry.width += t->geometry.width;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Right:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.width += t->geometry.width;
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-10 21:40:56 +01:00
|
|
|
|
|
|
|
/* Adding a border to a client only changes width and height, x and y are including border. */
|
|
|
|
geometry.width += 2 * border;
|
|
|
|
geometry.height += 2 * border;
|
2008-05-20 15:39:47 +02:00
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2008-08-26 16:02:43 +02:00
|
|
|
/** Remove the titlebar geometry and border width 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-09-21 10:13:21 +02:00
|
|
|
titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-12-10 21:40:56 +01:00
|
|
|
/* We need to add titlebar border to the total width and height.
|
2009-08-30 07:26:19 +02:00
|
|
|
* This can then be subtracted/added to the width/height/x/y.
|
2008-12-10 21:40:56 +01:00
|
|
|
* In this case the border is included, because it belongs to a different window.
|
|
|
|
*/
|
2009-08-17 16:56:03 +02:00
|
|
|
if(t && t->visible)
|
2008-06-03 18:41:54 +02:00
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.y += t->geometry.height;
|
|
|
|
unsigned_subtract(geometry.height, t->geometry.height);
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Bottom:
|
2009-07-28 16:04:58 +02:00
|
|
|
unsigned_subtract(geometry.height, t->geometry.height);
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Left:
|
2009-07-28 16:04:58 +02:00
|
|
|
geometry.x += t->geometry.width;
|
|
|
|
unsigned_subtract(geometry.width, t->geometry.width);
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
case Right:
|
2009-07-28 16:04:58 +02:00
|
|
|
unsigned_subtract(geometry.width, t->geometry.width);
|
2008-06-03 18:41:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-10 21:40:56 +01:00
|
|
|
|
|
|
|
/* Adding a border to a client only changes width and height, x and y are including border. */
|
2008-12-12 00:01:43 +01:00
|
|
|
unsigned_subtract(geometry.width, 2*border);
|
|
|
|
unsigned_subtract(geometry.height, 2*border);
|
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-11-25 17:01:06 +01:00
|
|
|
/** Update the titlebar geometry for a client.
|
2008-06-18 14:04:24 +02:00
|
|
|
* \param c The client.
|
2008-06-18 11:22:54 +02:00
|
|
|
*/
|
|
|
|
static inline void
|
2008-11-25 17:01:06 +01:00
|
|
|
titlebar_update_geometry(client_t *c)
|
2008-06-18 11:22:54 +02:00
|
|
|
{
|
|
|
|
area_t geom;
|
|
|
|
|
2008-09-20 21:24:16 +02:00
|
|
|
if(!c->titlebar)
|
2008-06-18 11:22:54 +02:00
|
|
|
return;
|
|
|
|
|
2009-02-02 20:16:57 +01:00
|
|
|
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
|
|
|
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &geom);
|
2009-08-24 11:44:15 +02:00
|
|
|
luaA_object_push(globalconf.L, c->titlebar);
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_moveresize(globalconf.L, -1, geom);
|
2009-08-28 11:21:31 +02:00
|
|
|
lua_pop(globalconf.L, 1);
|
2008-06-18 11:22:54 +02:00
|
|
|
}
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
#endif
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|