wibox: use new Lua object system
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
81033d391b
commit
5931bf752d
20
client.c
20
client.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* client.c - client management
|
* client.c - client management
|
||||||
*
|
*
|
||||||
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -391,9 +391,9 @@ client_real_stack(void)
|
||||||
|
|
||||||
/* first stack not ontop wibox window */
|
/* first stack not ontop wibox window */
|
||||||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(_sb, globalconf.screens[screen].wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *sb = globalconf.screens[screen].wiboxes.tab[i];
|
wibox_t *sb = *_sb;
|
||||||
if(!sb->ontop)
|
if(!sb->ontop)
|
||||||
{
|
{
|
||||||
xcb_configure_window(globalconf.connection,
|
xcb_configure_window(globalconf.connection,
|
||||||
|
@ -413,9 +413,9 @@ client_real_stack(void)
|
||||||
|
|
||||||
/* then stack ontop wibox window */
|
/* then stack ontop wibox window */
|
||||||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(_sb, globalconf.screens[screen].wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *sb = globalconf.screens[screen].wiboxes.tab[i];
|
wibox_t *sb = *_sb;
|
||||||
if(sb->ontop)
|
if(sb->ontop)
|
||||||
{
|
{
|
||||||
xcb_configure_window(globalconf.connection,
|
xcb_configure_window(globalconf.connection,
|
||||||
|
@ -1667,7 +1667,6 @@ luaA_client_newindex(lua_State *L)
|
||||||
bool b;
|
bool b;
|
||||||
double d;
|
double d;
|
||||||
int i;
|
int i;
|
||||||
wibox_t **t = NULL;
|
|
||||||
|
|
||||||
switch(a_tokenize(buf, len))
|
switch(a_tokenize(buf, len))
|
||||||
{
|
{
|
||||||
|
@ -1748,10 +1747,7 @@ luaA_client_newindex(lua_State *L)
|
||||||
if(lua_isnil(L, 3))
|
if(lua_isnil(L, 3))
|
||||||
titlebar_client_detach(c);
|
titlebar_client_detach(c);
|
||||||
else
|
else
|
||||||
{
|
titlebar_client_attach(c);
|
||||||
t = luaA_checkudata(L, 3, "wibox");
|
|
||||||
titlebar_client_attach(c, *t);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1970,9 +1966,7 @@ luaA_client_index(lua_State *L)
|
||||||
luaA_pushcolor(L, &c->border_color);
|
luaA_pushcolor(L, &c->border_color);
|
||||||
break;
|
break;
|
||||||
case A_TK_TITLEBAR:
|
case A_TK_TITLEBAR:
|
||||||
if(c->titlebar)
|
return wibox_push(L, c->titlebar);
|
||||||
return luaA_wibox_userdata_new(L, c->titlebar);
|
|
||||||
return 0;
|
|
||||||
case A_TK_URGENT:
|
case A_TK_URGENT:
|
||||||
lua_pushboolean(L, c->isurgent);
|
lua_pushboolean(L, c->isurgent);
|
||||||
break;
|
break;
|
||||||
|
|
14
event.c
14
event.c
|
@ -153,14 +153,14 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
||||||
case XCB_BUTTON_PRESS:
|
case XCB_BUTTON_PRESS:
|
||||||
if(b->tab[i]->press != LUA_REFNIL)
|
if(b->tab[i]->press != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
wibox_push(globalconf.L, wibox);
|
||||||
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XCB_BUTTON_RELEASE:
|
case XCB_BUTTON_RELEASE:
|
||||||
if(b->tab[i]->release != LUA_REFNIL)
|
if(b->tab[i]->release != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
wibox_push(globalconf.L, wibox);
|
||||||
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -183,14 +183,14 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
||||||
case XCB_BUTTON_PRESS:
|
case XCB_BUTTON_PRESS:
|
||||||
if(b->tab[i]->press != LUA_REFNIL)
|
if(b->tab[i]->press != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
wibox_push(globalconf.L, wibox);
|
||||||
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XCB_BUTTON_RELEASE:
|
case XCB_BUTTON_RELEASE:
|
||||||
if(b->tab[i]->release != LUA_REFNIL)
|
if(b->tab[i]->release != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
wibox_push(globalconf.L, wibox);
|
||||||
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -399,7 +399,7 @@ event_handle_widget_motionnotify(void *object,
|
||||||
if((*mouse_over)->mouse_leave != LUA_REFNIL)
|
if((*mouse_over)->mouse_leave != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
/* call mouse leave function on old widget */
|
/* call mouse leave function on old widget */
|
||||||
luaA_wibox_userdata_new(globalconf.L, object);
|
widget_push(globalconf.L, *mouse_over);
|
||||||
luaA_dofunction(globalconf.L, (*mouse_over)->mouse_leave, 1, 0);
|
luaA_dofunction(globalconf.L, (*mouse_over)->mouse_leave, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ event_handle_widget_motionnotify(void *object,
|
||||||
*mouse_over = widget;
|
*mouse_over = widget;
|
||||||
if(widget->mouse_enter != LUA_REFNIL)
|
if(widget->mouse_enter != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(globalconf.L, object);
|
widget_push(globalconf.L, widget);
|
||||||
luaA_dofunction(globalconf.L, widget->mouse_enter, 1, 0);
|
luaA_dofunction(globalconf.L, widget->mouse_enter, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
|
||||||
if(wibox->mouse_over->mouse_leave != LUA_REFNIL)
|
if(wibox->mouse_over->mouse_leave != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
/* call mouse leave function on widget the mouse was over */
|
/* call mouse leave function on widget the mouse was over */
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
wibox_push(globalconf.L, wibox);
|
||||||
luaA_dofunction(globalconf.L, wibox->mouse_over->mouse_leave, 1, 0);
|
luaA_dofunction(globalconf.L, wibox->mouse_over->mouse_leave, 1, 0);
|
||||||
}
|
}
|
||||||
wibox->mouse_over = NULL;
|
wibox->mouse_over = NULL;
|
||||||
|
|
2
mouse.c
2
mouse.c
|
@ -470,7 +470,7 @@ luaA_mouse_object_under_pointer(lua_State *L)
|
||||||
client_t *client;
|
client_t *client;
|
||||||
if((wibox = wibox_getbywin(child)))
|
if((wibox = wibox_getbywin(child)))
|
||||||
{
|
{
|
||||||
luaA_wibox_userdata_new(L, wibox);
|
wibox_push(L, wibox);
|
||||||
|
|
||||||
int16_t x = mouse_x - wibox->sw.geometry.x;
|
int16_t x = mouse_x - wibox->sw.geometry.x;
|
||||||
int16_t y = mouse_y - wibox->sw.geometry.y;
|
int16_t y = mouse_y - wibox->sw.geometry.y;
|
||||||
|
|
12
property.c
12
property.c
|
@ -377,17 +377,13 @@ property_handle_xrootpmap_id(void *data __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
if(globalconf.xinerama_is_active)
|
if(globalconf.xinerama_is_active)
|
||||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
{
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
wibox_array_t *w = &globalconf.screens[screen].wiboxes;
|
(*w)->need_update = true;
|
||||||
for(int i = 0; i < w->len; i++)
|
|
||||||
w->tab[i]->need_update = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int screen = xutil_root2screen(connection, window);
|
int screen = xutil_root2screen(connection, window);
|
||||||
wibox_array_t *w = &globalconf.screens[screen].wiboxes;
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
for(int i = 0; i < w->len; i++)
|
(*w)->need_update = true;
|
||||||
w->tab[i]->need_update = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
12
screen.c
12
screen.c
|
@ -216,9 +216,9 @@ screen_area_get(int screen, wibox_array_t *wiboxes,
|
||||||
|
|
||||||
/* swindow geometry includes borders. */
|
/* swindow geometry includes borders. */
|
||||||
if(wiboxes)
|
if(wiboxes)
|
||||||
for(int i = 0; i < wiboxes->len; i++)
|
foreach(_w, *wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *w = wiboxes->tab[i];
|
wibox_t *w = *_w;
|
||||||
if(w->isvisible)
|
if(w->isvisible)
|
||||||
switch(w->position)
|
switch(w->position)
|
||||||
{
|
{
|
||||||
|
@ -263,9 +263,9 @@ display_area_get(int phys_screen, wibox_array_t *wiboxes, padding_t *padding)
|
||||||
.height = s->height_in_pixels };
|
.height = s->height_in_pixels };
|
||||||
|
|
||||||
if(wiboxes)
|
if(wiboxes)
|
||||||
for(int i = 0; i < wiboxes->len; i++)
|
foreach(_w, *wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *w = wiboxes->tab[i];
|
wibox_t *w = *_w;
|
||||||
area.y += w->position == Top ? w->sw.geometry.height : 0;
|
area.y += w->position == Top ? w->sw.geometry.height : 0;
|
||||||
area.height -= (w->position == Top || w->position == Bottom) ? w->sw.geometry.height : 0;
|
area.height -= (w->position == Top || w->position == Bottom) ? w->sw.geometry.height : 0;
|
||||||
}
|
}
|
||||||
|
@ -513,8 +513,8 @@ luaA_screen_padding(lua_State *L)
|
||||||
s->need_arrange = true;
|
s->need_arrange = true;
|
||||||
|
|
||||||
/* All the wiboxes repositioned */
|
/* All the wiboxes repositioned */
|
||||||
for(int i = 0; i < s->wiboxes.len; i++)
|
foreach(w, s->wiboxes)
|
||||||
wibox_position_update(s->wiboxes.tab[i]);
|
wibox_position_update(*w);
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(s->index));
|
ewmh_update_workarea(screen_virttophys(s->index));
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ ARRAY_TYPE(button_t *, button)
|
||||||
/** Wibox type */
|
/** Wibox type */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Ref count */
|
/** Lua references */
|
||||||
int refcount;
|
luaA_ref_array_t refs;
|
||||||
/** Ontop */
|
/** Ontop */
|
||||||
bool ontop;
|
bool ontop;
|
||||||
/** Visible */
|
/** Visible */
|
||||||
|
|
21
titlebar.c
21
titlebar.c
|
@ -219,8 +219,10 @@ titlebar_client_detach(client_t *c)
|
||||||
simplewindow_wipe(&c->titlebar->sw);
|
simplewindow_wipe(&c->titlebar->sw);
|
||||||
c->titlebar->type = WIBOX_TYPE_NORMAL;
|
c->titlebar->type = WIBOX_TYPE_NORMAL;
|
||||||
c->titlebar->screen = SCREEN_UNDEF;
|
c->titlebar->screen = SCREEN_UNDEF;
|
||||||
wibox_unref(&c->titlebar);
|
|
||||||
|
wibox_unref(globalconf.L, c->titlebar);
|
||||||
c->titlebar = NULL;
|
c->titlebar = NULL;
|
||||||
|
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
client_stack();
|
client_stack();
|
||||||
}
|
}
|
||||||
|
@ -228,16 +230,15 @@ titlebar_client_detach(client_t *c)
|
||||||
|
|
||||||
/** Attach a wibox to a client as its titlebar.
|
/** Attach a wibox to a client as its titlebar.
|
||||||
* \param c The client.
|
* \param c The client.
|
||||||
* \param t The wibox/titlebar.
|
* \param ud The index of the wibox on the stack.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
titlebar_client_attach(client_t *c, wibox_t *t)
|
titlebar_client_attach(client_t *c)
|
||||||
{
|
{
|
||||||
titlebar_client_detach(c);
|
/* check if we can register the object */
|
||||||
|
wibox_t *t = wibox_ref(globalconf.L);
|
||||||
|
|
||||||
if(c && t)
|
titlebar_client_detach(c);
|
||||||
{
|
|
||||||
area_t wingeom;
|
|
||||||
|
|
||||||
/* check if titlebar is already on a client */
|
/* check if titlebar is already on a client */
|
||||||
titlebar_client_detach(client_getbytitlebar(t));
|
titlebar_client_detach(client_getbytitlebar(t));
|
||||||
|
@ -245,7 +246,9 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
/* check if client already has a titlebar. */
|
/* check if client already has a titlebar. */
|
||||||
titlebar_client_detach(c);
|
titlebar_client_detach(c);
|
||||||
|
|
||||||
c->titlebar = wibox_ref(&t);
|
/* set the object as new client's titlebar */
|
||||||
|
c->titlebar = t;
|
||||||
|
|
||||||
t->type = WIBOX_TYPE_TITLEBAR;
|
t->type = WIBOX_TYPE_TITLEBAR;
|
||||||
t->screen = c->screen;
|
t->screen = c->screen;
|
||||||
|
|
||||||
|
@ -269,6 +272,7 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
c->geometry = titlebar_geometry_add(c->titlebar, 0, c->geometry);
|
c->geometry = titlebar_geometry_add(c->titlebar, 0, c->geometry);
|
||||||
|
|
||||||
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
||||||
|
area_t wingeom;
|
||||||
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &wingeom);
|
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &wingeom);
|
||||||
|
|
||||||
simplewindow_init(&t->sw, c->phys_screen,
|
simplewindow_init(&t->sw, c->phys_screen,
|
||||||
|
@ -287,7 +291,6 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
|
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
client_stack();
|
client_stack();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Map or unmap a titlebar wibox.
|
/** Map or unmap a titlebar wibox.
|
||||||
|
|
|
@ -31,7 +31,7 @@ client_t * client_getbytitlebarwin(xcb_window_t);
|
||||||
void titlebar_geometry_compute(client_t *, area_t, area_t *);
|
void titlebar_geometry_compute(client_t *, area_t, area_t *);
|
||||||
void titlebar_init(client_t *);
|
void titlebar_init(client_t *);
|
||||||
void titlebar_client_detach(client_t *);
|
void titlebar_client_detach(client_t *);
|
||||||
void titlebar_client_attach(client_t *, wibox_t *);
|
void titlebar_client_attach(client_t *);
|
||||||
void titlebar_set_visible(wibox_t *, bool);
|
void titlebar_set_visible(wibox_t *, bool);
|
||||||
void titlebar_ban(wibox_t *);
|
void titlebar_ban(wibox_t *);
|
||||||
void titlebar_unban(wibox_t *);
|
void titlebar_unban(wibox_t *);
|
||||||
|
|
289
wibox.c
289
wibox.c
|
@ -28,9 +28,30 @@
|
||||||
#include "common/xcursor.h"
|
#include "common/xcursor.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
DO_LUA_NEW(extern, wibox_t, wibox, "wibox", wibox_ref)
|
DO_LUA_TOSTRING(wibox_t, wibox, "wibox")
|
||||||
DO_LUA_GC(wibox_t, wibox, "wibox", wibox_unref)
|
|
||||||
DO_LUA_EQ(wibox_t, wibox, "wibox")
|
/** Take care of garbage collecting a wibox.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack, 0!
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_wibox_gc(lua_State *L)
|
||||||
|
{
|
||||||
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
||||||
|
simplewindow_wipe(&wibox->sw);
|
||||||
|
button_array_wipe(&wibox->buttons);
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, wibox->widgets_table);
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_enter);
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_leave);
|
||||||
|
widget_node_array_wipe(&wibox->widgets);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wibox_unref_simplified(wibox_t **item)
|
||||||
|
{
|
||||||
|
wibox_unref(globalconf.L, *item);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wibox_need_update(wibox_t *wibox)
|
wibox_need_update(wibox_t *wibox)
|
||||||
|
@ -104,9 +125,8 @@ wibox_setposition(wibox_t *wibox, position_t p)
|
||||||
wibox_position_update(wibox);
|
wibox_position_update(wibox);
|
||||||
|
|
||||||
/* reset all wibox position */
|
/* reset all wibox position */
|
||||||
wibox_array_t *w = &globalconf.screens[wibox->screen].wiboxes;
|
foreach(w, globalconf.screens[wibox->screen].wiboxes)
|
||||||
for(int i = 0; i < w->len; i++)
|
wibox_position_update(*w);
|
||||||
wibox_position_update(w->tab[i]);
|
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(wibox->screen));
|
ewmh_update_workarea(screen_virttophys(wibox->screen));
|
||||||
|
|
||||||
|
@ -319,9 +339,9 @@ wibox_position_update(wibox_t *wibox)
|
||||||
|
|
||||||
/* Top and Bottom wibox_t have prio */
|
/* Top and Bottom wibox_t have prio */
|
||||||
if(wibox->position != Floating)
|
if(wibox->position != Floating)
|
||||||
for(int i = 0; i < globalconf.screens[wibox->screen].wiboxes.len; i++)
|
foreach(_w, globalconf.screens[wibox->screen].wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *w = globalconf.screens[wibox->screen].wiboxes.tab[i];
|
wibox_t *w = *_w;
|
||||||
/* Ignore every wibox after me that is in the same position */
|
/* Ignore every wibox after me that is in the same position */
|
||||||
if(wibox == w)
|
if(wibox == w)
|
||||||
{
|
{
|
||||||
|
@ -474,40 +494,22 @@ wibox_position_update(wibox_t *wibox)
|
||||||
wibox_move(wibox, wingeom.x, wingeom.y);
|
wibox_move(wibox, wingeom.x, wingeom.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete a wibox.
|
|
||||||
* \param wibox wibox to delete.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
wibox_delete(wibox_t **wibox)
|
|
||||||
{
|
|
||||||
simplewindow_wipe(&(*wibox)->sw);
|
|
||||||
button_array_wipe(&(*wibox)->buttons);
|
|
||||||
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
|
||||||
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->mouse_enter);
|
|
||||||
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->mouse_leave);
|
|
||||||
widget_node_array_wipe(&(*wibox)->widgets);
|
|
||||||
p_delete(wibox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get a wibox by its window.
|
/** Get a wibox by its window.
|
||||||
* \param w The window id.
|
* \param w The window id.
|
||||||
* \return A wibox if found, NULL otherwise.
|
* \return A wibox if found, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
wibox_t *
|
wibox_t *
|
||||||
wibox_getbywin(xcb_window_t w)
|
wibox_getbywin(xcb_window_t win)
|
||||||
{
|
{
|
||||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
{
|
if((*w)->sw.window == win)
|
||||||
wibox_t *s = globalconf.screens[screen].wiboxes.tab[i];
|
return *w;
|
||||||
if(s->sw.window == w)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
foreach(_c, globalconf.clients)
|
||||||
{
|
{
|
||||||
client_t *c = *_c;
|
client_t *c = *_c;
|
||||||
if(c->titlebar && c->titlebar->sw.window == w)
|
if(c->titlebar && c->titlebar->sw.window == win)
|
||||||
return c->titlebar;
|
return c->titlebar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,12 +539,9 @@ void
|
||||||
wibox_refresh(void)
|
wibox_refresh(void)
|
||||||
{
|
{
|
||||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
{
|
if((*w)->need_update)
|
||||||
wibox_t *s = globalconf.screens[screen].wiboxes.tab[i];
|
wibox_draw(*w);
|
||||||
if(s->need_update)
|
|
||||||
wibox_draw(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
foreach(_c, globalconf.clients)
|
||||||
{
|
{
|
||||||
|
@ -558,11 +557,8 @@ void
|
||||||
wibox_update_positions(void)
|
wibox_update_positions(void)
|
||||||
{
|
{
|
||||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
{
|
wibox_position_update(*w);
|
||||||
wibox_t *s = globalconf.screens[screen].wiboxes.tab[i];
|
|
||||||
wibox_position_update(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a wibox visible or not.
|
/** Set a wibox visible or not.
|
||||||
|
@ -588,9 +584,8 @@ wibox_setvisible(wibox_t *wibox, bool v)
|
||||||
wibox_systray_refresh(wibox);
|
wibox_systray_refresh(wibox);
|
||||||
|
|
||||||
/* All the other wibox and ourselves need to be repositioned */
|
/* All the other wibox and ourselves need to be repositioned */
|
||||||
wibox_array_t *w = &globalconf.screens[wibox->screen].wiboxes;
|
foreach(w, globalconf.screens[wibox->screen].wiboxes)
|
||||||
for(int i = 0; i < w->len; i++)
|
wibox_position_update(*w);
|
||||||
wibox_position_update(w->tab[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,27 +612,30 @@ wibox_detach(wibox_t *wibox)
|
||||||
|
|
||||||
simplewindow_wipe(&wibox->sw);
|
simplewindow_wipe(&wibox->sw);
|
||||||
|
|
||||||
for(int i = 0; i < globalconf.screens[wibox->screen].wiboxes.len; i++)
|
globalconf.screens[wibox->screen].need_arrange = true;
|
||||||
if(globalconf.screens[wibox->screen].wiboxes.tab[i] == wibox)
|
|
||||||
|
foreach(item, globalconf.screens[wibox->screen].wiboxes)
|
||||||
|
if(*item == wibox)
|
||||||
{
|
{
|
||||||
wibox_array_take(&globalconf.screens[wibox->screen].wiboxes, i);
|
wibox_array_remove(&globalconf.screens[wibox->screen].wiboxes, item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
globalconf.screens[wibox->screen].need_arrange = true;
|
|
||||||
wibox->screen = SCREEN_UNDEF;
|
wibox->screen = SCREEN_UNDEF;
|
||||||
wibox_unref(&wibox);
|
wibox_unref(globalconf.L, wibox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Attach a wibox.
|
/** Attach a wibox that is on top of the stack.
|
||||||
* \param wibox The wibox to attach.
|
|
||||||
* \param s The screen to attach the wibox to.
|
* \param s The screen to attach the wibox to.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
wibox_attach(wibox_t *wibox, screen_t *s)
|
wibox_attach(screen_t *s)
|
||||||
{
|
{
|
||||||
int phys_screen = screen_virttophys(s->index);
|
int phys_screen = screen_virttophys(s->index);
|
||||||
|
|
||||||
|
wibox_t *wibox = wibox_ref(globalconf.L);
|
||||||
|
|
||||||
wibox_detach(wibox);
|
wibox_detach(wibox);
|
||||||
|
|
||||||
/* Set the wibox screen */
|
/* Set the wibox screen */
|
||||||
|
@ -650,7 +648,7 @@ wibox_attach(wibox_t *wibox, screen_t *s)
|
||||||
if(cscreen != wibox->screen)
|
if(cscreen != wibox->screen)
|
||||||
wibox_move(wibox, s->geometry.x, s->geometry.y);
|
wibox_move(wibox, s->geometry.x, s->geometry.y);
|
||||||
|
|
||||||
wibox_array_append(&s->wiboxes, wibox_ref(&wibox));
|
wibox_array_append(&s->wiboxes, wibox);
|
||||||
|
|
||||||
/* compute x/y/width/height if not set */
|
/* compute x/y/width/height if not set */
|
||||||
wibox_position_update(wibox);
|
wibox_position_update(wibox);
|
||||||
|
@ -667,8 +665,8 @@ wibox_attach(wibox_t *wibox, screen_t *s)
|
||||||
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
||||||
|
|
||||||
/* All the other wibox and ourselves need to be repositioned */
|
/* All the other wibox and ourselves need to be repositioned */
|
||||||
for(int i = 0; i < s->wiboxes.len; i++)
|
foreach(w, s->wiboxes)
|
||||||
wibox_position_update(s->wiboxes.tab[i]);
|
wibox_position_update(*w);
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(s->index));
|
ewmh_update_workarea(screen_virttophys(s->index));
|
||||||
|
|
||||||
|
@ -686,7 +684,7 @@ wibox_attach(wibox_t *wibox, screen_t *s)
|
||||||
* position, align, fg, bg, border_width, border_color, ontop, width and height.
|
* position, align, fg, bg, border_width, border_color, ontop, width and height.
|
||||||
* \lreturn A brand new wibox.
|
* \lreturn A brand new wibox.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
luaA_wibox_new(lua_State *L)
|
luaA_wibox_new(lua_State *L)
|
||||||
{
|
{
|
||||||
wibox_t *w;
|
wibox_t *w;
|
||||||
|
@ -697,7 +695,7 @@ luaA_wibox_new(lua_State *L)
|
||||||
|
|
||||||
luaA_checktable(L, 2);
|
luaA_checktable(L, 2);
|
||||||
|
|
||||||
w = p_new(wibox_t, 1);
|
w = wibox_new(L);
|
||||||
w->widgets_table = LUA_REFNIL;
|
w->widgets_table = LUA_REFNIL;
|
||||||
|
|
||||||
w->sw.ctx.fg = globalconf.colors.fg;
|
w->sw.ctx.fg = globalconf.colors.fg;
|
||||||
|
@ -750,7 +748,7 @@ luaA_wibox_new(lua_State *L)
|
||||||
for(i = 0; i <= reqs_nbr; i++)
|
for(i = 0; i <= reqs_nbr; i++)
|
||||||
xcolor_init_reply(reqs[i]);
|
xcolor_init_reply(reqs[i]);
|
||||||
|
|
||||||
return luaA_wibox_userdata_new(L, w);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rebuild wibox widgets list.
|
/** Rebuild wibox widgets list.
|
||||||
|
@ -791,9 +789,9 @@ void
|
||||||
luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
||||||
{
|
{
|
||||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(w, globalconf.screens[screen].wiboxes)
|
||||||
{
|
{
|
||||||
wibox_t *wibox = globalconf.screens[screen].wiboxes.tab[i];
|
wibox_t *wibox = *w;
|
||||||
if(luaA_wibox_hasitem(L, wibox, item))
|
if(luaA_wibox_hasitem(L, wibox, item))
|
||||||
{
|
{
|
||||||
/* recompute widget node list */
|
/* recompute widget node list */
|
||||||
|
@ -836,7 +834,7 @@ static int
|
||||||
luaA_wibox_index(lua_State *L)
|
luaA_wibox_index(lua_State *L)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
wibox_t **wibox = luaA_checkudata(L, 1, "wibox");
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
||||||
const char *attr = luaL_checklstring(L, 2, &len);
|
const char *attr = luaL_checklstring(L, 2, &len);
|
||||||
|
|
||||||
if(luaA_usemetatable(L, 1, 2))
|
if(luaA_usemetatable(L, 1, 2))
|
||||||
|
@ -845,69 +843,69 @@ luaA_wibox_index(lua_State *L)
|
||||||
switch(a_tokenize(attr, len))
|
switch(a_tokenize(attr, len))
|
||||||
{
|
{
|
||||||
case A_TK_VISIBLE:
|
case A_TK_VISIBLE:
|
||||||
lua_pushboolean(L, (*wibox)->isvisible);
|
lua_pushboolean(L, wibox->isvisible);
|
||||||
break;
|
break;
|
||||||
case A_TK_CLIENT:
|
case A_TK_CLIENT:
|
||||||
return client_push(L, client_getbytitlebar(*wibox));
|
return client_push(L, client_getbytitlebar(wibox));
|
||||||
case A_TK_SCREEN:
|
case A_TK_SCREEN:
|
||||||
if((*wibox)->screen == SCREEN_UNDEF)
|
if(wibox->screen == SCREEN_UNDEF)
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushnumber(L, (*wibox)->screen + 1);
|
lua_pushnumber(L, wibox->screen + 1);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_WIDTH:
|
case A_TK_BORDER_WIDTH:
|
||||||
lua_pushnumber(L, (*wibox)->sw.border.width);
|
lua_pushnumber(L, wibox->sw.border.width);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_COLOR:
|
case A_TK_BORDER_COLOR:
|
||||||
luaA_pushcolor(L, &(*wibox)->sw.border.color);
|
luaA_pushcolor(L, &wibox->sw.border.color);
|
||||||
break;
|
break;
|
||||||
case A_TK_ALIGN:
|
case A_TK_ALIGN:
|
||||||
lua_pushstring(L, draw_align_tostr((*wibox)->align));
|
lua_pushstring(L, draw_align_tostr(wibox->align));
|
||||||
break;
|
break;
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
luaA_pushcolor(L, &(*wibox)->sw.ctx.fg);
|
luaA_pushcolor(L, &wibox->sw.ctx.fg);
|
||||||
break;
|
break;
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
luaA_pushcolor(L, &(*wibox)->sw.ctx.bg);
|
luaA_pushcolor(L, &wibox->sw.ctx.bg);
|
||||||
break;
|
break;
|
||||||
case A_TK_BG_IMAGE:
|
case A_TK_BG_IMAGE:
|
||||||
image_push(L, (*wibox)->bg_image);
|
image_push(L, wibox->bg_image);
|
||||||
break;
|
break;
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
lua_pushstring(L, position_tostr((*wibox)->position));
|
lua_pushstring(L, position_tostr(wibox->position));
|
||||||
break;
|
break;
|
||||||
case A_TK_ONTOP:
|
case A_TK_ONTOP:
|
||||||
lua_pushboolean(L, (*wibox)->ontop);
|
lua_pushboolean(L, wibox->ontop);
|
||||||
break;
|
break;
|
||||||
case A_TK_ORIENTATION:
|
case A_TK_ORIENTATION:
|
||||||
lua_pushstring(L, orientation_tostr((*wibox)->sw.orientation));
|
lua_pushstring(L, orientation_tostr(wibox->sw.orientation));
|
||||||
break;
|
break;
|
||||||
case A_TK_WIDGETS:
|
case A_TK_WIDGETS:
|
||||||
if((*wibox)->widgets_table != LUA_REFNIL)
|
if(wibox->widgets_table != LUA_REFNIL)
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, wibox->widgets_table);
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
break;
|
break;
|
||||||
case A_TK_CURSOR:
|
case A_TK_CURSOR:
|
||||||
lua_pushstring(L, (*wibox)->cursor);
|
lua_pushstring(L, wibox->cursor);
|
||||||
break;
|
break;
|
||||||
case A_TK_OPACITY:
|
case A_TK_OPACITY:
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
if ((d = window_opacity_get((*wibox)->sw.window)) >= 0)
|
if ((d = window_opacity_get(wibox->sw.window)) >= 0)
|
||||||
lua_pushnumber(L, d);
|
lua_pushnumber(L, d);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_MOUSE_ENTER:
|
case A_TK_MOUSE_ENTER:
|
||||||
if((*wibox)->mouse_enter != LUA_REFNIL)
|
if(wibox->mouse_enter != LUA_REFNIL)
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->mouse_enter);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, wibox->mouse_enter);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
case A_TK_MOUSE_LEAVE:
|
case A_TK_MOUSE_LEAVE:
|
||||||
if((*wibox)->mouse_leave != LUA_REFNIL)
|
if(wibox->mouse_leave != LUA_REFNIL)
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->mouse_leave);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, wibox->mouse_leave);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -928,37 +926,37 @@ luaA_wibox_index(lua_State *L)
|
||||||
static int
|
static int
|
||||||
luaA_wibox_geometry(lua_State *L)
|
luaA_wibox_geometry(lua_State *L)
|
||||||
{
|
{
|
||||||
wibox_t **wibox = luaA_checkudata(L, 1, "wibox");
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
||||||
|
|
||||||
if(lua_gettop(L) == 2)
|
if(lua_gettop(L) == 2)
|
||||||
{
|
{
|
||||||
area_t wingeom;
|
area_t wingeom;
|
||||||
|
|
||||||
luaA_checktable(L, 2);
|
luaA_checktable(L, 2);
|
||||||
wingeom.x = luaA_getopt_number(L, 2, "x", (*wibox)->sw.geometry.x);
|
wingeom.x = luaA_getopt_number(L, 2, "x", wibox->sw.geometry.x);
|
||||||
wingeom.y = luaA_getopt_number(L, 2, "y", (*wibox)->sw.geometry.y);
|
wingeom.y = luaA_getopt_number(L, 2, "y", wibox->sw.geometry.y);
|
||||||
wingeom.width = luaA_getopt_number(L, 2, "width", (*wibox)->sw.geometry.width);
|
wingeom.width = luaA_getopt_number(L, 2, "width", wibox->sw.geometry.width);
|
||||||
wingeom.height = luaA_getopt_number(L, 2, "height", (*wibox)->sw.geometry.height);
|
wingeom.height = luaA_getopt_number(L, 2, "height", wibox->sw.geometry.height);
|
||||||
|
|
||||||
switch((*wibox)->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
wibox_resize(*wibox, wingeom.width, wingeom.height);
|
wibox_resize(wibox, wingeom.width, wingeom.height);
|
||||||
break;
|
break;
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
if((*wibox)->position == Floating)
|
if(wibox->position == Floating)
|
||||||
wibox_moveresize(*wibox, wingeom);
|
wibox_moveresize(wibox, wingeom);
|
||||||
else if(wingeom.width != (*wibox)->sw.geometry.width
|
else if(wingeom.width != wibox->sw.geometry.width
|
||||||
|| wingeom.height != (*wibox)->sw.geometry.height)
|
|| wingeom.height != wibox->sw.geometry.height)
|
||||||
{
|
{
|
||||||
wibox_resize(*wibox, wingeom.width, wingeom.height);
|
wibox_resize(wibox, wingeom.width, wingeom.height);
|
||||||
globalconf.screens[(*wibox)->screen].need_arrange = true;
|
globalconf.screens[wibox->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return luaA_pusharea(L, (*wibox)->sw.geometry);
|
return luaA_pusharea(L, wibox->sw.geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wibox newindex.
|
/** Wibox newindex.
|
||||||
|
@ -969,7 +967,7 @@ static int
|
||||||
luaA_wibox_newindex(lua_State *L)
|
luaA_wibox_newindex(lua_State *L)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
wibox_t **wibox = luaA_checkudata(L, 1, "wibox");
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
||||||
const char *buf, *attr = luaL_checklstring(L, 2, &len);
|
const char *buf, *attr = luaL_checklstring(L, 2, &len);
|
||||||
awesome_token_t tok;
|
awesome_token_t tok;
|
||||||
|
|
||||||
|
@ -979,51 +977,52 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
|
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.ctx.fg, buf, len)))
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->sw.ctx.fg, buf, len)))
|
||||||
(*wibox)->need_update = true;
|
wibox->need_update = true;
|
||||||
break;
|
break;
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.ctx.bg, buf, len)))
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->sw.ctx.bg, buf, len)))
|
||||||
(*wibox)->need_update = true;
|
wibox->need_update = true;
|
||||||
break;
|
break;
|
||||||
case A_TK_BG_IMAGE:
|
case A_TK_BG_IMAGE:
|
||||||
image_unref(L, (*wibox)->bg_image);
|
image_unref(L, wibox->bg_image);
|
||||||
(*wibox)->bg_image = image_ref(L);
|
wibox->bg_image = image_ref(L);
|
||||||
(*wibox)->need_update = true;
|
wibox->need_update = true;
|
||||||
break;
|
break;
|
||||||
case A_TK_ALIGN:
|
case A_TK_ALIGN:
|
||||||
buf = luaL_checklstring(L, 3, &len);
|
buf = luaL_checklstring(L, 3, &len);
|
||||||
(*wibox)->align = draw_align_fromstr(buf, len);
|
wibox->align = draw_align_fromstr(buf, len);
|
||||||
switch((*wibox)->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
wibox_position_update(*wibox);
|
wibox_position_update(wibox);
|
||||||
break;
|
break;
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
titlebar_update_geometry(client_getbytitlebar(*wibox));
|
titlebar_update_geometry(client_getbytitlebar(wibox));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
switch((*wibox)->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
return luaA_titlebar_newindex(L, *wibox, tok);
|
return luaA_titlebar_newindex(L, wibox, tok);
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
wibox_setposition(*wibox, position_fromstr(buf, len));
|
wibox_setposition(wibox, position_fromstr(buf, len));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_CLIENT:
|
case A_TK_CLIENT:
|
||||||
/* first detach */
|
/* first detach */
|
||||||
if(lua_isnil(L, 3))
|
if(lua_isnil(L, 3))
|
||||||
titlebar_client_detach(client_getbytitlebar(*wibox));
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
client_t *c = luaA_client_checkudata(L, -1);
|
client_t *c = luaA_client_checkudata(L, -1);
|
||||||
titlebar_client_attach(c, *wibox);
|
lua_pushvalue(L, 1);
|
||||||
|
titlebar_client_attach(c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_CURSOR:
|
case A_TK_CURSOR:
|
||||||
|
@ -1033,60 +1032,61 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
if(cursor_font)
|
if(cursor_font)
|
||||||
{
|
{
|
||||||
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
|
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
|
||||||
p_delete(&(*wibox)->cursor);
|
p_delete(&wibox->cursor);
|
||||||
(*wibox)->cursor = a_strdup(buf);
|
wibox->cursor = a_strdup(buf);
|
||||||
simplewindow_cursor_set(&(*wibox)->sw, cursor);
|
simplewindow_cursor_set(&wibox->sw, cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_SCREEN:
|
case A_TK_SCREEN:
|
||||||
if(lua_isnil(L, 3))
|
if(lua_isnil(L, 3))
|
||||||
{
|
{
|
||||||
wibox_detach(*wibox);
|
wibox_detach(wibox);
|
||||||
titlebar_client_detach(client_getbytitlebar(*wibox));
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int screen = luaL_checknumber(L, 3) - 1;
|
int screen = luaL_checknumber(L, 3) - 1;
|
||||||
luaA_checkscreen(screen);
|
luaA_checkscreen(screen);
|
||||||
if(screen != (*wibox)->screen)
|
if(screen != wibox->screen)
|
||||||
{
|
{
|
||||||
titlebar_client_detach(client_getbytitlebar(*wibox));
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
||||||
wibox_attach(*wibox, &globalconf.screens[screen]);
|
lua_pushvalue(L, 1);
|
||||||
|
wibox_attach(&globalconf.screens[screen]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_ONTOP:
|
case A_TK_ONTOP:
|
||||||
b = luaA_checkboolean(L, 3);
|
b = luaA_checkboolean(L, 3);
|
||||||
if(b != (*wibox)->ontop)
|
if(b != wibox->ontop)
|
||||||
{
|
{
|
||||||
(*wibox)->ontop = b;
|
wibox->ontop = b;
|
||||||
client_stack();
|
client_stack();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_ORIENTATION:
|
case A_TK_ORIENTATION:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
{
|
{
|
||||||
simplewindow_orientation_set(&(*wibox)->sw, orientation_fromstr(buf, len));
|
simplewindow_orientation_set(&wibox->sw, orientation_fromstr(buf, len));
|
||||||
wibox_need_update(*wibox);
|
wibox_need_update(wibox);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_COLOR:
|
case A_TK_BORDER_COLOR:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.border.color, buf, len)))
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->sw.border.color, buf, len)))
|
||||||
if((*wibox)->sw.window)
|
if(wibox->sw.window)
|
||||||
simplewindow_border_color_set(&(*wibox)->sw, &(*wibox)->sw.border.color);
|
simplewindow_border_color_set(&wibox->sw, &wibox->sw.border.color);
|
||||||
break;
|
break;
|
||||||
case A_TK_VISIBLE:
|
case A_TK_VISIBLE:
|
||||||
b = luaA_checkboolean(L, 3);
|
b = luaA_checkboolean(L, 3);
|
||||||
if(b != (*wibox)->isvisible)
|
if(b != wibox->isvisible)
|
||||||
switch((*wibox)->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
wibox_setvisible(*wibox, b);
|
wibox_setvisible(wibox, b);
|
||||||
break;
|
break;
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
titlebar_set_visible(*wibox, b);
|
titlebar_set_visible(wibox, b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1097,34 +1097,34 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* register object */
|
/* register object */
|
||||||
luaA_register(L, 3, &(*wibox)->widgets_table);
|
luaA_register(L, 3, &wibox->widgets_table);
|
||||||
/* duplicate table because next function will eat it */
|
/* duplicate table because next function will eat it */
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
/* recompute widget node list */
|
/* recompute widget node list */
|
||||||
wibox_widgets_table_build(L, *wibox);
|
wibox_widgets_table_build(L, wibox);
|
||||||
luaA_table2wtable(L);
|
luaA_table2wtable(L);
|
||||||
break;
|
break;
|
||||||
case A_TK_OPACITY:
|
case A_TK_OPACITY:
|
||||||
if(lua_isnil(L, 3))
|
if(lua_isnil(L, 3))
|
||||||
window_opacity_set((*wibox)->sw.window, -1);
|
window_opacity_set(wibox->sw.window, -1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double d = luaL_checknumber(L, 3);
|
double d = luaL_checknumber(L, 3);
|
||||||
if(d >= 0 && d <= 1)
|
if(d >= 0 && d <= 1)
|
||||||
window_opacity_set((*wibox)->sw.window, d);
|
window_opacity_set(wibox->sw.window, d);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_MOUSE_ENTER:
|
case A_TK_MOUSE_ENTER:
|
||||||
luaA_registerfct(L, 3, &(*wibox)->mouse_enter);
|
luaA_registerfct(L, 3, &wibox->mouse_enter);
|
||||||
return 0;
|
return 0;
|
||||||
case A_TK_MOUSE_LEAVE:
|
case A_TK_MOUSE_LEAVE:
|
||||||
luaA_registerfct(L, 3, &(*wibox)->mouse_leave);
|
luaA_registerfct(L, 3, &wibox->mouse_leave);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
switch((*wibox)->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
return luaA_titlebar_newindex(L, *wibox, tok);
|
return luaA_titlebar_newindex(L, wibox, tok);
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1143,8 +1143,8 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
static int
|
static int
|
||||||
luaA_wibox_buttons(lua_State *L)
|
luaA_wibox_buttons(lua_State *L)
|
||||||
{
|
{
|
||||||
wibox_t **wibox = luaA_checkudata(L, 1, "wibox");
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
||||||
button_array_t *buttons = &(*wibox)->buttons;
|
button_array_t *buttons = &wibox->buttons;
|
||||||
|
|
||||||
if(lua_gettop(L) == 2)
|
if(lua_gettop(L) == 2)
|
||||||
{
|
{
|
||||||
|
@ -1167,7 +1167,6 @@ const struct luaL_reg awesome_wibox_meta[] =
|
||||||
{ "__index", luaA_wibox_index },
|
{ "__index", luaA_wibox_index },
|
||||||
{ "__newindex", luaA_wibox_newindex },
|
{ "__newindex", luaA_wibox_newindex },
|
||||||
{ "__gc", luaA_wibox_gc },
|
{ "__gc", luaA_wibox_gc },
|
||||||
{ "__eq", luaA_wibox_eq },
|
|
||||||
{ "__tostring", luaA_wibox_tostring },
|
{ "__tostring", luaA_wibox_tostring },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
10
wibox.h
10
wibox.h
|
@ -28,15 +28,13 @@
|
||||||
void wibox_refresh(void);
|
void wibox_refresh(void);
|
||||||
void wibox_update_positions(void);
|
void wibox_update_positions(void);
|
||||||
|
|
||||||
int luaA_wibox_new(lua_State *);
|
|
||||||
int luaA_wibox_userdata_new(lua_State *, wibox_t *);
|
|
||||||
void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
||||||
|
|
||||||
void wibox_position_update(wibox_t *);
|
void wibox_position_update(wibox_t *);
|
||||||
wibox_t * wibox_getbywin(xcb_window_t);
|
wibox_t * wibox_getbywin(xcb_window_t);
|
||||||
void wibox_detach(wibox_t *);
|
void wibox_detach(wibox_t *);
|
||||||
void wibox_attach(wibox_t *, screen_t *);
|
|
||||||
void wibox_delete(wibox_t **);
|
void wibox_unref_simplified(wibox_t **);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
wibox_moveresize(wibox_t *wibox, area_t geometry)
|
wibox_moveresize(wibox_t *wibox, area_t geometry)
|
||||||
|
@ -56,8 +54,8 @@ wibox_moveresize(wibox_t *wibox, area_t geometry)
|
||||||
wibox->need_update = true;
|
wibox->need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DO_RCNT(wibox_t, wibox, wibox_delete)
|
LUA_OBJECT_FUNCS(wibox_t, wibox, "wibox")
|
||||||
ARRAY_FUNCS(wibox_t *, wibox, wibox_unref)
|
ARRAY_FUNCS(wibox_t *, wibox, wibox_unref_simplified)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
12
widget.c
12
widget.c
|
@ -300,17 +300,13 @@ widget_render(wibox_t *wibox)
|
||||||
void
|
void
|
||||||
widget_invalidate_bytype(int screen, widget_constructor_t *type)
|
widget_invalidate_bytype(int screen, widget_constructor_t *type)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
|
foreach(wibox, globalconf.screens[screen].wiboxes)
|
||||||
|
foreach(wnode, (*wibox)->widgets)
|
||||||
|
if(wnode->widget->type == type)
|
||||||
{
|
{
|
||||||
wibox_t *wibox = globalconf.screens[screen].wiboxes.tab[i];
|
(*wibox)->need_update = true;
|
||||||
|
|
||||||
for(int j = 0; j < wibox->widgets.len; j++)
|
|
||||||
if(wibox->widgets.tab[j].widget->type == type)
|
|
||||||
{
|
|
||||||
wibox->need_update = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a wibox needs update because it has widget, or redraw a titlebar.
|
/** Set a wibox needs update because it has widget, or redraw a titlebar.
|
||||||
|
|
Loading…
Reference in New Issue