wibox: add full geometry
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f374210382
commit
305af484f5
|
@ -20,6 +20,7 @@ floating
|
|||
focus
|
||||
fullscreen
|
||||
gap
|
||||
geometry
|
||||
grow
|
||||
height
|
||||
hide
|
||||
|
|
2
event.c
2
event.c
|
@ -163,7 +163,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
|||
if((c = client_getbytitlebarwin(ev->event)))
|
||||
{
|
||||
if((w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
||||
c->titlebar->width, c->titlebar->height,
|
||||
c->titlebar->geometry.width, c->titlebar->geometry.height,
|
||||
&ev->event_x, &ev->event_y)))
|
||||
w->widget->button(w, ev, c->screen, c->titlebar);
|
||||
/* return even if no widget match */
|
||||
|
|
27
screen.c
27
screen.c
|
@ -265,8 +265,8 @@ display_area_get(int phys_screen, wibox_array_t *statusbars, padding_t *padding)
|
|||
for(int i = 0; i < statusbars->len; i++)
|
||||
{
|
||||
wibox_t *sb = statusbars->tab[i];
|
||||
area.y += sb->position == Top ? sb->height : 0;
|
||||
area.height -= (sb->position == Top || sb->position == Bottom) ? sb->height : 0;
|
||||
area.y += sb->position == Top ? sb->geometry.height : 0;
|
||||
area.height -= (sb->position == Top || sb->position == Bottom) ? sb->geometry.height : 0;
|
||||
}
|
||||
|
||||
/* make padding corrections */
|
||||
|
@ -489,7 +489,6 @@ luaA_screen_index(lua_State *L)
|
|||
size_t len;
|
||||
const char *buf;
|
||||
screen_t *s;
|
||||
area_t g;
|
||||
|
||||
if(luaA_usemetatable(L, 1, 2))
|
||||
return 1;
|
||||
|
@ -500,28 +499,10 @@ luaA_screen_index(lua_State *L)
|
|||
switch(a_tokenize(buf, len))
|
||||
{
|
||||
case A_TK_COORDS:
|
||||
/* \todo lua_pushgeometry() ? */
|
||||
lua_newtable(L);
|
||||
lua_pushnumber(L, s->geometry.x);
|
||||
lua_setfield(L, -2, "x");
|
||||
lua_pushnumber(L, s->geometry.y);
|
||||
lua_setfield(L, -2, "y");
|
||||
lua_pushnumber(L, s->geometry.width);
|
||||
lua_setfield(L, -2, "width");
|
||||
lua_pushnumber(L, s->geometry.height);
|
||||
lua_setfield(L, -2, "height");
|
||||
luaA_pusharea(L, s->geometry);
|
||||
break;
|
||||
case A_TK_WORKAREA:
|
||||
g = screen_area_get(s->index, &s->statusbars, &s->padding, true);
|
||||
lua_newtable(L);
|
||||
lua_pushnumber(L, g.x);
|
||||
lua_setfield(L, -2, "x");
|
||||
lua_pushnumber(L, g.y);
|
||||
lua_setfield(L, -2, "y");
|
||||
lua_pushnumber(L, g.width);
|
||||
lua_setfield(L, -2, "width");
|
||||
lua_pushnumber(L, g.height);
|
||||
lua_setfield(L, -2, "height");
|
||||
luaA_pusharea(L, screen_area_get(s->index, &s->statusbars, &s->padding, true));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
108
statusbar.c
108
statusbar.c
|
@ -267,7 +267,7 @@ statusbar_refresh(void)
|
|||
void
|
||||
statusbar_position_update(wibox_t *statusbar)
|
||||
{
|
||||
area_t area, wingeometry;
|
||||
area_t area;
|
||||
bool ignore = false;
|
||||
|
||||
if(statusbar->position == Off)
|
||||
|
@ -299,7 +299,7 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
switch(statusbar->position)
|
||||
{
|
||||
case Left:
|
||||
area.x += statusbar->height;
|
||||
area.x += statusbar->geometry.height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -309,7 +309,7 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
switch(statusbar->position)
|
||||
{
|
||||
case Right:
|
||||
area.x -= statusbar->height;
|
||||
area.x -= statusbar->geometry.height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -319,12 +319,12 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
switch(statusbar->position)
|
||||
{
|
||||
case Top:
|
||||
area.y += sb->height;
|
||||
area.y += sb->geometry.height;
|
||||
break;
|
||||
case Left:
|
||||
case Right:
|
||||
area.height -= sb->height;
|
||||
area.y += sb->height;
|
||||
area.height -= sb->geometry.height;
|
||||
area.y += sb->geometry.height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -334,11 +334,11 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
switch(statusbar->position)
|
||||
{
|
||||
case Bottom:
|
||||
area.y -= sb->height;
|
||||
area.y -= sb->geometry.height;
|
||||
break;
|
||||
case Left:
|
||||
case Right:
|
||||
area.height -= sb->height;
|
||||
area.height -= sb->geometry.height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -352,89 +352,77 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
switch(statusbar->position)
|
||||
{
|
||||
case Right:
|
||||
if(statusbar->width > 0)
|
||||
wingeometry.height = statusbar->width;
|
||||
else
|
||||
wingeometry.height = area.height;
|
||||
wingeometry.width = statusbar->height;
|
||||
statusbar->geometry.height = area.height;
|
||||
statusbar->geometry.width = 1.5 * globalconf.font->height;
|
||||
switch(statusbar->align)
|
||||
{
|
||||
default:
|
||||
wingeometry.x = area.x + area.width - wingeometry.width;
|
||||
wingeometry.y = area.y;
|
||||
statusbar->geometry.x = area.x + area.width - statusbar->geometry.width;
|
||||
statusbar->geometry.y = area.y;
|
||||
break;
|
||||
case AlignRight:
|
||||
wingeometry.x = area.x + area.width - wingeometry.width;
|
||||
wingeometry.y = area.y + area.height - wingeometry.height;
|
||||
statusbar->geometry.x = area.x + area.width - statusbar->geometry.width;
|
||||
statusbar->geometry.y = area.y + area.height - statusbar->geometry.height;
|
||||
break;
|
||||
case AlignCenter:
|
||||
wingeometry.x = area.x + area.width - wingeometry.width;
|
||||
wingeometry.y = (area.y + area.height - wingeometry.height) / 2;
|
||||
statusbar->geometry.x = area.x + area.width - statusbar->geometry.width;
|
||||
statusbar->geometry.y = (area.y + area.height - statusbar->geometry.height) / 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Left:
|
||||
if(statusbar->width > 0)
|
||||
wingeometry.height = statusbar->width;
|
||||
else
|
||||
wingeometry.height = area.height;
|
||||
wingeometry.width = statusbar->height;
|
||||
statusbar->geometry.height = area.height;
|
||||
statusbar->geometry.width = 1.5 * globalconf.font->height;
|
||||
switch(statusbar->align)
|
||||
{
|
||||
default:
|
||||
wingeometry.x = area.x;
|
||||
wingeometry.y = (area.y + area.height) - wingeometry.height;
|
||||
statusbar->geometry.x = area.x;
|
||||
statusbar->geometry.y = (area.y + area.height) - statusbar->geometry.height;
|
||||
break;
|
||||
case AlignRight:
|
||||
wingeometry.x = area.x;
|
||||
wingeometry.y = area.y;
|
||||
statusbar->geometry.x = area.x;
|
||||
statusbar->geometry.y = area.y;
|
||||
break;
|
||||
case AlignCenter:
|
||||
wingeometry.x = area.x;
|
||||
wingeometry.y = (area.y + area.height - wingeometry.height) / 2;
|
||||
statusbar->geometry.x = area.x;
|
||||
statusbar->geometry.y = (area.y + area.height - statusbar->geometry.height) / 2;
|
||||
}
|
||||
break;
|
||||
case Bottom:
|
||||
if(statusbar->width > 0)
|
||||
wingeometry.width = statusbar->width;
|
||||
else
|
||||
wingeometry.width = area.width;
|
||||
wingeometry.height = statusbar->height;
|
||||
statusbar->geometry.width = area.width;
|
||||
statusbar->geometry.height = 1.5 * globalconf.font->height;
|
||||
switch(statusbar->align)
|
||||
{
|
||||
default:
|
||||
wingeometry.x = area.x;
|
||||
wingeometry.y = (area.y + area.height) - wingeometry.height;
|
||||
statusbar->geometry.x = area.x;
|
||||
statusbar->geometry.y = (area.y + area.height) - statusbar->geometry.height;
|
||||
break;
|
||||
case AlignRight:
|
||||
wingeometry.x = area.x + area.width - wingeometry.width;
|
||||
wingeometry.y = (area.y + area.height) - wingeometry.height;
|
||||
statusbar->geometry.x = area.x + area.width - statusbar->geometry.width;
|
||||
statusbar->geometry.y = (area.y + area.height) - statusbar->geometry.height;
|
||||
break;
|
||||
case AlignCenter:
|
||||
wingeometry.x = area.x + (area.width - wingeometry.width) / 2;
|
||||
wingeometry.y = (area.y + area.height) - wingeometry.height;
|
||||
statusbar->geometry.x = area.x + (area.width - statusbar->geometry.width) / 2;
|
||||
statusbar->geometry.y = (area.y + area.height) - statusbar->geometry.height;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(statusbar->width > 0)
|
||||
wingeometry.width = statusbar->width;
|
||||
else
|
||||
wingeometry.width = area.width;
|
||||
wingeometry.height = statusbar->height;
|
||||
statusbar->geometry.width = area.width;
|
||||
statusbar->geometry.height = 1.5 * globalconf.font->height;
|
||||
switch(statusbar->align)
|
||||
{
|
||||
default:
|
||||
wingeometry.x = area.x;
|
||||
wingeometry.y = area.y;
|
||||
statusbar->geometry.x = area.x;
|
||||
statusbar->geometry.y = area.y;
|
||||
break;
|
||||
case AlignRight:
|
||||
wingeometry.x = area.x + area.width - wingeometry.width;
|
||||
wingeometry.y = area.y;
|
||||
statusbar->geometry.x = area.x + area.width - statusbar->geometry.width;
|
||||
statusbar->geometry.y = area.y;
|
||||
break;
|
||||
case AlignCenter:
|
||||
wingeometry.x = area.x + (area.width - wingeometry.width) / 2;
|
||||
wingeometry.y = area.y;
|
||||
statusbar->geometry.x = area.x + (area.width - statusbar->geometry.width) / 2;
|
||||
statusbar->geometry.y = area.y;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -445,8 +433,8 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
int phys_screen = screen_virttophys(statusbar->screen);
|
||||
|
||||
simplewindow_init(&statusbar->sw, phys_screen,
|
||||
wingeometry.x, wingeometry.y,
|
||||
wingeometry.width, wingeometry.height,
|
||||
statusbar->geometry.x, statusbar->geometry.y,
|
||||
statusbar->geometry.width, statusbar->geometry.height,
|
||||
0, statusbar->position,
|
||||
&statusbar->colors.fg, &statusbar->colors.bg);
|
||||
statusbar->need_update = true;
|
||||
|
@ -455,16 +443,16 @@ statusbar_position_update(wibox_t *statusbar)
|
|||
/* same window size and position ? */
|
||||
else
|
||||
{
|
||||
if(wingeometry.width != statusbar->sw.geometry.width
|
||||
|| wingeometry.height != statusbar->sw.geometry.height)
|
||||
if(statusbar->geometry.width != statusbar->sw.geometry.width
|
||||
|| statusbar->geometry.height != statusbar->sw.geometry.height)
|
||||
{
|
||||
simplewindow_resize(&statusbar->sw, wingeometry.width, wingeometry.height);
|
||||
simplewindow_resize(&statusbar->sw, statusbar->geometry.width, statusbar->geometry.height);
|
||||
statusbar->need_update = true;
|
||||
}
|
||||
|
||||
if(wingeometry.x != statusbar->sw.geometry.x
|
||||
|| wingeometry.y != statusbar->sw.geometry.y)
|
||||
simplewindow_move(&statusbar->sw, wingeometry.x, wingeometry.y);
|
||||
if(statusbar->geometry.x != statusbar->sw.geometry.x
|
||||
|| statusbar->geometry.y != statusbar->sw.geometry.y)
|
||||
simplewindow_move(&statusbar->sw, statusbar->geometry.x, statusbar->geometry.y);
|
||||
}
|
||||
|
||||
/* Set need update */
|
||||
|
|
|
@ -94,8 +94,8 @@ typedef struct
|
|||
wibox_type_t type;
|
||||
/** Window */
|
||||
simple_window_t sw;
|
||||
/** Box width and height */
|
||||
uint16_t width, height;
|
||||
/** Box geometry */
|
||||
area_t geometry;
|
||||
/** Box position */
|
||||
position_t position;
|
||||
/** Alignment */
|
||||
|
|
40
titlebar.c
40
titlebar.c
|
@ -102,8 +102,8 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|||
default:
|
||||
return;
|
||||
case Top:
|
||||
if(c->titlebar->width)
|
||||
width = MAX(1, MIN(c->titlebar->width, geometry.width - 2 * c->titlebar->sw.border.width));
|
||||
if(c->titlebar->geometry.width)
|
||||
width = MAX(1, MIN(c->titlebar->geometry.width, geometry.width - 2 * c->titlebar->sw.border.width));
|
||||
else
|
||||
width = MAX(1, geometry.width + 2 * c->border - 2 * c->titlebar->sw.border.width);
|
||||
switch(c->titlebar->align)
|
||||
|
@ -118,13 +118,13 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|||
break;
|
||||
}
|
||||
res->x = geometry.x + x_offset;
|
||||
res->y = geometry.y - c->titlebar->height - 2 * c->titlebar->sw.border.width + c->border;
|
||||
res->y = geometry.y - c->titlebar->geometry.height - 2 * c->titlebar->sw.border.width + c->border;
|
||||
res->width = width;
|
||||
res->height = c->titlebar->height;
|
||||
res->height = c->titlebar->geometry.height;
|
||||
break;
|
||||
case Bottom:
|
||||
if(c->titlebar->width)
|
||||
width = MAX(1, MIN(c->titlebar->width, geometry.width - 2 * c->titlebar->sw.border.width));
|
||||
if(c->titlebar->geometry.width)
|
||||
width = MAX(1, MIN(c->titlebar->geometry.width, geometry.width - 2 * c->titlebar->sw.border.width));
|
||||
else
|
||||
width = MAX(1, geometry.width + 2 * c->border - 2 * c->titlebar->sw.border.width);
|
||||
switch(c->titlebar->align)
|
||||
|
@ -141,11 +141,11 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|||
res->x = geometry.x + x_offset;
|
||||
res->y = geometry.y + geometry.height + c->border;
|
||||
res->width = width;
|
||||
res->height = c->titlebar->height;
|
||||
res->height = c->titlebar->geometry.height;
|
||||
break;
|
||||
case Left:
|
||||
if(c->titlebar->width)
|
||||
width = MAX(1, MIN(c->titlebar->width, geometry.height - 2 * c->titlebar->sw.border.width));
|
||||
if(c->titlebar->geometry.width)
|
||||
width = MAX(1, MIN(c->titlebar->geometry.width, geometry.height - 2 * c->titlebar->sw.border.width));
|
||||
else
|
||||
width = MAX(1, geometry.height + 2 * c->border - 2 * c->titlebar->sw.border.width);
|
||||
switch(c->titlebar->align)
|
||||
|
@ -159,14 +159,14 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|||
y_offset = (geometry.height - width) / 2;
|
||||
break;
|
||||
}
|
||||
res->x = geometry.x - c->titlebar->height + c->border;
|
||||
res->x = geometry.x - c->titlebar->geometry.height + c->border;
|
||||
res->y = geometry.y + y_offset;
|
||||
res->width = c->titlebar->height;
|
||||
res->width = c->titlebar->geometry.height;
|
||||
res->height = width;
|
||||
break;
|
||||
case Right:
|
||||
if(c->titlebar->width)
|
||||
width = MAX(1, MIN(c->titlebar->width, geometry.height - 2 * c->titlebar->sw.border.width));
|
||||
if(c->titlebar->geometry.width)
|
||||
width = MAX(1, MIN(c->titlebar->geometry.width, geometry.height - 2 * c->titlebar->sw.border.width));
|
||||
else
|
||||
width = MAX(1, geometry.height + 2 * c->border - 2 * c->titlebar->sw.border.width);
|
||||
switch(c->titlebar->align)
|
||||
|
@ -182,7 +182,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|||
}
|
||||
res->x = geometry.x + geometry.width + c->border;
|
||||
res->y = geometry.y + y_offset;
|
||||
res->width = c->titlebar->height;
|
||||
res->width = c->titlebar->geometry.height;
|
||||
res->height = width;
|
||||
break;
|
||||
}
|
||||
|
@ -208,19 +208,19 @@ titlebar_init(client_t *c)
|
|||
return;
|
||||
case Top:
|
||||
case Bottom:
|
||||
if(c->titlebar->width)
|
||||
width = MIN(c->titlebar->width, c->geometry.width - 2 * c->titlebar->sw.border.width);
|
||||
if(c->titlebar->geometry.width)
|
||||
width = MIN(c->titlebar->geometry.width, c->geometry.width - 2 * c->titlebar->sw.border.width);
|
||||
else
|
||||
width = c->geometry.width + 2 * c->border - 2 * c->titlebar->sw.border.width;
|
||||
height = c->titlebar->height;
|
||||
height = c->titlebar->geometry.height;
|
||||
break;
|
||||
case Left:
|
||||
case Right:
|
||||
if(c->titlebar->width)
|
||||
height = MIN(c->titlebar->width, c->geometry.height - 2 * c->titlebar->sw.border.width);
|
||||
if(c->titlebar->geometry.width)
|
||||
height = MIN(c->titlebar->geometry.width, c->geometry.height - 2 * c->titlebar->sw.border.width);
|
||||
else
|
||||
height = c->geometry.height + 2 * c->border - 2 * c->titlebar->sw.border.width;
|
||||
width = c->titlebar->height;
|
||||
width = c->titlebar->geometry.height;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
18
wibox.c
18
wibox.c
|
@ -90,11 +90,11 @@ luaA_wibox_new(lua_State *L)
|
|||
buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
|
||||
w->align = draw_align_fromstr(buf, len);
|
||||
|
||||
w->width = luaA_getopt_number(L, 2, "width", 0);
|
||||
w->height = luaA_getopt_number(L, 2, "height", 0);
|
||||
if(w->height <= 0)
|
||||
w->geometry.width = luaA_getopt_number(L, 2, "width", 0);
|
||||
w->geometry.height = luaA_getopt_number(L, 2, "height", 0);
|
||||
if(w->geometry.height <= 0)
|
||||
/* 1.5 as default factor, it fits nice but no one knows why */
|
||||
w->height = 1.5 * globalconf.font->height;
|
||||
w->geometry.height = 1.5 * globalconf.font->height;
|
||||
|
||||
buf = luaA_getopt_lstring(L, 2, "position", "top", &len);
|
||||
w->position = position_fromstr(buf, len);
|
||||
|
@ -111,6 +111,7 @@ luaA_wibox_new(lua_State *L)
|
|||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lfield geometry Geometry table.
|
||||
* \lfield screen Screen number.
|
||||
* \lfield client The client attached to this titlebar.
|
||||
* \lfield border_width Border width.
|
||||
|
@ -134,6 +135,9 @@ luaA_wibox_index(lua_State *L)
|
|||
{
|
||||
client_t *c;
|
||||
|
||||
case A_TK_GEOMETRY:
|
||||
luaA_pusharea(L, (*wibox)->geometry);
|
||||
break;
|
||||
case A_TK_CLIENT:
|
||||
if((c = client_getbytitlebar(*wibox)))
|
||||
return luaA_client_userdata_new(L, c);
|
||||
|
@ -162,12 +166,6 @@ luaA_wibox_index(lua_State *L)
|
|||
case A_TK_POSITION:
|
||||
lua_pushstring(L, position_tostr((*wibox)->position));
|
||||
break;
|
||||
case A_TK_WIDTH:
|
||||
lua_pushnumber(L, (*wibox)->width);
|
||||
break;
|
||||
case A_TK_HEIGHT:
|
||||
lua_pushnumber(L, (*wibox)->height);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue