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-21 16:50:17 +01:00
|
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <xcb/xcb_aux.h>
|
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2008-03-15 13:59:04 +01:00
|
|
|
#include "titlebar.h"
|
2008-04-28 12:55:11 +02:00
|
|
|
#include "client.h"
|
2008-03-17 08:56:17 +01:00
|
|
|
#include "screen.h"
|
2008-04-04 10:26:46 +02:00
|
|
|
#include "layouts/floating.h"
|
2008-03-15 13:59:04 +01:00
|
|
|
|
|
|
|
extern AwesomeConf globalconf;
|
|
|
|
|
2008-04-23 17:44:09 +02:00
|
|
|
static char *
|
|
|
|
titlebar_text(client_t *c)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
if(globalconf.focus->client == c)
|
|
|
|
text = c->titlebar.text_focus;
|
|
|
|
else if(c->isurgent)
|
|
|
|
text = c->titlebar.text_urgent;
|
|
|
|
else
|
|
|
|
text = c->titlebar.text_normal;
|
|
|
|
|
2008-04-28 12:23:10 +02:00
|
|
|
return client_markup_parse(c, text, a_strlen(text));
|
2008-04-23 17:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline area_t
|
|
|
|
titlebar_size(client_t *c)
|
|
|
|
{
|
|
|
|
return draw_text_extents(globalconf.connection, globalconf.default_screen,
|
|
|
|
globalconf.screens[c->screen].styles.normal.font, titlebar_text(c));
|
|
|
|
}
|
|
|
|
|
2008-04-09 19:41:28 +02:00
|
|
|
/** Initialize a titlebar: create the simple_window_t.
|
2008-04-04 10:26:46 +02:00
|
|
|
* We still need to update its geometry to have it placed correctly.
|
|
|
|
* \param c the client
|
|
|
|
*/
|
2008-03-17 08:56:17 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
titlebar_init(client_t *c)
|
2008-03-17 08:56:17 +01:00
|
|
|
{
|
2008-04-23 17:44:09 +02:00
|
|
|
int width = 0, height = 0;
|
2008-03-17 08:56:17 +01:00
|
|
|
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.height)
|
2008-04-23 17:44:09 +02:00
|
|
|
c->titlebar.height = MAX(MAX(draw_text_extents(globalconf.connection, globalconf.default_screen,
|
2008-04-28 17:38:03 +02:00
|
|
|
globalconf.screens[c->screen].styles.focus.font,
|
|
|
|
client_markup_parse(c, c->titlebar.text_focus, a_strlen(c->titlebar.text_focus))).height,
|
2008-04-23 17:44:09 +02:00
|
|
|
draw_text_extents(globalconf.connection, globalconf.default_screen,
|
2008-04-28 17:38:03 +02:00
|
|
|
globalconf.screens[c->screen].styles.normal.font,
|
|
|
|
client_markup_parse(c, c->titlebar.text_normal, a_strlen(c->titlebar.text_normal))).height),
|
2008-04-23 17:44:09 +02:00
|
|
|
draw_text_extents(globalconf.connection, globalconf.default_screen,
|
2008-04-28 17:38:03 +02:00
|
|
|
globalconf.screens[c->screen].styles.urgent.font,
|
|
|
|
client_markup_parse(c, c->titlebar.text_urgent, a_strlen(c->titlebar.text_urgent))).height);
|
2008-03-20 20:45:08 +01:00
|
|
|
|
2008-03-17 08:56:17 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
2008-04-04 10:26:46 +02:00
|
|
|
case Off:
|
|
|
|
return;
|
2008-04-23 17:44:09 +02:00
|
|
|
default:
|
2008-04-04 10:26:46 +02:00
|
|
|
c->titlebar.position = Off;
|
|
|
|
return;
|
2008-03-17 08:56:17 +01:00
|
|
|
case Top:
|
|
|
|
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-04-23 17:44:09 +02:00
|
|
|
height = c->titlebar.height;
|
2008-03-17 08:56:17 +01:00
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
case Right:
|
2008-03-24 16:31:02 +01:00
|
|
|
if(!c->titlebar.width)
|
2008-04-23 17:44:09 +02:00
|
|
|
height = c->geometry.height + 2 * c->border;
|
2008-03-24 16:31:02 +01:00
|
|
|
else
|
2008-04-23 17:44:09 +02:00
|
|
|
height = MIN(c->titlebar.width, c->geometry.height);
|
|
|
|
width = c->titlebar.height;
|
2008-03-17 08:56:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-04-23 17:44:09 +02:00
|
|
|
c->titlebar.sw = simplewindow_new(globalconf.connection,
|
|
|
|
c->phys_screen, 0, 0,
|
|
|
|
width, height, 0);
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_map_window(globalconf.connection, c->titlebar.sw->window);
|
2008-03-17 08:56:17 +01:00
|
|
|
}
|
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
/** Add the titlebar geometry to a geometry.
|
|
|
|
* \param t the titlebar
|
|
|
|
* \param geometry the geometry
|
|
|
|
* \return a new geometry bigger if the titlebar is visible
|
|
|
|
*/
|
2008-03-25 14:45:13 +01:00
|
|
|
area_t
|
2008-04-10 11:53:44 +02:00
|
|
|
titlebar_geometry_add(titlebar_t *t, area_t geometry)
|
2008-03-25 14:45:13 +01:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
/** Remove the titlebar geometry to a geometry.
|
|
|
|
* \param t the titlebar
|
|
|
|
* \param geometry the geometry
|
|
|
|
* \return a new geometry smaller if the titlebar is visible
|
|
|
|
*/
|
2008-03-25 14:56:21 +01:00
|
|
|
area_t
|
2008-04-10 11:53:44 +02:00
|
|
|
titlebar_geometry_remove(titlebar_t *t, area_t geometry)
|
2008-03-25 14:56:21 +01:00
|
|
|
{
|
|
|
|
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-04-04 10:26:46 +02:00
|
|
|
/** Draw the titlebar content.
|
|
|
|
* \param c the client
|
|
|
|
*/
|
2008-03-15 13:59:04 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
titlebar_draw(client_t *c)
|
2008-03-15 13:59:04 +01:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_drawable_t dw = 0;
|
2008-04-28 15:32:30 +02:00
|
|
|
draw_context_t *ctx;
|
2008-03-15 13:59:04 +01:00
|
|
|
area_t geometry;
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_screen_t *s;
|
2008-04-23 17:44:09 +02:00
|
|
|
char *text;
|
2008-04-29 11:42:16 +02:00
|
|
|
style_t *style;
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
if(!c->titlebar.sw)
|
|
|
|
return;
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
s = xcb_aux_get_screen(globalconf.connection,
|
|
|
|
c->titlebar.sw->phys_screen);
|
|
|
|
|
2008-03-15 20:10:09 +01:00
|
|
|
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-21 16:50:17 +01:00
|
|
|
dw = xcb_generate_id(globalconf.connection);
|
|
|
|
xcb_create_pixmap(globalconf.connection, s->root_depth,
|
|
|
|
dw,
|
2008-03-27 16:05:37 +01:00
|
|
|
s->root,
|
2008-03-21 16:50:17 +01:00
|
|
|
c->titlebar.sw->geometry.height,
|
|
|
|
c->titlebar.sw->geometry.width);
|
|
|
|
ctx = draw_context_new(globalconf.connection, c->titlebar.sw->phys_screen,
|
2008-03-15 20:10:09 +01:00
|
|
|
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:
|
2008-03-21 16:50:17 +01:00
|
|
|
ctx = draw_context_new(globalconf.connection, c->titlebar.sw->phys_screen,
|
2008-03-15 20:10:09 +01:00
|
|
|
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-04-23 17:44:09 +02:00
|
|
|
text = titlebar_text(c);
|
2008-03-15 13:59:04 +01:00
|
|
|
geometry.x = geometry.y = 0;
|
2008-04-29 11:42:16 +02:00
|
|
|
style = client_style_get(c);
|
2008-04-29 11:51:59 +02:00
|
|
|
draw_text(ctx, geometry, text, style);
|
2008-04-23 17:44:09 +02:00
|
|
|
p_delete(&text);
|
2008-03-15 13:59:04 +01:00
|
|
|
|
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-21 16:50:17 +01:00
|
|
|
xcb_free_pixmap(globalconf.connection, 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-21 16:50:17 +01:00
|
|
|
xcb_free_pixmap(globalconf.connection, dw);
|
2008-03-15 20:10:09 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-09 19:40:32 +02:00
|
|
|
simplewindow_refresh_drawable(c->titlebar.sw);
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-03-21 11:26:56 +01:00
|
|
|
draw_context_delete(&ctx);
|
2008-03-15 13:59:04 +01:00
|
|
|
}
|
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
/** Update the titlebar geometry for a floating client.
|
|
|
|
* \param c the client
|
|
|
|
*/
|
2008-03-15 15:24:47 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
titlebar_update_geometry_floating(client_t *c)
|
2008-03-15 15:24:47 +01:00
|
|
|
{
|
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;
|
2008-04-04 10:26:46 +02:00
|
|
|
case Off:
|
|
|
|
return;
|
2008-03-15 15:24:47 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
titlebar_draw(c);
|
2008-03-15 15:24:47 +01:00
|
|
|
}
|
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
|
|
|
|
/** Update the titlebar geometry for a tiled client.
|
|
|
|
* \param c the client
|
|
|
|
* \param geometry the geometry the client will receive
|
|
|
|
*/
|
2008-03-26 10:57:06 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
titlebar_update_geometry(client_t *c, area_t geometry)
|
2008-03-15 13:59:04 +01:00
|
|
|
{
|
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-26 10:57:06 +01:00
|
|
|
return;
|
2008-03-16 11:07:59 +01:00
|
|
|
|
2008-03-15 14:19:52 +01:00
|
|
|
switch(c->titlebar.position)
|
|
|
|
{
|
|
|
|
default:
|
2008-03-26 10:57:06 +01:00
|
|
|
return;
|
2008-04-04 10:26:46 +02:00
|
|
|
case Off:
|
|
|
|
return;
|
2008-03-15 14:19:52 +01:00
|
|
|
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);
|
|
|
|
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
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-24 17:42:45 +01:00
|
|
|
geometry.x + x_offset,
|
2008-03-26 10:46:25 +01:00
|
|
|
geometry.y + geometry.height
|
|
|
|
- c->titlebar.sw->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
|
|
|
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
|
|
|
simplewindow_move_resize(c->titlebar.sw,
|
2008-03-26 10:46:25 +01:00
|
|
|
geometry.x + geometry.width
|
|
|
|
- c->titlebar.sw->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
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
titlebar_draw(c);
|
2008-03-15 13:59:04 +01:00
|
|
|
}
|
|
|
|
|
2008-04-24 22:58:25 +02:00
|
|
|
void
|
2008-04-11 11:19:23 +02:00
|
|
|
titlebar_position_set(titlebar_t *t, position_t p)
|
2008-04-24 22:58:25 +02:00
|
|
|
{
|
|
|
|
if(!t->sw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if((t->position = p))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_map_window(globalconf.connection, t->sw->window);
|
2008-04-24 22:58:25 +02:00
|
|
|
else
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_unmap_window(globalconf.connection, t->sw->window);
|
2008-04-24 22:58:25 +02:00
|
|
|
}
|
|
|
|
|
2008-04-10 23:37:22 +02:00
|
|
|
/** Toggle the visibility of the focused window's titlebar.
|
2008-03-15 13:59:04 +01:00
|
|
|
* \param screen screen number (unused)
|
|
|
|
* \param arg unused argument
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
|
|
|
void
|
2008-03-27 15:00:46 +01:00
|
|
|
uicb_client_toggletitlebar(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused)))
|
2008-03-15 13:59:04 +01:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c = globalconf.focus->client;
|
2008-03-15 13:59:04 +01:00
|
|
|
|
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)
|
2008-04-24 22:58:25 +02:00
|
|
|
titlebar_position_set(&c->titlebar, c->titlebar.dposition);
|
2008-03-15 13:59:04 +01:00
|
|
|
else
|
2008-04-24 22:58:25 +02:00
|
|
|
titlebar_position_set(&c->titlebar, Off);
|
2008-03-15 13:59:04 +01:00
|
|
|
|
2008-04-04 10:26:46 +02:00
|
|
|
if(c->isfloating || layout_get_current(screen)->arrange == layout_floating)
|
|
|
|
titlebar_update_geometry_floating(c);
|
|
|
|
else
|
2008-03-21 16:50:17 +01:00
|
|
|
globalconf.screens[c->screen].need_arrange = true;
|
2008-03-15 13:59:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|