2008-03-15 13:59:04 +01:00
|
|
|
/*
|
|
|
|
* titlebar.c - titlebar management
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
#include "titlebar.h"
|
2008-03-17 08:56:17 +01:00
|
|
|
#include "screen.h"
|
2008-03-15 13:59:04 +01:00
|
|
|
|
|
|
|
extern AwesomeConf globalconf;
|
|
|
|
|
2008-03-17 08:56:17 +01:00
|
|
|
void
|
|
|
|
titlebar_init(Client *c)
|
|
|
|
{
|
2008-03-24 16:31:02 +01:00
|
|
|
int width;
|
2008-03-17 08:56:17 +01:00
|
|
|
|
2008-03-20 20:45:08 +01:00
|
|
|
if(c->titlebar.position == Off
|
|
|
|
|| c->titlebar.position == Auto)
|
|
|
|
{
|
|
|
|
c->titlebar.position = Off;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.height)
|
|
|
|
c->titlebar.height = 1.5 * MAX(c->titlebar.styles.normal.font->height,
|
|
|
|
MAX(c->titlebar.styles.focus.font->height,
|
|
|
|
c->titlebar.styles.urgent.font->height));
|
2008-03-20 20:45:08 +01:00
|
|
|
|
2008-03-17 08:56:17 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
case Top:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.width + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.width);
|
2008-03-17 08:56:17 +01:00
|
|
|
c->titlebar.sw = simplewindow_new(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
c->phys_screen,
|
2008-03-17 08:56:17 +01:00
|
|
|
c->geometry.x,
|
2008-03-24 16:31:02 +01:00
|
|
|
c->geometry.y - c->titlebar.height,
|
|
|
|
width,
|
|
|
|
c->titlebar.height,
|
2008-03-17 08:56:17 +01:00
|
|
|
0);
|
|
|
|
break;
|
|
|
|
case Bottom:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.width + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.width);
|
2008-03-17 08:56:17 +01:00
|
|
|
c->titlebar.sw = simplewindow_new(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
c->phys_screen,
|
2008-03-17 08:56:17 +01:00
|
|
|
c->geometry.x,
|
|
|
|
c->geometry.y + c->geometry.height + 2 * c->border,
|
2008-03-24 16:31:02 +01:00
|
|
|
width,
|
|
|
|
c->titlebar.height,
|
2008-03-17 08:56:17 +01:00
|
|
|
0);
|
|
|
|
break;
|
|
|
|
case Left:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.height + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.height);
|
2008-03-17 08:56:17 +01:00
|
|
|
c->titlebar.sw = simplewindow_new(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
c->phys_screen,
|
2008-03-24 16:31:02 +01:00
|
|
|
c->geometry.x - c->titlebar.height,
|
2008-03-17 08:56:17 +01:00
|
|
|
c->geometry.y,
|
2008-03-24 16:31:02 +01:00
|
|
|
c->titlebar.height,
|
|
|
|
width,
|
2008-03-17 08:56:17 +01:00
|
|
|
0);
|
|
|
|
break;
|
|
|
|
case Right:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.height + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.height);
|
2008-03-17 08:56:17 +01:00
|
|
|
c->titlebar.sw = simplewindow_new(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
c->phys_screen,
|
2008-03-17 08:56:17 +01:00
|
|
|
c->geometry.x + c->geometry.width + 2 * c->border,
|
|
|
|
c->geometry.y,
|
2008-03-24 16:31:02 +01:00
|
|
|
c->titlebar.height,
|
|
|
|
width,
|
2008-03-17 08:56:17 +01:00
|
|
|
0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-25 14:45:13 +01:00
|
|
|
area_t
|
|
|
|
titlebar_geometry_add(Titlebar *t, area_t geometry)
|
|
|
|
{
|
|
|
|
if(!t->sw)
|
|
|
|
return geometry;
|
|
|
|
|
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
|
|
|
geometry.y -= t->sw->geometry.height;
|
|
|
|
geometry.height += t->sw->geometry.height;
|
|
|
|
break;
|
|
|
|
case Bottom:
|
|
|
|
geometry.height += t->sw->geometry.height;
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
geometry.x -= t->sw->geometry.width;
|
|
|
|
geometry.width += t->sw->geometry.width;
|
|
|
|
break;
|
|
|
|
case Right:
|
|
|
|
geometry.width += t->sw->geometry.width;
|
2008-03-25 14:56:21 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
area_t
|
|
|
|
titlebar_geometry_remove(Titlebar *t, area_t geometry)
|
|
|
|
{
|
|
|
|
if(!t->sw)
|
|
|
|
return geometry;
|
|
|
|
|
|
|
|
switch(t->position)
|
|
|
|
{
|
|
|
|
case Top:
|
|
|
|
geometry.y += t->sw->geometry.height;
|
|
|
|
geometry.height -= t->sw->geometry.height;
|
|
|
|
break;
|
|
|
|
case Bottom:
|
|
|
|
geometry.height -= t->sw->geometry.height;
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
geometry.x += t->sw->geometry.width;
|
|
|
|
geometry.width -= t->sw->geometry.width;
|
|
|
|
break;
|
|
|
|
case Right:
|
|
|
|
geometry.width -= t->sw->geometry.width;
|
2008-03-25 14:45:13 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
void
|
|
|
|
titlebar_update(Client *c)
|
|
|
|
{
|
2008-03-20 09:51:01 +01:00
|
|
|
Drawable dw = 0;
|
2008-03-15 13:59:04 +01:00
|
|
|
DrawCtx *ctx;
|
|
|
|
style_t style;
|
|
|
|
area_t geometry;
|
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
if(!c->titlebar.sw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
case Off:
|
2008-03-15 13:59:04 +01:00
|
|
|
return;
|
2008-03-15 20:10:09 +01:00
|
|
|
case Right:
|
|
|
|
case Left:
|
2008-03-20 09:51:01 +01:00
|
|
|
dw = XCreatePixmap(globalconf.display,
|
|
|
|
RootWindow(globalconf.display, c->titlebar.sw->phys_screen),
|
|
|
|
c->titlebar.sw->geometry.height,
|
|
|
|
c->titlebar.sw->geometry.width,
|
|
|
|
DefaultDepth(globalconf.display, c->titlebar.sw->phys_screen));
|
2008-03-15 20:10:09 +01:00
|
|
|
ctx = draw_context_new(globalconf.display, c->titlebar.sw->phys_screen,
|
|
|
|
c->titlebar.sw->geometry.height,
|
|
|
|
c->titlebar.sw->geometry.width,
|
2008-03-20 09:51:01 +01:00
|
|
|
dw);
|
2008-03-15 20:10:09 +01:00
|
|
|
geometry.width = c->titlebar.sw->geometry.height;
|
|
|
|
geometry.height = c->titlebar.sw->geometry.width;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ctx = draw_context_new(globalconf.display, c->titlebar.sw->phys_screen,
|
|
|
|
c->titlebar.sw->geometry.width,
|
|
|
|
c->titlebar.sw->geometry.height,
|
|
|
|
c->titlebar.sw->drawable);
|
|
|
|
geometry = c->titlebar.sw->geometry;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 13:59:04 +01:00
|
|
|
|
|
|
|
|
2008-03-25 19:07:25 +01:00
|
|
|
if(globalconf.focus->client == c)
|
2008-03-20 20:45:08 +01:00
|
|
|
style = c->titlebar.styles.focus;
|
2008-03-25 19:07:25 +01:00
|
|
|
else if(c->isurgent)
|
|
|
|
style = c->titlebar.styles.urgent;
|
2008-03-15 13:59:04 +01:00
|
|
|
else
|
2008-03-20 20:45:08 +01:00
|
|
|
style = c->titlebar.styles.normal;
|
2008-03-15 13:59:04 +01:00
|
|
|
|
|
|
|
geometry.x = geometry.y = 0;
|
|
|
|
|
|
|
|
draw_text(ctx, geometry, c->titlebar.text_align, style.font->height / 2,
|
|
|
|
c->name, style);
|
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
case Left:
|
2008-03-20 09:17:34 +01:00
|
|
|
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
|
|
|
- M_PI_2, 0, c->titlebar.sw->geometry.height);
|
2008-03-20 09:51:01 +01:00
|
|
|
XFreePixmap(globalconf.display, dw);
|
2008-03-15 20:10:09 +01:00
|
|
|
break;
|
2008-03-16 18:00:49 +01:00
|
|
|
case Right:
|
2008-03-20 09:17:34 +01:00
|
|
|
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
|
|
|
M_PI_2, c->titlebar.sw->geometry.width, 0);
|
2008-03-20 09:51:01 +01:00
|
|
|
XFreePixmap(globalconf.display, dw);
|
2008-03-15 20:10:09 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
simplewindow_refresh_drawable(c->titlebar.sw, c->titlebar.sw->phys_screen);
|
|
|
|
|
2008-03-21 11:26:56 +01:00
|
|
|
draw_context_delete(&ctx);
|
2008-03-15 13:59:04 +01:00
|
|
|
}
|
|
|
|
|
2008-03-15 15:24:47 +01:00
|
|
|
void
|
|
|
|
titlebar_update_geometry_floating(Client *c)
|
|
|
|
{
|
2008-03-24 17:42:45 +01:00
|
|
|
int width, x_offset = 0, y_offset = 0;
|
2008-03-24 16:31:02 +01:00
|
|
|
|
2008-03-15 16:41:59 +01:00
|
|
|
if(!c->titlebar.sw)
|
|
|
|
return;
|
|
|
|
|
2008-03-15 15:24:47 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
case Top:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.width + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.width);
|
2008-03-24 17:42:45 +01:00
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
x_offset = 2 * c->border + c->geometry.width - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
x_offset = (c->geometry.width - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 15:24:47 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-24 17:42:45 +01:00
|
|
|
c->geometry.x + x_offset,
|
2008-03-15 15:24:47 +01:00
|
|
|
c->geometry.y - c->titlebar.sw->geometry.height,
|
2008-03-24 16:31:02 +01:00
|
|
|
width,
|
2008-03-15 15:24:47 +01:00
|
|
|
c->titlebar.sw->geometry.height);
|
|
|
|
break;
|
|
|
|
case Bottom:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.width + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.width);
|
2008-03-24 17:42:45 +01:00
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
x_offset = 2 * c->border + c->geometry.width - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
x_offset = (c->geometry.width - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 15:24:47 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-24 17:42:45 +01:00
|
|
|
c->geometry.x + x_offset,
|
2008-03-15 15:24:47 +01:00
|
|
|
c->geometry.y + c->geometry.height + 2 * c->border,
|
2008-03-24 16:31:02 +01:00
|
|
|
width,
|
2008-03-15 15:24:47 +01:00
|
|
|
c->titlebar.sw->geometry.height);
|
|
|
|
break;
|
2008-03-15 20:10:09 +01:00
|
|
|
case Left:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.height + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.height);
|
2008-03-24 17:42:45 +01:00
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
y_offset = 2 * c->border + c->geometry.height - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
y_offset = (c->geometry.height - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 20:10:09 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
|
|
|
c->geometry.x - c->titlebar.sw->geometry.width,
|
2008-03-24 17:42:45 +01:00
|
|
|
c->geometry.y + y_offset,
|
2008-03-15 20:10:09 +01:00
|
|
|
c->titlebar.sw->geometry.width,
|
2008-03-24 16:31:02 +01:00
|
|
|
width);
|
2008-03-15 20:10:09 +01:00
|
|
|
break;
|
2008-03-16 18:00:49 +01:00
|
|
|
case Right:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
|
|
|
width = c->geometry.height + 2 * c->border;
|
|
|
|
else
|
|
|
|
width = MIN(c->titlebar.width, c->geometry.height);
|
2008-03-24 17:42:45 +01:00
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
y_offset = 2 * c->border + c->geometry.height - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
y_offset = (c->geometry.height - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-16 18:00:49 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
|
|
|
c->geometry.x + c->geometry.width + 2 * c->border,
|
2008-03-24 17:42:45 +01:00
|
|
|
c->geometry.y + y_offset,
|
2008-03-16 18:00:49 +01:00
|
|
|
c->titlebar.sw->geometry.width,
|
2008-03-24 16:31:02 +01:00
|
|
|
width);
|
2008-03-16 18:00:49 +01:00
|
|
|
break;
|
2008-03-15 15:24:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
titlebar_update(c);
|
|
|
|
}
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
area_t
|
|
|
|
titlebar_update_geometry(Client *c, area_t geometry)
|
|
|
|
{
|
2008-03-24 17:42:45 +01:00
|
|
|
int width, x_offset = 0 , y_offset = 0;
|
2008-03-24 16:31:02 +01:00
|
|
|
|
2008-03-16 11:07:59 +01:00
|
|
|
if(!c->titlebar.sw)
|
2008-03-16 11:33:13 +01:00
|
|
|
return geometry;
|
2008-03-16 11:07:59 +01:00
|
|
|
|
2008-03-15 14:19:52 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return geometry;
|
|
|
|
case Top:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
2008-03-24 17:42:45 +01:00
|
|
|
width = geometry.width + 2 * c->border;
|
2008-03-24 16:31:02 +01:00
|
|
|
else
|
2008-03-24 17:42:45 +01:00
|
|
|
width = MIN(c->titlebar.width, geometry.width);
|
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
x_offset = 2 * c->border + geometry.width - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
x_offset = (geometry.width - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 14:19:52 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-24 17:42:45 +01:00
|
|
|
geometry.x + x_offset,
|
2008-03-15 14:19:52 +01:00
|
|
|
geometry.y,
|
2008-03-24 16:31:02 +01:00
|
|
|
width,
|
2008-03-15 14:19:52 +01:00
|
|
|
c->titlebar.sw->geometry.height);
|
|
|
|
geometry.y += c->titlebar.sw->geometry.height;
|
|
|
|
geometry.height -= c->titlebar.sw->geometry.height;
|
|
|
|
break;
|
|
|
|
case Bottom:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
2008-03-24 17:42:45 +01:00
|
|
|
width = geometry.width + 2 * c->border;
|
2008-03-24 16:31:02 +01:00
|
|
|
else
|
2008-03-24 17:42:45 +01:00
|
|
|
width = MIN(c->titlebar.width, geometry.width);
|
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
x_offset = 2 * c->border + geometry.width - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
x_offset = (geometry.width - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 14:19:52 +01:00
|
|
|
geometry.height -= c->titlebar.sw->geometry.height;
|
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-24 17:42:45 +01:00
|
|
|
geometry.x + x_offset,
|
2008-03-15 14:19:52 +01:00
|
|
|
geometry.y + geometry.height + 2 * c->border,
|
2008-03-24 16:31:02 +01:00
|
|
|
width,
|
2008-03-15 14:19:52 +01:00
|
|
|
c->titlebar.sw->geometry.height);
|
|
|
|
break;
|
2008-03-15 20:10:09 +01:00
|
|
|
case Left:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
2008-03-24 17:42:45 +01:00
|
|
|
width = geometry.height + 2 * c->border;
|
2008-03-24 16:31:02 +01:00
|
|
|
else
|
2008-03-24 17:42:45 +01:00
|
|
|
width = MIN(c->titlebar.width, geometry.height);
|
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
y_offset = 2 * c->border + geometry.height - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
y_offset = (geometry.height - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 20:10:09 +01:00
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
|
|
|
geometry.x,
|
2008-03-24 17:42:45 +01:00
|
|
|
geometry.y + y_offset,
|
2008-03-15 20:10:09 +01:00
|
|
|
c->titlebar.sw->geometry.width,
|
2008-03-24 16:31:02 +01:00
|
|
|
width);
|
2008-03-15 20:10:09 +01:00
|
|
|
geometry.width -= c->titlebar.sw->geometry.width;
|
|
|
|
geometry.x += c->titlebar.sw->geometry.width;
|
|
|
|
break;
|
2008-03-16 18:00:49 +01:00
|
|
|
case Right:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
2008-03-24 17:42:45 +01:00
|
|
|
width = geometry.height + 2 * c->border;
|
2008-03-24 16:31:02 +01:00
|
|
|
else
|
2008-03-24 17:42:45 +01:00
|
|
|
width = MIN(c->titlebar.width, geometry.height);
|
|
|
|
switch(c->titlebar.align)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case AlignRight:
|
|
|
|
y_offset = 2 * c->border + geometry.height - width;
|
|
|
|
break;
|
|
|
|
case AlignCenter:
|
|
|
|
y_offset = (geometry.height - width) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-16 18:00:49 +01:00
|
|
|
geometry.width -= c->titlebar.sw->geometry.width;
|
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
|
|
|
geometry.x + geometry.width + 2 * c->border,
|
2008-03-24 17:42:45 +01:00
|
|
|
geometry.y + y_offset,
|
2008-03-16 18:00:49 +01:00
|
|
|
c->titlebar.sw->geometry.width,
|
2008-03-24 16:31:02 +01:00
|
|
|
width);
|
2008-03-16 18:00:49 +01:00
|
|
|
break;
|
2008-03-15 14:19:52 +01:00
|
|
|
}
|
2008-03-15 13:59:04 +01:00
|
|
|
|
|
|
|
titlebar_update(c);
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Toggle window titlebar visibility
|
|
|
|
* \param screen screen number (unused)
|
|
|
|
* \param arg unused argument
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
uicb_client_toggletitlebar(int screen __attribute__ ((unused)),
|
|
|
|
char *arg __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
Client *c = globalconf.focus->client;
|
|
|
|
|
2008-03-17 08:42:36 +01:00
|
|
|
if(!c || !c->titlebar.sw)
|
2008-03-15 13:59:04 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if(!c->titlebar.position)
|
|
|
|
c->titlebar.position = c->titlebar.dposition;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c->titlebar.position = Off;
|
|
|
|
XUnmapWindow(globalconf.display, c->titlebar.sw->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
globalconf.screens[c->screen].need_arrange = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|