[titlebar] Rewrote titlebar based on widgets
This is the new titlebar handling code, based on widgets. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
dfea3c3bba
commit
1e08a992b8
68
client.c
68
client.c
|
@ -198,7 +198,7 @@ client_updatetitle(client_t *c)
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
||||||
|
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar_getbyclient(c));
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ client_unfocus(client_t *c)
|
||||||
|
|
||||||
focus_client_push(NULL);
|
focus_client_push(NULL);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar_getbyclient(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ban client and unmap it
|
/** Ban client and unmap it
|
||||||
|
@ -220,12 +220,14 @@ client_unfocus(client_t *c)
|
||||||
void
|
void
|
||||||
client_ban(client_t *c)
|
client_ban(client_t *c)
|
||||||
{
|
{
|
||||||
|
titlebar_t *titlebar = titlebar_getbyclient(c);
|
||||||
|
|
||||||
if(globalconf.focus->client == c)
|
if(globalconf.focus->client == c)
|
||||||
client_unfocus(c);
|
client_unfocus(c);
|
||||||
xcb_unmap_window(globalconf.connection, c->win);
|
xcb_unmap_window(globalconf.connection, c->win);
|
||||||
window_setstate(c->win, XCB_WM_ICONIC_STATE);
|
window_setstate(c->win, XCB_WM_ICONIC_STATE);
|
||||||
if(c->titlebar.position && c->titlebar_sw)
|
if(titlebar && titlebar->position && titlebar->sw)
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_unmap_window(globalconf.connection, titlebar->sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Give focus to client, or to first client if c is NULL
|
/** Give focus to client, or to first client if c is NULL
|
||||||
|
@ -254,7 +256,7 @@ client_focus(client_t *c, int screen)
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
/* save sel in focus history */
|
/* save sel in focus history */
|
||||||
focus_client_push(c);
|
focus_client_push(c);
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar_getbyclient(c));
|
||||||
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
||||||
c->win, XCB_CURRENT_TIME);
|
c->win, XCB_CURRENT_TIME);
|
||||||
/* since we're dropping EnterWindow events and sometimes the window
|
/* since we're dropping EnterWindow events and sometimes the window
|
||||||
|
@ -295,6 +297,7 @@ client_raise(client_t *c)
|
||||||
uint32_t config_win_vals[2];
|
uint32_t config_win_vals[2];
|
||||||
client_node_t *node;
|
client_node_t *node;
|
||||||
layer_t layer;
|
layer_t layer;
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
config_win_vals[0] = XCB_NONE;
|
config_win_vals[0] = XCB_NONE;
|
||||||
config_win_vals[1] = XCB_STACK_MODE_BELOW;
|
config_win_vals[1] = XCB_STACK_MODE_BELOW;
|
||||||
|
@ -306,13 +309,15 @@ client_raise(client_t *c)
|
||||||
if(node->client->layer == layer
|
if(node->client->layer == layer
|
||||||
&& client_isvisible_anyscreen(node->client))
|
&& client_isvisible_anyscreen(node->client))
|
||||||
{
|
{
|
||||||
if(node->client->titlebar.position && node->client->titlebar_sw)
|
if((titlebar = titlebar_getbyclient(node->client))
|
||||||
|
&& titlebar->position
|
||||||
|
&& titlebar->sw)
|
||||||
{
|
{
|
||||||
xcb_configure_window(globalconf.connection,
|
xcb_configure_window(globalconf.connection,
|
||||||
node->client->titlebar_sw->window,
|
titlebar->sw->window,
|
||||||
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
config_win_vals);
|
config_win_vals);
|
||||||
config_win_vals[0] = node->client->titlebar_sw->window;
|
config_win_vals[0] = titlebar->sw->window;
|
||||||
}
|
}
|
||||||
xcb_configure_window(globalconf.connection, node->client->win,
|
xcb_configure_window(globalconf.connection, node->client->win,
|
||||||
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
@ -484,11 +489,14 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
/* Values to configure a window is an array where values are
|
/* Values to configure a window is an array where values are
|
||||||
* stored according to 'value_mask' */
|
* stored according to 'value_mask' */
|
||||||
uint32_t values[5];
|
uint32_t values[5];
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
if(!c->ismoving && !c->isfloating && layout != layout_floating)
|
titlebar = titlebar_getbyclient(c);
|
||||||
|
|
||||||
|
if(titlebar && !c->ismoving && !c->isfloating && layout != layout_floating)
|
||||||
{
|
{
|
||||||
titlebar_update_geometry(c, geometry);
|
titlebar_update_geometry(titlebar, geometry);
|
||||||
geometry = titlebar_geometry_remove(&c->titlebar, geometry);
|
geometry = titlebar_geometry_remove(titlebar, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hints)
|
if(hints)
|
||||||
|
@ -527,7 +535,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
if(c->ismoving || c->isfloating
|
if(c->ismoving || c->isfloating
|
||||||
|| layout_get_current(new_screen) == layout_floating)
|
|| layout_get_current(new_screen) == layout_floating)
|
||||||
{
|
{
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(titlebar);
|
||||||
if(!c->ismax)
|
if(!c->ismax)
|
||||||
c->f_geometry = geometry;
|
c->f_geometry = geometry;
|
||||||
}
|
}
|
||||||
|
@ -548,7 +556,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
/* call it again like it was floating,
|
/* call it again like it was floating,
|
||||||
* we want it to be sticked to the window */
|
* we want it to be sticked to the window */
|
||||||
if(!c->ismoving && !c->isfloating && layout != layout_floating)
|
if(!c->ismoving && !c->isfloating && layout != layout_floating)
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(titlebar);
|
||||||
|
|
||||||
return resized;
|
return resized;
|
||||||
}
|
}
|
||||||
|
@ -619,16 +627,18 @@ client_saveprops(client_t *c)
|
||||||
void
|
void
|
||||||
client_unban(client_t *c)
|
client_unban(client_t *c)
|
||||||
{
|
{
|
||||||
|
titlebar_t *titlebar = titlebar_getbyclient(c);
|
||||||
xcb_map_window(globalconf.connection, c->win);
|
xcb_map_window(globalconf.connection, c->win);
|
||||||
window_setstate(c->win, XCB_WM_NORMAL_STATE);
|
window_setstate(c->win, XCB_WM_NORMAL_STATE);
|
||||||
if(c->titlebar_sw && c->titlebar.position != Off)
|
if(titlebar && titlebar->sw && titlebar->position != Off)
|
||||||
xcb_map_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_map_window(globalconf.connection, titlebar->sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_unmanage(client_t *c)
|
client_unmanage(client_t *c)
|
||||||
{
|
{
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
/* The server grab construct avoids race conditions. */
|
/* The server grab construct avoids race conditions. */
|
||||||
xcb_grab_server(globalconf.connection);
|
xcb_grab_server(globalconf.connection);
|
||||||
|
@ -653,7 +663,12 @@ client_unmanage(client_t *c)
|
||||||
xcb_aux_sync(globalconf.connection);
|
xcb_aux_sync(globalconf.connection);
|
||||||
xcb_ungrab_server(globalconf.connection);
|
xcb_ungrab_server(globalconf.connection);
|
||||||
|
|
||||||
simplewindow_delete(&c->titlebar_sw);
|
if((titlebar = titlebar_getbyclient(c)))
|
||||||
|
{
|
||||||
|
simplewindow_delete(&titlebar->sw);
|
||||||
|
titlebar_list_detach(&globalconf.titlebar, titlebar);
|
||||||
|
titlebar_unref(&titlebar);
|
||||||
|
}
|
||||||
|
|
||||||
p_delete(&c);
|
p_delete(&c);
|
||||||
}
|
}
|
||||||
|
@ -669,7 +684,7 @@ client_updatewmhints(client_t *c)
|
||||||
if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
|
if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
|
||||||
{
|
{
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar_getbyclient(c));
|
||||||
/* execute hook */
|
/* execute hook */
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
|
||||||
|
@ -909,24 +924,6 @@ luaA_client_border_set(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_client_titlebar_set(lua_State *L)
|
|
||||||
{
|
|
||||||
client_t **c = luaL_checkudata(L, 1, "client");
|
|
||||||
titlebar_t **t = luaL_checkudata(L, 2, "titlebar");
|
|
||||||
|
|
||||||
/* Copy titlebar info */
|
|
||||||
(*c)->titlebar = **t;
|
|
||||||
titlebar_init(*c);
|
|
||||||
|
|
||||||
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
|
||||||
titlebar_update_geometry_floating(*c);
|
|
||||||
else
|
|
||||||
globalconf.screens[(*c)->screen].need_arrange = true;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_client_screen_set(lua_State *L)
|
luaA_client_screen_set(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -1161,7 +1158,6 @@ const struct luaL_reg awesome_client_meta[] =
|
||||||
{
|
{
|
||||||
{ "name_get", luaA_client_name_get },
|
{ "name_get", luaA_client_name_get },
|
||||||
{ "name_set", luaA_client_name_set },
|
{ "name_set", luaA_client_name_set },
|
||||||
{ "titlebar_set", luaA_client_titlebar_set },
|
|
||||||
{ "screen_set", luaA_client_screen_set },
|
{ "screen_set", luaA_client_screen_set },
|
||||||
{ "screen_get", luaA_client_screen_get },
|
{ "screen_get", luaA_client_screen_get },
|
||||||
{ "border_set", luaA_client_border_set },
|
{ "border_set", luaA_client_border_set },
|
||||||
|
|
54
event.c
54
event.c
|
@ -81,6 +81,7 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
|
||||||
client_t *c;
|
client_t *c;
|
||||||
widget_node_t *w;
|
widget_node_t *w;
|
||||||
statusbar_t *statusbar;
|
statusbar_t *statusbar;
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
|
@ -122,14 +123,35 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for titlebar first */
|
if((titlebar = titlebar_getbywin(ev->event)))
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
{
|
||||||
if(c->titlebar_sw && c->titlebar_sw->window == ev->event)
|
/* Need to transform coordinates like it was
|
||||||
|
* top/bottom */
|
||||||
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
event_handle_mouse_button_press(c, ev->detail, ev->state,
|
case Right:
|
||||||
globalconf.buttons.titlebar);
|
tmp = ev->event_y;
|
||||||
return 0;
|
ev->event_y = titlebar->height - ev->event_x;
|
||||||
|
ev->event_x = tmp;
|
||||||
|
break;
|
||||||
|
case Left:
|
||||||
|
tmp = ev->event_y;
|
||||||
|
ev->event_y = ev->event_x;
|
||||||
|
ev->event_x = titlebar->width - tmp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
for(w = titlebar->widgets; w; w = w->next)
|
||||||
|
if(ev->event_x >= w->area.x && ev->event_x < w->area.x + w->area.width
|
||||||
|
&& ev->event_y >= w->area.y && ev->event_y < w->area.y + w->area.height)
|
||||||
|
{
|
||||||
|
w->widget->button_press(w, ev, titlebar->client->screen, titlebar);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* return if no widget match */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->event)))
|
if((c = client_get_bywin(globalconf.clients, ev->event)))
|
||||||
{
|
{
|
||||||
|
@ -188,7 +210,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(titlebar_getbyclient(c));
|
||||||
window_configure(c->win, geometry, c->border);
|
window_configure(c->win, geometry, c->border);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,16 +310,16 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *connection __attribute__ ((unused)),
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
xcb_enter_notify_event_t *ev)
|
xcb_enter_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c = NULL;
|
||||||
|
titlebar_t *t;
|
||||||
|
|
||||||
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
||||||
|| (ev->root_x == globalconf.pointer_x
|
|| (ev->root_x == globalconf.pointer_x
|
||||||
&& ev->root_y == globalconf.pointer_y))
|
&& ev->root_y == globalconf.pointer_y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
if((t = titlebar_getbywin(ev->event)))
|
||||||
if(c->titlebar_sw && c->titlebar_sw->window == ev->event)
|
c = t->client;
|
||||||
break;
|
|
||||||
|
|
||||||
if(c || (c = client_get_bywin(globalconf.clients, ev->event)))
|
if(c || (c = client_get_bywin(globalconf.clients, ev->event)))
|
||||||
{
|
{
|
||||||
|
@ -327,7 +349,7 @@ event_handle_expose(void *data __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
int screen;
|
int screen;
|
||||||
statusbar_t *statusbar;
|
statusbar_t *statusbar;
|
||||||
client_t *c;
|
titlebar_t *t;
|
||||||
|
|
||||||
if(!ev->count)
|
if(!ev->count)
|
||||||
{
|
{
|
||||||
|
@ -340,12 +362,8 @@ event_handle_expose(void *data __attribute__ ((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
if((t = titlebar_getbywin(ev->window)))
|
||||||
if(c->titlebar_sw && c->titlebar_sw->window == ev->window)
|
simplewindow_refresh_drawable(t->sw);
|
||||||
{
|
|
||||||
simplewindow_refresh_drawable(c->titlebar_sw);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
24
ewmh.c
24
ewmh.c
|
@ -253,6 +253,7 @@ static void
|
||||||
ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
{
|
{
|
||||||
const uint32_t raise_window_val = XCB_STACK_MODE_ABOVE;
|
const uint32_t raise_window_val = XCB_STACK_MODE_ABOVE;
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
if(state == net_wm_state_sticky)
|
if(state == net_wm_state_sticky)
|
||||||
{
|
{
|
||||||
|
@ -281,10 +282,11 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
/* restore geometry */
|
/* restore geometry */
|
||||||
geometry = c->m_geometry;
|
geometry = c->m_geometry;
|
||||||
/* restore borders and titlebar */
|
/* restore borders and titlebar */
|
||||||
if((c->titlebar.position = c->titlebar_oldposition))
|
if((titlebar = titlebar_getbyclient(c))
|
||||||
|
&& (titlebar->position = titlebar->oldposition))
|
||||||
{
|
{
|
||||||
c->titlebar.position = c->titlebar_oldposition;
|
titlebar->position = titlebar->oldposition;
|
||||||
xcb_map_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_map_window(globalconf.connection, titlebar->sw->window);
|
||||||
}
|
}
|
||||||
c->noborder = false;
|
c->noborder = false;
|
||||||
c->ismax = false;
|
c->ismax = false;
|
||||||
|
@ -298,10 +300,11 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
c->m_geometry = c->geometry;
|
c->m_geometry = c->geometry;
|
||||||
c->wasfloating = c->isfloating;
|
c->wasfloating = c->isfloating;
|
||||||
/* disable titlebar and borders */
|
/* disable titlebar and borders */
|
||||||
if((c->titlebar_oldposition = c->titlebar.position))
|
if((titlebar = titlebar_getbyclient(c))
|
||||||
|
&& (titlebar->oldposition = titlebar->position))
|
||||||
{
|
{
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_unmap_window(globalconf.connection, titlebar->sw->window);
|
||||||
c->titlebar.position = Off;
|
titlebar->position = Off;
|
||||||
}
|
}
|
||||||
c->ismax = true;
|
c->ismax = true;
|
||||||
c->oldborder = c->border;
|
c->oldborder = c->border;
|
||||||
|
@ -343,6 +346,8 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
static void
|
static void
|
||||||
ewmh_process_window_type_atom(client_t *c, xcb_atom_t state)
|
ewmh_process_window_type_atom(client_t *c, xcb_atom_t state)
|
||||||
{
|
{
|
||||||
|
titlebar_t *titlebar;
|
||||||
|
|
||||||
if(state == net_wm_window_type_normal)
|
if(state == net_wm_window_type_normal)
|
||||||
{
|
{
|
||||||
/* do nothing. this is REALLY IMPORTANT */
|
/* do nothing. this is REALLY IMPORTANT */
|
||||||
|
@ -352,10 +357,11 @@ ewmh_process_window_type_atom(client_t *c, xcb_atom_t state)
|
||||||
{
|
{
|
||||||
c->skip = true;
|
c->skip = true;
|
||||||
c->isfixed = true;
|
c->isfixed = true;
|
||||||
if(c->titlebar.position)
|
if((titlebar = titlebar_getbyclient(c))
|
||||||
|
&& titlebar->position && titlebar->sw)
|
||||||
{
|
{
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_unmap_window(globalconf.connection, titlebar->sw->window);
|
||||||
c->titlebar.position = Off;
|
titlebar->position = Off;
|
||||||
}
|
}
|
||||||
client_setborder(c, 0);
|
client_setborder(c, 0);
|
||||||
c->noborder = true;
|
c->noborder = true;
|
||||||
|
|
7
mouse.c
7
mouse.c
|
@ -97,13 +97,14 @@ static area_t
|
||||||
mouse_snapclient(client_t *c, area_t geometry, int snap)
|
mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
{
|
{
|
||||||
client_t *snapper;
|
client_t *snapper;
|
||||||
|
titlebar_t *t = titlebar_getbyclient(c);
|
||||||
area_t snapper_geometry;
|
area_t snapper_geometry;
|
||||||
area_t screen_geometry =
|
area_t screen_geometry =
|
||||||
screen_get_area(c->screen,
|
screen_get_area(c->screen,
|
||||||
globalconf.screens[c->screen].statusbar,
|
globalconf.screens[c->screen].statusbar,
|
||||||
&globalconf.screens[c->screen].padding);
|
&globalconf.screens[c->screen].padding);
|
||||||
|
|
||||||
geometry = titlebar_geometry_add(&c->titlebar, geometry);
|
geometry = titlebar_geometry_add(t, geometry);
|
||||||
geometry.width += 2 * c->border;
|
geometry.width += 2 * c->border;
|
||||||
geometry.height += 2 * c->border;
|
geometry.height += 2 * c->border;
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
snapper_geometry = snapper->geometry;
|
snapper_geometry = snapper->geometry;
|
||||||
snapper_geometry.width += 2 * c->border;
|
snapper_geometry.width += 2 * c->border;
|
||||||
snapper_geometry.height += 2 * c->border;
|
snapper_geometry.height += 2 * c->border;
|
||||||
snapper_geometry = titlebar_geometry_add(&snapper->titlebar, snapper_geometry);
|
snapper_geometry = titlebar_geometry_add(t, snapper_geometry);
|
||||||
geometry =
|
geometry =
|
||||||
mouse_snapclienttogeometry_outside(geometry,
|
mouse_snapclienttogeometry_outside(geometry,
|
||||||
snapper_geometry,
|
snapper_geometry,
|
||||||
|
@ -125,7 +126,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
|
|
||||||
geometry.width -= 2 * c->border;
|
geometry.width -= 2 * c->border;
|
||||||
geometry.height -= 2 * c->border;
|
geometry.height -= 2 * c->border;
|
||||||
return titlebar_geometry_remove(&c->titlebar, geometry);
|
return titlebar_geometry_remove(t, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Redraw the resizebar.
|
/** Redraw the resizebar.
|
||||||
|
|
12
placement.c
12
placement.c
|
@ -73,6 +73,7 @@ placement_smart(client_t *c)
|
||||||
area_t *screen_geometry, *arealist = NULL, *r;
|
area_t *screen_geometry, *arealist = NULL, *r;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
layout_t *layout;
|
layout_t *layout;
|
||||||
|
titlebar_t *titlebar = titlebar_getbyclient(c);
|
||||||
|
|
||||||
screen_geometry = p_new(area_t, 1);
|
screen_geometry = p_new(area_t, 1);
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ placement_smart(client_t *c)
|
||||||
newgeometry = client->f_geometry;
|
newgeometry = client->f_geometry;
|
||||||
newgeometry.width += 2 * client->border;
|
newgeometry.width += 2 * client->border;
|
||||||
newgeometry.height += 2 * client->border;
|
newgeometry.height += 2 * client->border;
|
||||||
newgeometry = titlebar_geometry_add(&client->titlebar, newgeometry);
|
newgeometry = titlebar_geometry_add(titlebar, newgeometry);
|
||||||
area_list_remove(&arealist, &newgeometry);
|
area_list_remove(&arealist, &newgeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,9 +120,9 @@ placement_smart(client_t *c)
|
||||||
newgeometry.width = c->f_geometry.width;
|
newgeometry.width = c->f_geometry.width;
|
||||||
newgeometry.height = c->f_geometry.height;
|
newgeometry.height = c->f_geometry.height;
|
||||||
|
|
||||||
newgeometry = titlebar_geometry_add(&c->titlebar, newgeometry);
|
newgeometry = titlebar_geometry_add(titlebar, newgeometry);
|
||||||
newgeometry = placement_fix_offscreen(newgeometry, c->screen, c->border);
|
newgeometry = placement_fix_offscreen(newgeometry, c->screen, c->border);
|
||||||
newgeometry = titlebar_geometry_remove(&c->titlebar, newgeometry);
|
newgeometry = titlebar_geometry_remove(titlebar, newgeometry);
|
||||||
|
|
||||||
area_list_wipe(&arealist);
|
area_list_wipe(&arealist);
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ placement_under_mouse(client_t *c)
|
||||||
xcb_query_pointer_cookie_t qp_c;
|
xcb_query_pointer_cookie_t qp_c;
|
||||||
xcb_query_pointer_reply_t *qp_r;
|
xcb_query_pointer_reply_t *qp_r;
|
||||||
area_t finalgeometry = c->f_geometry;
|
area_t finalgeometry = c->f_geometry;
|
||||||
|
titlebar_t *titlebar = titlebar_getbyclient(c);
|
||||||
|
|
||||||
qp_c = xcb_query_pointer(globalconf.connection,
|
qp_c = xcb_query_pointer(globalconf.connection,
|
||||||
xcb_aux_get_screen(globalconf.connection, c->phys_screen)->root);
|
xcb_aux_get_screen(globalconf.connection, c->phys_screen)->root);
|
||||||
|
@ -145,9 +147,9 @@ placement_under_mouse(client_t *c)
|
||||||
p_delete(&qp_r);
|
p_delete(&qp_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalgeometry = titlebar_geometry_add(&c->titlebar, finalgeometry);
|
finalgeometry = titlebar_geometry_add(titlebar, finalgeometry);
|
||||||
finalgeometry = placement_fix_offscreen(finalgeometry, c->screen, c->border);
|
finalgeometry = placement_fix_offscreen(finalgeometry, c->screen, c->border);
|
||||||
finalgeometry = titlebar_geometry_remove(&c->titlebar, finalgeometry);
|
finalgeometry = titlebar_geometry_remove(titlebar, finalgeometry);
|
||||||
|
|
||||||
return finalgeometry;
|
return finalgeometry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ statusbar_draw(statusbar_t *statusbar)
|
||||||
if(!statusbar->position)
|
if(!statusbar->position)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
widget_render(statusbar->widgets, statusbar->ctx, statusbar->sw->drawable,
|
widget_render(statusbar->widgets, statusbar->ctx, statusbar->sw->gc,
|
||||||
|
statusbar->sw->drawable,
|
||||||
statusbar->screen, statusbar->position,
|
statusbar->screen, statusbar->position,
|
||||||
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
|
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
|
||||||
statusbar);
|
statusbar);
|
||||||
|
|
181
structs.h
181
structs.h
|
@ -47,58 +47,32 @@ typedef enum
|
||||||
enum
|
enum
|
||||||
{ CurNormal, CurResize, CurMove, CurLast };
|
{ CurNormal, CurResize, CurMove, CurLast };
|
||||||
|
|
||||||
/** Titlebar template structure */
|
typedef struct button_t button_t;
|
||||||
typedef struct
|
typedef struct widget_t widget_t;
|
||||||
{
|
typedef struct widget_node_t widget_node_t;
|
||||||
/** Ref count */
|
typedef struct statusbar_t statusbar_t;
|
||||||
int refcount;
|
typedef struct client_t client_t;
|
||||||
/** Position */
|
typedef struct titlebar_t titlebar_t;
|
||||||
position_t position;
|
|
||||||
/** Alignment on window */
|
|
||||||
alignment_t align;
|
|
||||||
/** Width and height */
|
|
||||||
int width, height;
|
|
||||||
/** Various text used for rendering */
|
|
||||||
char *text_normal, *text_focus, *text_urgent;
|
|
||||||
} titlebar_t;
|
|
||||||
|
|
||||||
/** Delete a titlebar structure.
|
|
||||||
* \param t The titlebar to destroy.
|
|
||||||
*/
|
|
||||||
static inline void
|
|
||||||
titlebar_delete(titlebar_t **t)
|
|
||||||
{
|
|
||||||
p_delete(&(*t)->text_normal);
|
|
||||||
p_delete(&(*t)->text_focus);
|
|
||||||
p_delete(&(*t)->text_urgent);
|
|
||||||
p_delete(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
DO_RCNT(titlebar_t, titlebar, titlebar_delete)
|
|
||||||
|
|
||||||
/** Keys bindings */
|
|
||||||
typedef struct keybinding_t keybinding_t;
|
typedef struct keybinding_t keybinding_t;
|
||||||
struct keybinding_t
|
typedef struct client_node_t client_node_t;
|
||||||
{
|
typedef struct _tag_t tag_t;
|
||||||
/** Ref count */
|
typedef struct tag_client_node_t tag_client_node_t;
|
||||||
int refcount;
|
typedef area_t (FloatingPlacement)(client_t *);
|
||||||
/** Key modifier */
|
typedef struct awesome_t awesome_t;
|
||||||
unsigned long mod;
|
|
||||||
/** Keysym */
|
|
||||||
xcb_keysym_t keysym;
|
|
||||||
/** Keycode */
|
|
||||||
xcb_keycode_t keycode;
|
|
||||||
/** Lua function to execute. */
|
|
||||||
luaA_function fct;
|
|
||||||
/** Next and previous keys */
|
|
||||||
keybinding_t *prev, *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
DO_SLIST(keybinding_t, keybinding, p_delete)
|
/** Widget tell status code */
|
||||||
DO_RCNT(keybinding_t, keybinding, p_delete)
|
typedef enum
|
||||||
|
{
|
||||||
|
WIDGET_NOERROR = 0,
|
||||||
|
WIDGET_ERROR,
|
||||||
|
WIDGET_ERROR_NOVALUE,
|
||||||
|
WIDGET_ERROR_CUSTOM,
|
||||||
|
WIDGET_ERROR_FORMAT_FONT,
|
||||||
|
WIDGET_ERROR_FORMAT_COLOR,
|
||||||
|
WIDGET_ERROR_FORMAT_SECTION
|
||||||
|
} widget_tell_status_t;
|
||||||
|
|
||||||
/** Mouse buttons bindings */
|
/** Mouse buttons bindings */
|
||||||
typedef struct button_t button_t;
|
|
||||||
struct button_t
|
struct button_t
|
||||||
{
|
{
|
||||||
/** Key modifiers */
|
/** Key modifiers */
|
||||||
|
@ -113,22 +87,7 @@ struct button_t
|
||||||
|
|
||||||
DO_SLIST(button_t, button, p_delete)
|
DO_SLIST(button_t, button, p_delete)
|
||||||
|
|
||||||
/** Widget tell status code */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
WIDGET_NOERROR = 0,
|
|
||||||
WIDGET_ERROR,
|
|
||||||
WIDGET_ERROR_NOVALUE,
|
|
||||||
WIDGET_ERROR_CUSTOM,
|
|
||||||
WIDGET_ERROR_FORMAT_FONT,
|
|
||||||
WIDGET_ERROR_FORMAT_COLOR,
|
|
||||||
WIDGET_ERROR_FORMAT_SECTION
|
|
||||||
} widget_tell_status_t;
|
|
||||||
|
|
||||||
/** Widget */
|
/** Widget */
|
||||||
typedef struct widget_t widget_t;
|
|
||||||
typedef struct widget_node_t widget_node_t;
|
|
||||||
typedef struct statusbar_t statusbar_t;
|
|
||||||
struct widget_t
|
struct widget_t
|
||||||
{
|
{
|
||||||
/** Ref count */
|
/** Ref count */
|
||||||
|
@ -153,16 +112,6 @@ struct widget_t
|
||||||
bool isvisible;
|
bool isvisible;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct widget_node_t
|
|
||||||
{
|
|
||||||
/** The widget */
|
|
||||||
widget_t *widget;
|
|
||||||
/** The area where the widget was drawn */
|
|
||||||
area_t area;
|
|
||||||
/** Next and previous widget in the list */
|
|
||||||
widget_node_t *prev, *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Delete a widget structure.
|
/** Delete a widget structure.
|
||||||
* \param widget The widget to destroy.
|
* \param widget The widget to destroy.
|
||||||
*/
|
*/
|
||||||
|
@ -177,6 +126,16 @@ widget_delete(widget_t **widget)
|
||||||
|
|
||||||
DO_RCNT(widget_t, widget, widget_delete)
|
DO_RCNT(widget_t, widget, widget_delete)
|
||||||
|
|
||||||
|
struct widget_node_t
|
||||||
|
{
|
||||||
|
/** The widget */
|
||||||
|
widget_t *widget;
|
||||||
|
/** The area where the widget was drawn */
|
||||||
|
area_t area;
|
||||||
|
/** Next and previous widget in the list */
|
||||||
|
widget_node_t *prev, *next;
|
||||||
|
};
|
||||||
|
|
||||||
/** Delete a widget node structure.
|
/** Delete a widget node structure.
|
||||||
* \param node The node to destroy.
|
* \param node The node to destroy.
|
||||||
*/
|
*/
|
||||||
|
@ -189,6 +148,65 @@ widget_node_delete(widget_node_t **node)
|
||||||
|
|
||||||
DO_SLIST(widget_node_t, widget_node, widget_node_delete)
|
DO_SLIST(widget_node_t, widget_node, widget_node_delete)
|
||||||
|
|
||||||
|
/** Titlebar template structure */
|
||||||
|
struct titlebar_t
|
||||||
|
{
|
||||||
|
/** Ref count */
|
||||||
|
int refcount;
|
||||||
|
/** Attached client */
|
||||||
|
client_t *client;
|
||||||
|
/** Position */
|
||||||
|
position_t position, oldposition;
|
||||||
|
/** Alignment on window */
|
||||||
|
alignment_t align;
|
||||||
|
/** Widgets */
|
||||||
|
widget_node_t *widgets;
|
||||||
|
/** Width and height */
|
||||||
|
int width, height;
|
||||||
|
/** Titlebar window */
|
||||||
|
simple_window_t *sw;
|
||||||
|
/** Default colors */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
xcolor_t fg, bg;
|
||||||
|
} colors;
|
||||||
|
/** Next and previous in list */
|
||||||
|
titlebar_t *prev, *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Delete a titlebar structure.
|
||||||
|
* \param t The titlebar to destroy.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
titlebar_delete(titlebar_t **t)
|
||||||
|
{
|
||||||
|
widget_node_list_wipe(&(*t)->widgets);
|
||||||
|
p_delete(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
DO_SLIST(titlebar_t, titlebar, titlebar_delete)
|
||||||
|
DO_RCNT(titlebar_t, titlebar, titlebar_delete)
|
||||||
|
|
||||||
|
/** Keys bindings */
|
||||||
|
struct keybinding_t
|
||||||
|
{
|
||||||
|
/** Ref count */
|
||||||
|
int refcount;
|
||||||
|
/** Key modifier */
|
||||||
|
unsigned long mod;
|
||||||
|
/** Keysym */
|
||||||
|
xcb_keysym_t keysym;
|
||||||
|
/** Keycode */
|
||||||
|
xcb_keycode_t keycode;
|
||||||
|
/** Lua function to execute. */
|
||||||
|
luaA_function fct;
|
||||||
|
/** Next and previous keys */
|
||||||
|
keybinding_t *prev, *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
DO_SLIST(keybinding_t, keybinding, p_delete)
|
||||||
|
DO_RCNT(keybinding_t, keybinding, p_delete)
|
||||||
|
|
||||||
/** Status bar */
|
/** Status bar */
|
||||||
struct statusbar_t
|
struct statusbar_t
|
||||||
{
|
{
|
||||||
|
@ -228,7 +246,6 @@ struct statusbar_t
|
||||||
};
|
};
|
||||||
|
|
||||||
/** client_t type */
|
/** client_t type */
|
||||||
typedef struct client_t client_t;
|
|
||||||
struct client_t
|
struct client_t
|
||||||
{
|
{
|
||||||
/** Client name */
|
/** Client name */
|
||||||
|
@ -268,19 +285,12 @@ struct client_t
|
||||||
int screen;
|
int screen;
|
||||||
/** Client physical screen */
|
/** Client physical screen */
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
/** Titlebar */
|
|
||||||
titlebar_t titlebar;
|
|
||||||
/** Titlebar window */
|
|
||||||
simple_window_t *titlebar_sw;
|
|
||||||
/** Old position */
|
|
||||||
position_t titlebar_oldposition;
|
|
||||||
/** Layer in the stacking order */
|
/** Layer in the stacking order */
|
||||||
layer_t layer, oldlayer;
|
layer_t layer, oldlayer;
|
||||||
/** Path to an icon */
|
/** Path to an icon */
|
||||||
char *icon_path;
|
char *icon_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct client_node_t client_node_t;
|
|
||||||
struct client_node_t
|
struct client_node_t
|
||||||
{
|
{
|
||||||
/** The client */
|
/** The client */
|
||||||
|
@ -290,7 +300,6 @@ struct client_node_t
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Tag type */
|
/** Tag type */
|
||||||
typedef struct _tag_t tag_t;
|
|
||||||
struct _tag_t
|
struct _tag_t
|
||||||
{
|
{
|
||||||
/** Ref count */
|
/** Ref count */
|
||||||
|
@ -314,7 +323,6 @@ struct _tag_t
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Tag client link type */
|
/** Tag client link type */
|
||||||
typedef struct tag_client_node_t tag_client_node_t;
|
|
||||||
struct tag_client_node_t
|
struct tag_client_node_t
|
||||||
{
|
{
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
|
@ -336,8 +344,6 @@ typedef struct
|
||||||
int right;
|
int right;
|
||||||
} Padding;
|
} Padding;
|
||||||
|
|
||||||
typedef area_t (FloatingPlacement)(client_t *);
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** true if we need to arrange() */
|
/** true if we need to arrange() */
|
||||||
|
@ -351,7 +357,6 @@ typedef struct
|
||||||
} screen_t;
|
} screen_t;
|
||||||
|
|
||||||
/** Main configuration structure */
|
/** Main configuration structure */
|
||||||
typedef struct awesome_t awesome_t;
|
|
||||||
struct awesome_t
|
struct awesome_t
|
||||||
{
|
{
|
||||||
/** Connection ref */
|
/** Connection ref */
|
||||||
|
@ -387,8 +392,10 @@ struct awesome_t
|
||||||
bool have_randr;
|
bool have_randr;
|
||||||
/** Cursors */
|
/** Cursors */
|
||||||
xcb_cursor_t cursor[CurLast];
|
xcb_cursor_t cursor[CurLast];
|
||||||
/** client_ts list */
|
/** Clients list */
|
||||||
client_t *clients;
|
client_t *clients;
|
||||||
|
/** Titlebar list */
|
||||||
|
titlebar_t *titlebar;
|
||||||
/** Path to config file */
|
/** Path to config file */
|
||||||
char *configpath;
|
char *configpath;
|
||||||
/** Floating window placement algo */
|
/** Floating window placement algo */
|
||||||
|
|
406
titlebar.c
406
titlebar.c
|
@ -27,51 +27,63 @@
|
||||||
#include "titlebar.h"
|
#include "titlebar.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "widget.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
||||||
static char *
|
/** Get a titlebar for a client
|
||||||
titlebar_text(client_t *c)
|
* \param c The client.
|
||||||
|
* \return A titlebar.
|
||||||
|
*/
|
||||||
|
titlebar_t *
|
||||||
|
titlebar_getbyclient(client_t *c)
|
||||||
{
|
{
|
||||||
char *text;
|
titlebar_t *t;
|
||||||
|
|
||||||
if(globalconf.focus->client == c)
|
for(t = globalconf.titlebar; t; t = t->next)
|
||||||
text = c->titlebar.text_focus;
|
if(t->client == c)
|
||||||
else if(c->isurgent)
|
return t;
|
||||||
text = c->titlebar.text_urgent;
|
|
||||||
else
|
|
||||||
text = c->titlebar.text_normal;
|
|
||||||
|
|
||||||
return client_markup_parse(c, text, a_strlen(text));
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline area_t
|
/** Get a titlebar which own a window.
|
||||||
titlebar_size(client_t *c)
|
* \param The window.
|
||||||
|
* \return A titlebar.
|
||||||
|
*/
|
||||||
|
titlebar_t *
|
||||||
|
titlebar_getbywin(xcb_window_t win)
|
||||||
{
|
{
|
||||||
return draw_text_extents(globalconf.connection, globalconf.default_screen,
|
titlebar_t *t;
|
||||||
globalconf.font, titlebar_text(c));
|
|
||||||
|
for(t = globalconf.titlebar; t; t = t->next)
|
||||||
|
if(t->sw && t->sw->window == win)
|
||||||
|
return t;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draw the titlebar content.
|
/** Draw the titlebar content.
|
||||||
* \param c the client
|
* \param c the client
|
||||||
|
* \todo stop duplicating the context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
titlebar_draw(client_t *c)
|
titlebar_draw(titlebar_t *titlebar)
|
||||||
{
|
{
|
||||||
xcb_drawable_t dw = 0;
|
xcb_drawable_t dw = 0;
|
||||||
draw_context_t *ctx;
|
draw_context_t *ctx;
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
xcb_screen_t *s;
|
xcb_screen_t *s;
|
||||||
char *text;
|
|
||||||
|
|
||||||
if(!c->titlebar_sw)
|
if(!titlebar || !titlebar->sw || !titlebar->position)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s = xcb_aux_get_screen(globalconf.connection,
|
s = xcb_aux_get_screen(globalconf.connection,
|
||||||
c->titlebar_sw->phys_screen);
|
titlebar->sw->phys_screen);
|
||||||
|
|
||||||
switch(c->titlebar.position)
|
/** \todo move this in init */
|
||||||
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
case Off:
|
case Off:
|
||||||
return;
|
return;
|
||||||
|
@ -81,54 +93,52 @@ titlebar_draw(client_t *c)
|
||||||
xcb_create_pixmap(globalconf.connection, s->root_depth,
|
xcb_create_pixmap(globalconf.connection, s->root_depth,
|
||||||
dw,
|
dw,
|
||||||
s->root,
|
s->root,
|
||||||
c->titlebar_sw->geometry.height,
|
titlebar->sw->geometry.height,
|
||||||
c->titlebar_sw->geometry.width);
|
titlebar->sw->geometry.width);
|
||||||
ctx = draw_context_new(globalconf.connection, c->titlebar_sw->phys_screen,
|
ctx = draw_context_new(globalconf.connection, titlebar->sw->phys_screen,
|
||||||
c->titlebar_sw->geometry.height,
|
titlebar->sw->geometry.height,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
dw,
|
dw,
|
||||||
globalconf.colors.fg,
|
titlebar->colors.fg,
|
||||||
globalconf.colors.bg);
|
titlebar->colors.bg);
|
||||||
geometry.width = c->titlebar_sw->geometry.height;
|
geometry.width = titlebar->sw->geometry.height;
|
||||||
geometry.height = c->titlebar_sw->geometry.width;
|
geometry.height = titlebar->sw->geometry.width;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ctx = draw_context_new(globalconf.connection, c->titlebar_sw->phys_screen,
|
ctx = draw_context_new(globalconf.connection, titlebar->sw->phys_screen,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
c->titlebar_sw->geometry.height,
|
titlebar->sw->geometry.height,
|
||||||
c->titlebar_sw->drawable,
|
titlebar->sw->drawable,
|
||||||
globalconf.colors.fg,
|
titlebar->colors.fg,
|
||||||
globalconf.colors.bg);
|
titlebar->colors.bg);
|
||||||
geometry = c->titlebar_sw->geometry;
|
geometry = titlebar->sw->geometry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = titlebar_text(c);
|
widget_render(titlebar->widgets, ctx, titlebar->sw->gc, titlebar->sw->drawable,
|
||||||
geometry.x = geometry.y = 0;
|
titlebar->client->screen, titlebar->position,
|
||||||
draw_rectangle(ctx, geometry, 1.0, true, globalconf.colors.bg);
|
titlebar->sw->geometry.x, titlebar->sw->geometry.y, titlebar);
|
||||||
draw_text(ctx, globalconf.font, geometry, text);
|
|
||||||
p_delete(&text);
|
|
||||||
|
|
||||||
switch(c->titlebar.position)
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
case Left:
|
case Left:
|
||||||
draw_rotate(ctx, ctx->drawable, c->titlebar_sw->drawable,
|
draw_rotate(ctx, ctx->drawable, titlebar->sw->drawable,
|
||||||
ctx->width, ctx->height,
|
ctx->width, ctx->height,
|
||||||
ctx->height, ctx->width,
|
ctx->height, ctx->width,
|
||||||
- M_PI_2, 0, c->titlebar_sw->geometry.height);
|
- M_PI_2, 0, titlebar->sw->geometry.height);
|
||||||
xcb_free_pixmap(globalconf.connection, dw);
|
xcb_free_pixmap(globalconf.connection, dw);
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
draw_rotate(ctx, ctx->drawable, c->titlebar_sw->drawable,
|
draw_rotate(ctx, ctx->drawable, titlebar->sw->drawable,
|
||||||
ctx->width, ctx->height,
|
ctx->width, ctx->height,
|
||||||
ctx->height, ctx->width,
|
ctx->height, ctx->width,
|
||||||
M_PI_2, c->titlebar_sw->geometry.width, 0);
|
M_PI_2, titlebar->sw->geometry.width, 0);
|
||||||
xcb_free_pixmap(globalconf.connection, dw);
|
xcb_free_pixmap(globalconf.connection, dw);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
simplewindow_refresh_drawable(c->titlebar_sw);
|
simplewindow_refresh_drawable(titlebar->sw);
|
||||||
|
|
||||||
draw_context_delete(&ctx);
|
draw_context_delete(&ctx);
|
||||||
}
|
}
|
||||||
|
@ -137,110 +147,109 @@ titlebar_draw(client_t *c)
|
||||||
* \param c the client
|
* \param c the client
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
titlebar_update_geometry_floating(client_t *c)
|
titlebar_update_geometry_floating(titlebar_t *titlebar)
|
||||||
{
|
{
|
||||||
int width, x_offset = 0, y_offset = 0;
|
int width, x_offset = 0, y_offset = 0;
|
||||||
|
|
||||||
if(!c->titlebar_sw)
|
if(!titlebar || !titlebar->sw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(c->titlebar.position)
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case Off:
|
case Off:
|
||||||
return;
|
return;
|
||||||
case Top:
|
case Top:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = c->geometry.width + 2 * c->border;
|
width = MIN(titlebar->width, titlebar->client->geometry.width);
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.width);
|
width = titlebar->client->geometry.width + 2 * titlebar->client->border;
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
x_offset = 2 * c->border + c->geometry.width - width;
|
x_offset = 2 * titlebar->client->border + titlebar->client->geometry.width - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
x_offset = (c->geometry.width - width) / 2;
|
x_offset = (titlebar->client->geometry.width - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
c->geometry.x + x_offset,
|
titlebar->client->geometry.x + x_offset,
|
||||||
c->geometry.y - c->titlebar_sw->geometry.height,
|
titlebar->client->geometry.y - titlebar->sw->geometry.height,
|
||||||
width,
|
width,
|
||||||
c->titlebar_sw->geometry.height);
|
titlebar->sw->geometry.height);
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = c->geometry.width + 2 * c->border;
|
width = MIN(titlebar->width, titlebar->client->geometry.width);
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.width);
|
width = titlebar->client->geometry.width + 2 * titlebar->client->border;
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
x_offset = 2 * c->border + c->geometry.width - width;
|
x_offset = 2 * titlebar->client->border + titlebar->client->geometry.width - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
x_offset = (c->geometry.width - width) / 2;
|
x_offset = (titlebar->client->geometry.width - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
c->geometry.x + x_offset,
|
titlebar->client->geometry.x + x_offset,
|
||||||
c->geometry.y + c->geometry.height + 2 * c->border,
|
titlebar->client->geometry.y + titlebar->client->geometry.height + 2 * titlebar->client->border,
|
||||||
width,
|
width,
|
||||||
c->titlebar_sw->geometry.height);
|
titlebar->sw->geometry.height);
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = c->geometry.height + 2 * c->border;
|
width = MIN(titlebar->width, titlebar->client->geometry.height);
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.height);
|
width = titlebar->client->geometry.height + 2 * titlebar->client->border;
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
y_offset = 2 * c->border + c->geometry.height - width;
|
y_offset = 2 * titlebar->client->border + titlebar->client->geometry.height - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
y_offset = (c->geometry.height - width) / 2;
|
y_offset = (titlebar->client->geometry.height - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
c->geometry.x - c->titlebar_sw->geometry.width,
|
titlebar->client->geometry.x - titlebar->sw->geometry.width,
|
||||||
c->geometry.y + y_offset,
|
titlebar->client->geometry.y + y_offset,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
width);
|
width);
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = c->geometry.height + 2 * c->border;
|
width = MIN(titlebar->width, titlebar->client->geometry.height);
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.height);
|
width = titlebar->client->geometry.height + 2 * titlebar->client->border;
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
y_offset = 2 * c->border + c->geometry.height - width;
|
y_offset = 2 * titlebar->client->border + titlebar->client->geometry.height - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
y_offset = (c->geometry.height - width) / 2;
|
y_offset = (titlebar->client->geometry.height - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
c->geometry.x + c->geometry.width + 2 * c->border,
|
titlebar->client->geometry.x + titlebar->client->geometry.width + 2 * titlebar->client->border,
|
||||||
c->geometry.y + y_offset,
|
titlebar->client->geometry.y + y_offset,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
width);
|
width);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
titlebar_draw(titlebar);
|
||||||
titlebar_draw(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,112 +258,112 @@ titlebar_update_geometry_floating(client_t *c)
|
||||||
* \param geometry the geometry the client will receive
|
* \param geometry the geometry the client will receive
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
titlebar_update_geometry(client_t *c, area_t geometry)
|
titlebar_update_geometry(titlebar_t *titlebar, area_t geometry)
|
||||||
{
|
{
|
||||||
int width, x_offset = 0 , y_offset = 0;
|
int width, x_offset = 0 , y_offset = 0;
|
||||||
|
|
||||||
if(!c->titlebar_sw)
|
if(!titlebar || !titlebar->sw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(c->titlebar.position)
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case Off:
|
case Off:
|
||||||
return;
|
return;
|
||||||
case Top:
|
case Top:
|
||||||
if(!c->titlebar.width)
|
if(!titlebar->width)
|
||||||
width = geometry.width + 2 * c->border;
|
width = geometry.width + 2 * titlebar->client->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, geometry.width);
|
width = MIN(titlebar->width, geometry.width);
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
x_offset = 2 * c->border + geometry.width - width;
|
x_offset = 2 * titlebar->client->border + geometry.width - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
x_offset = (geometry.width - width) / 2;
|
x_offset = (geometry.width - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
geometry.x + x_offset,
|
geometry.x + x_offset,
|
||||||
geometry.y,
|
geometry.y,
|
||||||
width,
|
width,
|
||||||
c->titlebar_sw->geometry.height);
|
titlebar->sw->geometry.height);
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = geometry.width + 2 * c->border;
|
width = geometry.width + 2 * titlebar->client->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, geometry.width);
|
width = MIN(titlebar->width, geometry.width);
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
x_offset = 2 * c->border + geometry.width - width;
|
x_offset = 2 * titlebar->client->border + geometry.width - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
x_offset = (geometry.width - width) / 2;
|
x_offset = (geometry.width - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
geometry.x + x_offset,
|
geometry.x + x_offset,
|
||||||
geometry.y + geometry.height
|
geometry.y + geometry.height
|
||||||
- c->titlebar_sw->geometry.height + 2 * c->border,
|
- titlebar->sw->geometry.height + 2 * titlebar->client->border,
|
||||||
width,
|
width,
|
||||||
c->titlebar_sw->geometry.height);
|
titlebar->sw->geometry.height);
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
if(!c->titlebar.width)
|
if(!titlebar->width)
|
||||||
width = geometry.height + 2 * c->border;
|
width = geometry.height + 2 * titlebar->client->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, geometry.height);
|
width = MIN(titlebar->width, geometry.height);
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
y_offset = 2 * c->border + geometry.height - width;
|
y_offset = 2 * titlebar->client->border + geometry.height - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
y_offset = (geometry.height - width) / 2;
|
y_offset = (geometry.height - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
geometry.x,
|
geometry.x,
|
||||||
geometry.y + y_offset,
|
geometry.y + y_offset,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
width);
|
width);
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = geometry.height + 2 * c->border;
|
width = geometry.height + 2 * titlebar->client->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, geometry.height);
|
width = MIN(titlebar->width, geometry.height);
|
||||||
switch(c->titlebar.align)
|
switch(titlebar->align)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
y_offset = 2 * c->border + geometry.height - width;
|
y_offset = 2 * titlebar->client->border + geometry.height - width;
|
||||||
break;
|
break;
|
||||||
case AlignCenter:
|
case AlignCenter:
|
||||||
y_offset = (geometry.height - width) / 2;
|
y_offset = (geometry.height - width) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_move_resize(c->titlebar_sw,
|
simplewindow_move_resize(titlebar->sw,
|
||||||
geometry.x + geometry.width
|
geometry.x + geometry.width
|
||||||
- c->titlebar_sw->geometry.width + 2 * c->border,
|
- titlebar->sw->geometry.width + 2 * titlebar->client->border,
|
||||||
geometry.y + y_offset,
|
geometry.y + y_offset,
|
||||||
c->titlebar_sw->geometry.width,
|
titlebar->sw->geometry.width,
|
||||||
width);
|
width);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set client titlebar position.
|
/** Set client titlebar position.
|
||||||
|
@ -362,57 +371,55 @@ titlebar_update_geometry(client_t *c, area_t geometry)
|
||||||
* \param p The position.
|
* \param p The position.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
titlebar_init(client_t *c)
|
titlebar_init(titlebar_t *titlebar)
|
||||||
{
|
{
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
|
|
||||||
if(!c->titlebar.height)
|
switch(titlebar->position)
|
||||||
c->titlebar.height = draw_text_extents(globalconf.connection, globalconf.default_screen,
|
|
||||||
globalconf.font,
|
|
||||||
client_markup_parse(c,
|
|
||||||
c->titlebar.text_focus,
|
|
||||||
a_strlen(c->titlebar.text_focus))).height;
|
|
||||||
switch(c->titlebar.position)
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
c->titlebar.position = Off;
|
titlebar->position = Off;
|
||||||
if(c->titlebar_sw)
|
if(titlebar->sw)
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_unmap_window(globalconf.connection, titlebar->sw->window);
|
||||||
return;
|
|
||||||
return;
|
return;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
width = c->geometry.width + 2 * c->border;
|
width = MIN(titlebar->width, titlebar->client->geometry.width);
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.width);
|
width = titlebar->client->geometry.width + 2 * titlebar->client->border;
|
||||||
height = c->titlebar.height;
|
height = titlebar->height;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
case Right:
|
case Right:
|
||||||
if(!c->titlebar.width)
|
if(titlebar->width)
|
||||||
height = c->geometry.height + 2 * c->border;
|
height = MIN(titlebar->width, titlebar->client->geometry.height);
|
||||||
else
|
else
|
||||||
height = MIN(c->titlebar.width, c->geometry.height);
|
height = titlebar->client->geometry.height + 2 * titlebar->client->border;
|
||||||
width = c->titlebar.height;
|
width = titlebar->height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete old statusbar */
|
/* Delete old statusbar */
|
||||||
simplewindow_delete(&c->titlebar_sw);
|
simplewindow_delete(&titlebar->sw);
|
||||||
|
|
||||||
c->titlebar_sw = simplewindow_new(globalconf.connection,
|
titlebar->sw = simplewindow_new(globalconf.connection,
|
||||||
c->phys_screen, 0, 0,
|
titlebar->client->phys_screen, 0, 0,
|
||||||
width, height, 0);
|
width, height, 0);
|
||||||
titlebar_draw(c);
|
titlebar_draw(titlebar);
|
||||||
xcb_map_window(globalconf.connection, c->titlebar_sw->window);
|
xcb_map_window(globalconf.connection, titlebar->sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Create a new titlebar.
|
||||||
|
* \param A table with values: align, position, fg, bg, width and height.
|
||||||
|
* \return A brand new titlebar.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_titlebar_new(lua_State *L)
|
luaA_titlebar_new(lua_State *L)
|
||||||
{
|
{
|
||||||
titlebar_t **tb;
|
titlebar_t **tb;
|
||||||
int objpos;
|
int objpos;
|
||||||
|
const char *color;
|
||||||
|
|
||||||
luaA_checktable(L, 1);
|
luaA_checktable(L, 1);
|
||||||
|
|
||||||
|
@ -420,10 +427,6 @@ luaA_titlebar_new(lua_State *L)
|
||||||
*tb = p_new(titlebar_t, 1);
|
*tb = p_new(titlebar_t, 1);
|
||||||
objpos = lua_gettop(L);
|
objpos = lua_gettop(L);
|
||||||
|
|
||||||
(*tb)->text_normal = a_strdup(luaA_getopt_string(L, 1, "text_normal", "<title/>"));
|
|
||||||
(*tb)->text_focus = a_strdup(luaA_getopt_string(L, 1, "text_focus", "<title/>"));
|
|
||||||
(*tb)->text_urgent = a_strdup(luaA_getopt_string(L, 1, "text_urgent", "<title/>"));
|
|
||||||
|
|
||||||
(*tb)->align = draw_align_get_from_str(luaA_getopt_string(L, 1, "align", "left"));
|
(*tb)->align = draw_align_get_from_str(luaA_getopt_string(L, 1, "align", "left"));
|
||||||
|
|
||||||
(*tb)->width = luaA_getopt_number(L, 1, "width", 0);
|
(*tb)->width = luaA_getopt_number(L, 1, "width", 0);
|
||||||
|
@ -434,38 +437,88 @@ luaA_titlebar_new(lua_State *L)
|
||||||
|
|
||||||
(*tb)->position = position_get_from_str(luaA_getopt_string(L, 1, "position", "top"));
|
(*tb)->position = position_get_from_str(luaA_getopt_string(L, 1, "position", "top"));
|
||||||
|
|
||||||
|
lua_getfield(L, 1, "fg");
|
||||||
|
if((color = luaL_optstring(L, -1, NULL)))
|
||||||
|
xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
|
color, &(*tb)->colors.fg);
|
||||||
|
else
|
||||||
|
(*tb)->colors.fg = globalconf.colors.fg;
|
||||||
|
|
||||||
|
lua_getfield(L, 1, "bg");
|
||||||
|
if((color = luaL_optstring(L, -1, NULL)))
|
||||||
|
xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
|
color, &(*tb)->colors.bg);
|
||||||
|
else
|
||||||
|
(*tb)->colors.bg = globalconf.colors.bg;
|
||||||
|
|
||||||
titlebar_ref(tb);
|
titlebar_ref(tb);
|
||||||
|
|
||||||
lua_pushvalue(L, objpos);
|
lua_pushvalue(L, objpos);
|
||||||
return luaA_settype(L, "titlebar");
|
return luaA_settype(L, "titlebar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the client where the titlebar belongs to.
|
||||||
|
* \param A client where to attach titlebar, or none for removing.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_titlebar_mouse(lua_State *L)
|
luaA_titlebar_client_set(lua_State *L)
|
||||||
{
|
{
|
||||||
size_t i, len;
|
titlebar_t *oldt, **t = luaL_checkudata(L, 1, "titlebar");
|
||||||
int b;
|
client_t **c = NULL;
|
||||||
button_t *button;
|
|
||||||
|
if(lua_gettop(L) == 2)
|
||||||
|
c = luaL_checkudata(L, 2, "client");
|
||||||
|
|
||||||
/* arg 1 is modkey table */
|
if(!c)
|
||||||
luaA_checktable(L, 1);
|
|
||||||
/* arg 2 is mouse button */
|
|
||||||
b = luaL_checknumber(L, 2);
|
|
||||||
/* arg 3 is cmd to run */
|
|
||||||
luaA_checkfunction(L, 3);
|
|
||||||
|
|
||||||
button = p_new(button_t, 1);
|
|
||||||
button->button = xutil_button_fromint(b);
|
|
||||||
button->fct = luaL_ref(L, LUA_REGISTRYINDEX);
|
|
||||||
|
|
||||||
len = lua_objlen(L, 1);
|
|
||||||
for(i = 1; i <= len; i++)
|
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, 1, i);
|
if((*t)->client
|
||||||
button->mod |= xutil_keymask_fromstr(luaL_checkstring(L, -1));
|
&& (*t)->client->isfloating
|
||||||
|
&& layout_get_current((*t)->client->screen) != layout_floating)
|
||||||
|
globalconf.screens[(*t)->client->screen].need_arrange = true;
|
||||||
|
|
||||||
|
simplewindow_delete(&(*t)->sw);
|
||||||
|
titlebar_list_detach(&globalconf.titlebar, *t);
|
||||||
|
titlebar_unref(t);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if((oldt = titlebar_getbyclient(*c)))
|
||||||
|
{
|
||||||
|
simplewindow_delete(&oldt->sw);
|
||||||
|
titlebar_list_detach(&globalconf.titlebar, oldt);
|
||||||
|
titlebar_unref(&oldt);
|
||||||
|
}
|
||||||
|
|
||||||
|
titlebar_list_push(&globalconf.titlebar, *t);
|
||||||
|
titlebar_ref(t);
|
||||||
|
|
||||||
|
(*t)->client = *c;
|
||||||
|
titlebar_init(*t);
|
||||||
|
|
||||||
|
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
||||||
|
titlebar_update_geometry_floating(*t);
|
||||||
|
else
|
||||||
|
globalconf.screens[(*c)->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_list_push(&globalconf.buttons.titlebar, button);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add a widget to a titlebar.
|
||||||
|
* \param A widget.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_titlebar_widget_add(lua_State *L)
|
||||||
|
{
|
||||||
|
titlebar_t **tb = luaL_checkudata(L, 1, "titlebar");
|
||||||
|
widget_t **widget = luaL_checkudata(L, 2, "widget");
|
||||||
|
widget_node_t *w = p_new(widget_node_t, 1);
|
||||||
|
|
||||||
|
w->widget = *widget;
|
||||||
|
widget_node_list_append(&(*tb)->widgets, w);
|
||||||
|
widget_ref(widget);
|
||||||
|
|
||||||
|
titlebar_draw(*tb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -498,11 +551,12 @@ luaA_titlebar_eq(lua_State *L)
|
||||||
const struct luaL_reg awesome_titlebar_methods[] =
|
const struct luaL_reg awesome_titlebar_methods[] =
|
||||||
{
|
{
|
||||||
{ "new", luaA_titlebar_new },
|
{ "new", luaA_titlebar_new },
|
||||||
{ "mouse", luaA_titlebar_mouse },
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
const struct luaL_reg awesome_titlebar_meta[] =
|
const struct luaL_reg awesome_titlebar_meta[] =
|
||||||
{
|
{
|
||||||
|
{ "client_set", luaA_titlebar_client_set },
|
||||||
|
{ "widget_add", luaA_titlebar_widget_add },
|
||||||
{ "__eq", luaA_titlebar_eq },
|
{ "__eq", luaA_titlebar_eq },
|
||||||
{ "__gc", luaA_titlebar_gc },
|
{ "__gc", luaA_titlebar_gc },
|
||||||
{ "__tostring", luaA_titlebar_tostring },
|
{ "__tostring", luaA_titlebar_tostring },
|
||||||
|
|
88
titlebar.h
88
titlebar.h
|
@ -24,10 +24,12 @@
|
||||||
|
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
void titlebar_draw(client_t *);
|
titlebar_t * titlebar_getbyclient(client_t *);
|
||||||
void titlebar_update_geometry_floating(client_t *);
|
titlebar_t * titlebar_getbywin(xcb_window_t);
|
||||||
void titlebar_update_geometry(client_t *, area_t);
|
void titlebar_draw(titlebar_t *);
|
||||||
void titlebar_init(client_t *);
|
void titlebar_update_geometry_floating(titlebar_t *);
|
||||||
|
void titlebar_update_geometry(titlebar_t *, area_t);
|
||||||
|
void titlebar_init(titlebar_t *);
|
||||||
|
|
||||||
/** Add the titlebar geometry to a geometry.
|
/** Add the titlebar geometry to a geometry.
|
||||||
* \param t the titlebar
|
* \param t the titlebar
|
||||||
|
@ -37,25 +39,26 @@ void titlebar_init(client_t *);
|
||||||
static inline area_t
|
static inline area_t
|
||||||
titlebar_geometry_add(titlebar_t *t, area_t geometry)
|
titlebar_geometry_add(titlebar_t *t, area_t geometry)
|
||||||
{
|
{
|
||||||
switch(t->position)
|
if(t && t->sw)
|
||||||
{
|
switch(t->position)
|
||||||
case Top:
|
{
|
||||||
geometry.y -= t->height;
|
case Top:
|
||||||
geometry.height += t->height;
|
geometry.y -= t->sw->geometry.height;
|
||||||
break;
|
geometry.height += t->sw->geometry.height;
|
||||||
case Bottom:
|
break;
|
||||||
geometry.height += t->height;
|
case Bottom:
|
||||||
break;
|
geometry.height += t->sw->geometry.height;
|
||||||
case Left:
|
break;
|
||||||
geometry.x -= t->width;
|
case Left:
|
||||||
geometry.width += t->width;
|
geometry.x -= t->sw->geometry.width;
|
||||||
break;
|
geometry.width += t->sw->geometry.width;
|
||||||
case Right:
|
break;
|
||||||
geometry.width += t->width;
|
case Right:
|
||||||
break;
|
geometry.width += t->sw->geometry.width;
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
@ -68,25 +71,26 @@ titlebar_geometry_add(titlebar_t *t, area_t geometry)
|
||||||
static inline area_t
|
static inline area_t
|
||||||
titlebar_geometry_remove(titlebar_t *t, area_t geometry)
|
titlebar_geometry_remove(titlebar_t *t, area_t geometry)
|
||||||
{
|
{
|
||||||
switch(t->position)
|
if(t && t->sw)
|
||||||
{
|
switch(t->position)
|
||||||
case Top:
|
{
|
||||||
geometry.y += t->height;
|
case Top:
|
||||||
geometry.height -= t->height;
|
geometry.y += t->sw->geometry.height;
|
||||||
break;
|
geometry.height -= t->sw->geometry.height;
|
||||||
case Bottom:
|
break;
|
||||||
geometry.height -= t->height;
|
case Bottom:
|
||||||
break;
|
geometry.height -= t->sw->geometry.height;
|
||||||
case Left:
|
break;
|
||||||
geometry.x += t->width;
|
case Left:
|
||||||
geometry.width -= t->width;
|
geometry.x += t->sw->geometry.width;
|
||||||
break;
|
geometry.width -= t->sw->geometry.width;
|
||||||
case Right:
|
break;
|
||||||
geometry.width -= t->width;
|
case Right:
|
||||||
break;
|
geometry.width -= t->sw->geometry.width;
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
31
widget.c
31
widget.c
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
#include "titlebar.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
@ -118,9 +119,10 @@ widget_common_tell(widget_t *widget,
|
||||||
* \param y The y coordinates of the object.
|
* \param y The y coordinates of the object.
|
||||||
* drawable when the object position is right or left.
|
* drawable when the object position is right or left.
|
||||||
* \param object The object pointer.
|
* \param object The object pointer.
|
||||||
|
* \todo Remove GC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_drawable_t rotate_dw,
|
widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_drawable_t rotate_dw,
|
||||||
int screen, position_t position,
|
int screen, position_t position,
|
||||||
int x, int y, void *object)
|
int x, int y, void *object)
|
||||||
{
|
{
|
||||||
|
@ -179,11 +181,11 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_drawable_t rotate_d
|
||||||
x + ctx->height);
|
x + ctx->height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
draw_rotate(ctx,
|
xcb_copy_area(globalconf.connection, rootpix,
|
||||||
rootpix, ctx->drawable,
|
rotate_dw, gc,
|
||||||
rootsize.width, rootsize.height,
|
x, y,
|
||||||
ctx->width, ctx->height,
|
0, 0,
|
||||||
0, x, y);
|
ctx->width, ctx->height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,15 +262,17 @@ widget_invalidate_cache(int screen, int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a statusbar needs update because it has widget.
|
/** Set a statusbar needs update because it has widget, or redraw a titlebar.
|
||||||
|
* \todo Probably needs more optimization.
|
||||||
* \param widget The widget to look for.
|
* \param widget The widget to look for.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
widget_invalidate_statusbar_bywidget(widget_t *widget)
|
widget_invalidate_bywidget(widget_t *widget)
|
||||||
{
|
{
|
||||||
int screen;
|
int screen;
|
||||||
statusbar_t *statusbar;
|
statusbar_t *statusbar;
|
||||||
widget_node_t *witer;
|
widget_node_t *witer;
|
||||||
|
titlebar_t *t;
|
||||||
|
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar;
|
for(statusbar = globalconf.screens[screen].statusbar;
|
||||||
|
@ -280,6 +284,11 @@ widget_invalidate_statusbar_bywidget(widget_t *widget)
|
||||||
statusbar->need_update = true;
|
statusbar->need_update = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(t = globalconf.titlebar; t; t = t->next)
|
||||||
|
for(witer = t->widgets; witer; witer = witer->next)
|
||||||
|
if(witer->widget == widget)
|
||||||
|
titlebar_draw(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new widget userdata. The object is pushed on the stack.
|
/** Create a new widget userdata. The object is pushed on the stack.
|
||||||
|
@ -396,7 +405,7 @@ widget_tell_managestatus(widget_t *widget, widget_tell_status_t status, const ch
|
||||||
property, widget->name);
|
property, widget->name);
|
||||||
break;
|
break;
|
||||||
case WIDGET_NOERROR:
|
case WIDGET_NOERROR:
|
||||||
widget_invalidate_statusbar_bywidget(widget);
|
widget_invalidate_bywidget(widget);
|
||||||
break;
|
break;
|
||||||
case WIDGET_ERROR_CUSTOM:
|
case WIDGET_ERROR_CUSTOM:
|
||||||
break;
|
break;
|
||||||
|
@ -528,7 +537,7 @@ luaA_widget_visible_set(lua_State *L)
|
||||||
{
|
{
|
||||||
widget_t **widget = luaL_checkudata(L, 1, "widget");
|
widget_t **widget = luaL_checkudata(L, 1, "widget");
|
||||||
(*widget)->isvisible = luaA_checkboolean(L, 2);
|
(*widget)->isvisible = luaA_checkboolean(L, 2);
|
||||||
widget_invalidate_statusbar_bywidget(*widget);
|
widget_invalidate_bywidget(*widget);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
widget.h
3
widget.h
|
@ -36,9 +36,8 @@ void widget_invalidate_cache(int, int);
|
||||||
int widget_calculate_offset(int, int, int, int);
|
int widget_calculate_offset(int, int, int, int);
|
||||||
void widget_common_new(widget_t *);
|
void widget_common_new(widget_t *);
|
||||||
widget_t * widget_getbyname(const char *);
|
widget_t * widget_getbyname(const char *);
|
||||||
void widget_invalidate_statusbar_bywidget(widget_t *);
|
|
||||||
void widget_tell_managestatus(widget_t *, widget_tell_status_t, const char *);
|
void widget_tell_managestatus(widget_t *, widget_tell_status_t, const char *);
|
||||||
void widget_render(widget_node_t *, draw_context_t *, xcb_drawable_t, int, position_t, int, int, void *);
|
void widget_render(widget_node_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, position_t, int, int, void *);
|
||||||
|
|
||||||
widget_constructor_t taglist_new;
|
widget_constructor_t taglist_new;
|
||||||
widget_constructor_t textbox_new;
|
widget_constructor_t textbox_new;
|
||||||
|
|
Loading…
Reference in New Issue