From 0feb7de68e55db3d4958170835614724ae953654 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 21 Sep 2008 20:39:23 +0200 Subject: [PATCH] wibox: merge statusbars and titlebars Lua objects Signed-off-by: Julien Danjou --- awesomerc.lua.in | 4 +- client.c | 28 +---- event.c | 16 +-- lib/awful.lua.in | 4 +- luaa.c | 23 +--- luaa.h | 8 -- statusbar.c | 240 +++++++----------------------------- statusbar.h | 4 +- structs.h | 14 ++- swindow.c | 3 + titlebar.c | 238 ++++++++--------------------------- titlebar.h | 4 +- wibox.c | 279 ++++++++++++++++++++++++++++++++++++++++++ wibox.h | 3 + widget.c | 21 ++-- widget.h | 4 +- widgets/graph.c | 4 +- widgets/imagebox.c | 3 +- widgets/progressbar.c | 4 +- widgets/systray.c | 6 +- widgets/taglist.c | 12 +- widgets/tasklist.c | 12 +- widgets/textbox.c | 4 +- 23 files changed, 447 insertions(+), 491 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 5330f55b..4868331b 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -144,8 +144,8 @@ end -- Create a statusbar for each screen and add it mystatusbar = {} for s = 1, screen.count() do - mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s, - fg = beautiful.fg_normal, bg = beautiful.bg_normal }) + mystatusbar[s] = wibox({ position = "top", name = "mystatusbar" .. s, + fg = beautiful.fg_normal, bg = beautiful.bg_normal }) -- Add widgets to the statusbar - order matters mystatusbar[s]:widgets({ mytaglist, diff --git a/client.c b/client.c index 756486b8..fcabb1fa 100644 --- a/client.c +++ b/client.c @@ -1281,29 +1281,13 @@ luaA_client_newindex(lua_State *L) XCB_CW_BORDER_PIXEL, &(*c)->border_color.pixel); break; case A_TK_TITLEBAR: - if(!lua_isnil(L, 3)) + if(lua_isnil(L, 3)) + titlebar_client_detach(*c); + else { - t = luaA_checkudata(L, 3, "titlebar"); - if(client_getbytitlebar(*t)) - luaL_error(L, "titlebar is already used by another client"); + t = luaA_checkudata(L, 3, "wibox"); + titlebar_client_attach(*c, *t); } - - /* If client had a titlebar, unref it */ - if((*c)->titlebar) - { - xcb_unmap_window(globalconf.connection, (*c)->titlebar->sw.window); - wibox_unref(&(*c)->titlebar); - (*c)->titlebar = NULL; - client_need_arrange(*c); - } - - if(t) - { - /* Attach titlebar to client */ - (*c)->titlebar = wibox_ref(t); - titlebar_init(*c); - } - client_stack(); break; default: return 0; @@ -1482,7 +1466,7 @@ luaA_client_index(lua_State *L) break; case A_TK_TITLEBAR: if((*c)->titlebar) - return luaA_titlebar_userdata_new(L, (*c)->titlebar); + return luaA_wibox_userdata_new(L, (*c)->titlebar); return 0; case A_TK_URGENT: lua_pushboolean(L, (*c)->isurgent); diff --git a/event.c b/event.c index 7bd6dd1b..e2975f6a 100644 --- a/event.c +++ b/event.c @@ -154,7 +154,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e statusbar->sw.geometry.width, statusbar->sw.geometry.height, &ev->event_x, &ev->event_y))) - w->widget->button(w, ev, statusbar->screen, statusbar, AWESOME_TYPE_STATUSBAR); + w->widget->button(w, ev, statusbar->screen, statusbar); /* return even if no widget match */ return 0; } @@ -165,7 +165,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e if((w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets, c->titlebar->width, c->titlebar->height, &ev->event_x, &ev->event_y))) - w->widget->button(w, ev, c->screen, c->titlebar, AWESOME_TYPE_TITLEBAR); + w->widget->button(w, ev, c->screen, c->titlebar); /* return even if no widget match */ return 0; } @@ -343,13 +343,11 @@ event_handle_destroynotify(void *data __attribute__ ((unused)), /** Handle a motion notify over widgets. * \param object The object. - * \param type The object type. * \param mouse_over The pointer to the registered mouse over widget. * \param w The new widget the mouse is over. */ static void event_handle_widget_motionnotify(void *object, - awesome_type_t type, widget_node_t **mouse_over, widget_node_t *w) { @@ -358,14 +356,14 @@ event_handle_widget_motionnotify(void *object, if(*mouse_over) { /* call mouse leave function on old widget */ - luaA_pushpointer(globalconf.L, object, type); + luaA_wibox_userdata_new(globalconf.L, object); luaA_dofunction(globalconf.L, (*mouse_over)->widget->mouse_leave, 1, 0); } if(w) { /* call mouse enter function on new widget and register it */ *mouse_over = w; - luaA_pushpointer(globalconf.L, object, type); + luaA_wibox_userdata_new(globalconf.L, object); luaA_dofunction(globalconf.L, w->widget->mouse_enter, 1, 0); } } @@ -392,7 +390,6 @@ event_handle_motionnotify(void *data __attribute__ ((unused)), statusbar->sw.geometry.height, &ev->event_x, &ev->event_y); event_handle_widget_motionnotify(statusbar, - AWESOME_TYPE_STATUSBAR, &statusbar->mouse_over, w); } else if((c = client_getbytitlebarwin(ev->event))) @@ -402,7 +399,6 @@ event_handle_motionnotify(void *data __attribute__ ((unused)), c->titlebar->sw.geometry.height, &ev->event_x, &ev->event_y); event_handle_widget_motionnotify(c->titlebar, - AWESOME_TYPE_TITLEBAR, &c->titlebar->mouse_over, w); } @@ -427,7 +423,7 @@ event_handle_leavenotify(void *data __attribute__ ((unused)), if(statusbar->mouse_over) { /* call mouse leave function on widget the mouse was over */ - luaA_statusbar_userdata_new(globalconf.L, statusbar); + luaA_wibox_userdata_new(globalconf.L, statusbar); luaA_dofunction(globalconf.L, statusbar->mouse_over->widget->mouse_leave, 1, 0); } } @@ -436,7 +432,7 @@ event_handle_leavenotify(void *data __attribute__ ((unused)), if(c->titlebar->mouse_over) { /* call mouse leave function on widget the mouse was over */ - luaA_titlebar_userdata_new(globalconf.L, c->titlebar); + luaA_wibox_userdata_new(globalconf.L, c->titlebar); luaA_dofunction(globalconf.L, c->titlebar->mouse_over->widget->mouse_leave, 1, 0); } } diff --git a/lib/awful.lua.in b/lib/awful.lua.in index fa8af05b..2ab0806e 100644 --- a/lib/awful.lua.in +++ b/lib/awful.lua.in @@ -24,7 +24,7 @@ local capi = client = client, mouse = mouse, button = button, - titlebar = titlebar, + wibox = wibox, widget = widget, hooks = hooks, keygrabber = keygrabber @@ -1526,7 +1526,7 @@ function titlebar.add(c, args) local targs = {} if args.fg then targs.fg = args.fg end if args.bg then targs.bg = args.bg end - local tb = capi.titlebar(targs) + local tb = capi.wibox(targs) local title = capi.widget({ type = "textbox", name = "title", align = "flex" }) local bts = diff --git a/luaa.c b/luaa.c index 32783fae..f2276f7b 100644 --- a/luaa.c +++ b/luaa.c @@ -74,6 +74,8 @@ extern const struct luaL_reg awesome_widget_methods[]; extern const struct luaL_reg awesome_widget_meta[]; extern const struct luaL_reg awesome_statusbar_methods[]; extern const struct luaL_reg awesome_statusbar_meta[]; +extern const struct luaL_reg awesome_wibox_methods[]; +extern const struct luaL_reg awesome_wibox_meta[]; extern const struct luaL_reg awesome_keybinding_methods[]; extern const struct luaL_reg awesome_keybinding_meta[]; @@ -363,24 +365,6 @@ luaA_colors(lua_State *L) return 1; } -/** Push a pointer onto the stack according to its type. - * \param p The pointer. - * \param type Its type. - */ -void -luaA_pushpointer(lua_State *L, void *p, awesome_type_t type) -{ - switch(type) - { - case AWESOME_TYPE_STATUSBAR: - luaA_statusbar_userdata_new(L, p); - break; - case AWESOME_TYPE_TITLEBAR: - luaA_titlebar_userdata_new(L, p); - break; - } -} - static void luaA_openlib(lua_State *L, const char *name, const struct luaL_reg methods[], @@ -661,6 +645,9 @@ luaA_init(void) /* Export statusbar */ luaA_openlib(L, "statusbar", awesome_statusbar_methods, awesome_statusbar_meta); + /* Export wibox */ + luaA_openlib(L, "wibox", awesome_wibox_methods, awesome_wibox_meta); + /* Export widget */ luaA_openlib(L, "widget", awesome_widget_methods, awesome_widget_meta); diff --git a/luaa.h b/luaa.h index 2d926455..1e391eb1 100644 --- a/luaa.h +++ b/luaa.h @@ -29,13 +29,6 @@ #include "draw.h" #include "common/util.h" -/** Object types */ -typedef enum -{ - AWESOME_TYPE_STATUSBAR = 1, - AWESOME_TYPE_TITLEBAR -} awesome_type_t; - /** Type for Lua function */ typedef int luaA_ref; @@ -263,7 +256,6 @@ luaA_otable_new(lua_State *L) void luaA_init(void); void luaA_parserc(const char *); -void luaA_pushpointer(lua_State *, void *, awesome_type_t); void luaA_cs_init(void); void luaA_cs_cleanup(void); void luaA_on_timer(EV_P_ ev_timer *w, int revents); diff --git a/statusbar.c b/statusbar.c index 698c8a9e..85d39477 100644 --- a/statusbar.c +++ b/statusbar.c @@ -30,10 +30,6 @@ extern awesome_t globalconf; -DO_LUA_NEW(extern, wibox_t, statusbar, "statusbar", wibox_ref) -DO_LUA_GC(wibox_t, statusbar, "statusbar", wibox_unref) -DO_LUA_EQ(wibox_t, statusbar, "statusbar") - /** Kick out systray windows. * \param phys_screen Physical screen number. */ @@ -226,7 +222,7 @@ statusbar_draw(wibox_t *statusbar) statusbar->sw.pixmap, statusbar->screen, statusbar->position, statusbar->sw.geometry.x, statusbar->sw.geometry.y, - statusbar, AWESOME_TYPE_STATUSBAR); + statusbar); simplewindow_refresh_pixmap(&statusbar->sw); } @@ -453,6 +449,7 @@ statusbar_position_update(wibox_t *statusbar) wingeometry.width, wingeometry.height, 0, statusbar->position, &statusbar->colors.fg, &statusbar->colors.bg); + statusbar->need_update = true; xcb_map_window(globalconf.connection, statusbar->sw.window); } /* same window size and position ? */ @@ -474,21 +471,7 @@ statusbar_position_update(wibox_t *statusbar) globalconf.screens[statusbar->screen].need_arrange = true; } -/** Convert a statusbar to a printable string. - * \param L The Lua VM state. - * - * \luastack - * \lvalue A statusbar. - */ -static int -luaA_statusbar_tostring(lua_State *L) -{ - wibox_t **p = luaA_checkudata(L, 1, "statusbar"); - lua_pushfstring(L, "[statusbar udata(%p)]", *p); - return 1; -} - -/** Create a new statusbar. +/** Create a new statusbar (DEPRECATED). * \param L The Lua VM state. * * \luastack @@ -499,117 +482,16 @@ luaA_statusbar_tostring(lua_State *L) static int luaA_statusbar_new(lua_State *L) { - wibox_t *sb; - const char *buf; - size_t len; - xcolor_init_request_t reqs[2]; - int8_t i, reqs_nbr = -1; + deprecate(); - luaA_checktable(L, 2); - - sb = p_new(wibox_t, 1); - - sb->colors.fg = globalconf.colors.fg; - if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&sb->colors.fg, buf, len); - - sb->colors.bg = globalconf.colors.bg; - if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&sb->colors.bg, buf, len); - - buf = luaA_getopt_lstring(L, 2, "align", "left", &len); - sb->align = draw_align_fromstr(buf, len); - - sb->width = luaA_getopt_number(L, 2, "width", 0); - sb->height = luaA_getopt_number(L, 2, "height", 0); - if(sb->height <= 0) - /* 1.5 as default factor, it fits nice but no one knows why */ - sb->height = 1.5 * globalconf.font->height; - - buf = luaA_getopt_lstring(L, 2, "position", "top", &len); - sb->position = position_fromstr(buf, len); - - sb->screen = SCREEN_UNDEF; - - for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(reqs[i]); - - return luaA_statusbar_userdata_new(L, sb); -} - -/** Statusbar object. - * \param L The Lua VM state. - * \return The number of elements pushed on stack. - * \luastack - * \lfield screen Screen number. - * \lfield align The alignment. - * \lfield fg Foreground color. - * \lfield bg Background color. - * \lfield position The position. - */ -static int -luaA_statusbar_index(lua_State *L) -{ - size_t len; - wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar"); - const char *attr = luaL_checklstring(L, 2, &len); - - if(luaA_usemetatable(L, 1, 2)) - return 1; - - switch(a_tokenize(attr, len)) - { - case A_TK_SCREEN: - if((*statusbar)->screen == SCREEN_UNDEF) - return 0; - lua_pushnumber(L, (*statusbar)->screen + 1); - break; - case A_TK_ALIGN: - lua_pushstring(L, draw_align_tostr((*statusbar)->align)); - break; - case A_TK_FG: - luaA_pushcolor(L, &(*statusbar)->colors.fg); - break; - case A_TK_BG: - luaA_pushcolor(L, &(*statusbar)->colors.bg); - break; - case A_TK_POSITION: - lua_pushstring(L, position_tostr((*statusbar)->position)); - break; - default: - return 0; - } - - return 1; -} - -/** Get or set the statusbar widgets. - * \param L The Lua VM state. - * \return The number of elements pushed on stack. - * \luastack - * \lparam None, or a table of widgets to set. - * \lreturn The current statusbar widgets. -*/ -static int -luaA_statusbar_widgets(lua_State *L) -{ - wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar"); - - if(lua_gettop(L) == 2) - { - luaA_widget_set(L, 2, *statusbar, &(*statusbar)->widgets); - (*statusbar)->need_update = true; - (*statusbar)->mouse_over = NULL; - return 1; - } - return luaA_widget_get(L, (*statusbar)->widgets); + return luaA_wibox_new(L); } /** Remove a statubar from a screen. * \param statusbar Statusbar to detach from screen. */ -static void -statusbar_remove(wibox_t *statusbar) +void +statusbar_detach(wibox_t *statusbar) { if(statusbar->screen != SCREEN_UNDEF) { @@ -623,8 +505,6 @@ statusbar_remove(wibox_t *statusbar) statusbar->position = p; simplewindow_wipe(&statusbar->sw); - /* sw.window is used to now if the window has been init or not */ - statusbar->sw.window = 0; for(int i = 0; i < globalconf.screens[statusbar->screen].statusbars.len; i++) if(globalconf.screens[statusbar->screen].statusbars.tab[i] == statusbar) @@ -634,91 +514,69 @@ statusbar_remove(wibox_t *statusbar) } globalconf.screens[statusbar->screen].need_arrange = true; statusbar->screen = SCREEN_UNDEF; + statusbar->type = WIBOX_TYPE_NONE; wibox_unref(&statusbar); } } +/** Attach a statusbar. + * \param statusbar The statusbar to attach. + * \param s The screen to attach the statusbar to. + */ +void +statusbar_attach(wibox_t *statusbar, screen_t *s) +{ + statusbar_detach(statusbar); + + statusbar->screen = s->index; + + wibox_array_append(&s->statusbars, wibox_ref(&statusbar)); + + statusbar->type = WIBOX_TYPE_STATUSBAR; + + /* All the other statusbar and ourselves need to be repositioned */ + for(int i = 0; i < s->statusbars.len; i++) + statusbar_position_update(s->statusbars.tab[i]); + + ewmh_update_workarea(screen_virttophys(s->index)); +} + /** Statusbar newindex. * \param L The Lua VM state. + * \param statusbar The wibox statusbar. + * \param tok The token for property. * \return The number of elements pushed on stack. */ -static int -luaA_statusbar_newindex(lua_State *L) +int +luaA_statusbar_newindex(lua_State *L, wibox_t *statusbar, awesome_token_t tok) { size_t len; - wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar"); - const char *buf, *attr = luaL_checklstring(L, 2, &len); + const char *buf; position_t p; - int screen; - switch(a_tokenize(attr, len)) + switch(tok) { - case A_TK_SCREEN: - if(lua_isnil(L, 3)) - statusbar_remove(*statusbar); - else - { - screen = luaL_checknumber(L, 3) - 1; - - luaA_checkscreen(screen); - - if((*statusbar)->screen == screen) - luaL_error(L, "this statusbar is already on screen %d", - (*statusbar)->screen + 1); - - statusbar_remove(*statusbar); - - (*statusbar)->screen = screen; - - wibox_array_append(&globalconf.screens[screen].statusbars, wibox_ref(statusbar)); - - /* All the other statusbar and ourselves need to be repositioned */ - for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++) - { - wibox_t *s = globalconf.screens[screen].statusbars.tab[i]; - statusbar_position_update(s); - } - - ewmh_update_workarea(screen_virttophys(screen)); - } - break; case A_TK_ALIGN: buf = luaL_checklstring(L, 3, &len); - (*statusbar)->align = draw_align_fromstr(buf, len); - statusbar_position_update(*statusbar); - break; - case A_TK_FG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&(*statusbar)->colors.fg, buf, len))) - { - (*statusbar)->sw.ctx.fg = (*statusbar)->colors.fg; - (*statusbar)->need_update = true; - } - break; - case A_TK_BG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&(*statusbar)->colors.bg, buf, len))) - { - (*statusbar)->sw.ctx.bg = (*statusbar)->colors.bg; - (*statusbar)->need_update = true; - } + statusbar->align = draw_align_fromstr(buf, len); + statusbar_position_update(statusbar); break; case A_TK_POSITION: buf = luaL_checklstring(L, 3, &len); p = position_fromstr(buf, len); - if(p != (*statusbar)->position) + if(p != statusbar->position) { - (*statusbar)->position = p; - simplewindow_wipe(&(*statusbar)->sw); - (*statusbar)->sw.window = 0; - if((*statusbar)->screen != SCREEN_UNDEF) + statusbar->position = p; + simplewindow_wipe(&statusbar->sw); + statusbar->sw.window = 0; + if(statusbar->screen != SCREEN_UNDEF) { - for(int i = 0; i < globalconf.screens[(*statusbar)->screen].statusbars.len; i++) + for(int i = 0; i < globalconf.screens[statusbar->screen].statusbars.len; i++) { - wibox_t *s = globalconf.screens[(*statusbar)->screen].statusbars.tab[i]; + wibox_t *s = globalconf.screens[statusbar->screen].statusbars.tab[i]; statusbar_position_update(s); } - ewmh_update_workarea(screen_virttophys((*statusbar)->screen)); + ewmh_update_workarea(screen_virttophys(statusbar->screen)); } } break; @@ -736,12 +594,6 @@ const struct luaL_reg awesome_statusbar_methods[] = }; const struct luaL_reg awesome_statusbar_meta[] = { - { "widgets", luaA_statusbar_widgets }, - { "__index", luaA_statusbar_index }, - { "__newindex", luaA_statusbar_newindex }, - { "__gc", luaA_statusbar_gc }, - { "__eq", luaA_statusbar_eq }, - { "__tostring", luaA_statusbar_tostring }, { NULL, NULL }, }; diff --git a/statusbar.h b/statusbar.h index 83f20e07..abf8b890 100644 --- a/statusbar.h +++ b/statusbar.h @@ -29,8 +29,10 @@ wibox_t * statusbar_getbywin(xcb_window_t); void statusbar_refresh(void); void statusbar_position_update(wibox_t *); +void statusbar_detach(wibox_t *); +void statusbar_attach(wibox_t *, screen_t *); -int luaA_statusbar_userdata_new(lua_State *, wibox_t *); +int luaA_statusbar_newindex(lua_State *, wibox_t *, awesome_token_t); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/structs.h b/structs.h index 12e695de..4fae841f 100644 --- a/structs.h +++ b/structs.h @@ -59,6 +59,14 @@ typedef enum WINDOW_TYPE_DIALOG, } window_type_t; +/** Wibox types */ +typedef enum +{ + WIBOX_TYPE_NONE = 0, + WIBOX_TYPE_STATUSBAR, + WIBOX_TYPE_TITLEBAR +} wibox_type_t; + /** Cursors */ enum { @@ -82,6 +90,8 @@ typedef struct { /** Ref count */ int refcount; + /** Wibox type */ + wibox_type_t type; /** Window */ simple_window_t sw; /** Box width and height */ @@ -143,13 +153,13 @@ struct widget_t /** Widget detach function */ void (*detach)(widget_t *, wibox_t *); /** Draw function */ - int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *, awesome_type_t); + int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *); /** Index function */ int (*index)(lua_State *, awesome_token_t); /** Newindex function */ int (*newindex)(lua_State *, awesome_token_t); /** Button event handler */ - void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *, awesome_type_t); + void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *); /** Mouse over event handler */ luaA_ref mouse_enter, mouse_leave; /** Alignement */ diff --git a/swindow.c b/swindow.c index 75c8184c..1ae45ae1 100644 --- a/swindow.c +++ b/swindow.c @@ -112,8 +112,11 @@ void simplewindow_wipe(simple_window_t *sw) { xcb_destroy_window(globalconf.connection, sw->window); + sw->window = XCB_NONE; xcb_free_pixmap(globalconf.connection, sw->pixmap); + sw->pixmap = XCB_NONE; xcb_free_gc(globalconf.connection, sw->gc); + sw->gc = XCB_NONE; draw_context_wipe(&sw->ctx); } diff --git a/titlebar.c b/titlebar.c index 67fafc81..d483816c 100644 --- a/titlebar.c +++ b/titlebar.c @@ -28,10 +28,6 @@ extern awesome_t globalconf; -DO_LUA_NEW(extern, wibox_t, titlebar, "titlebar", wibox_ref) -DO_LUA_GC(wibox_t, titlebar, "titlebar", wibox_unref) -DO_LUA_EQ(wibox_t, titlebar, "titlebar") - /** Get a client by its titlebar. * \param titlebar The titlebar. * \return A client. @@ -77,7 +73,7 @@ titlebar_draw(client_t *c) c->titlebar->sw.gc, c->titlebar->sw.pixmap, c->screen, c->titlebar->position, c->titlebar->sw.geometry.x, c->titlebar->sw.geometry.y, - c->titlebar, AWESOME_TYPE_TITLEBAR); + c->titlebar); simplewindow_refresh_pixmap(&c->titlebar->sw); @@ -242,7 +238,7 @@ titlebar_init(client_t *c) c->titlebar->need_update = true; } -/** Create a new titlebar. +/** Create a new titlebar (DEPRECATED). * \param L The Lua VM state. * \return The number of value pushed. * @@ -254,128 +250,91 @@ titlebar_init(client_t *c) static int luaA_titlebar_new(lua_State *L) { - wibox_t *tb; - const char *buf; - size_t len; - xcolor_init_request_t reqs[3]; - int8_t i, reqs_nbr = -1; + deprecate(); - luaA_checktable(L, 2); + return luaA_wibox_new(L); +} - tb = p_new(wibox_t, 1); +/** Detach a wibox titlebar from its client. + * \param c The client. + */ +void +titlebar_client_detach(client_t *c) +{ + /* If client has a titlebar, kick it out. */ + if(c && c->titlebar) + { + wibox_unref(&c->titlebar); + simplewindow_wipe(&c->titlebar->sw); + c->titlebar->type = WIBOX_TYPE_NONE; + c->titlebar = NULL; + client_need_arrange(c); + client_stack(); + } +} - buf = luaA_getopt_lstring(L, 2, "align", "left", &len); - tb->align = draw_align_fromstr(buf, len); +/** Attach a wibox to a client as its titlebar. + * \param c The client. + * \param t The wibox/titlebar. + */ +void +titlebar_client_attach(client_t *c, wibox_t *t) +{ + titlebar_client_detach(c); - tb->width = luaA_getopt_number(L, 2, "width", 0); - tb->height = luaA_getopt_number(L, 2, "height", 0); - if(tb->height <= 0) - /* 1.5 as default factor, it fits nice but no one knows why */ - tb->height = 1.5 * globalconf.font->height; - - buf = luaA_getopt_lstring(L, 2, "position", "top", &len); - tb->position = position_fromstr(buf, len); - - tb->colors.fg = globalconf.colors.fg; - if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->colors.fg, buf, len); - - tb->colors.bg = globalconf.colors.bg; - if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->colors.bg, buf, len); - - tb->border.color = globalconf.colors.fg; - if((buf = luaA_getopt_lstring(L, 2, "border_color", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&tb->border.color, buf, len); - - tb->border.width = luaA_getopt_number(L, 2, "border_width", 0); - - for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(reqs[i]); - - return luaA_titlebar_userdata_new(globalconf.L, tb); + if(c && t) + { + /* check if titlebar is already on a client */ + titlebar_client_detach(client_getbytitlebar(t)); + c->titlebar = wibox_ref(&t); + t->type = WIBOX_TYPE_TITLEBAR; + titlebar_init(c); + client_need_arrange(c); + client_stack(); + } } /** Titlebar newindex. * \param L The Lua VM state. + * \param titlebar The wibox titlebar. + * \param tok The attribute token. * \return The number of elements pushed on stack. */ -static int -luaA_titlebar_newindex(lua_State *L) +int +luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok) { size_t len; - wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar"); - const char *buf, *attr = luaL_checklstring(L, 2, &len); + const char *buf; client_t *c = NULL; int i; position_t position; - switch(a_tokenize(attr, len)) + switch(tok) { - case A_TK_CLIENT: - if(!lua_isnil(L, 3)) - { - client_t **newc = luaA_checkudata(L, 3, "client"); - if((*newc)->titlebar) - { - xcb_unmap_window(globalconf.connection, (*newc)->titlebar->sw.window); - wibox_unref(&(*newc)->titlebar); - } - /* Attach titlebar to client */ - (*newc)->titlebar = wibox_ref(titlebar); - titlebar_init(*newc); - c = *newc; - } - else if((c = client_getbytitlebar(*titlebar))) - { - xcb_unmap_window(globalconf.connection, (*titlebar)->sw.window); - /* unref and NULL the ref */ - wibox_unref(&c->titlebar); - c->titlebar = NULL; - client_need_arrange(c); - } - client_stack(); - break; case A_TK_ALIGN: if((buf = luaL_checklstring(L, 3, &len))) - (*titlebar)->align = draw_align_fromstr(buf, len); + titlebar->align = draw_align_fromstr(buf, len); else return 0; break; case A_TK_BORDER_WIDTH: if((i = luaL_checknumber(L, 3)) >= 0) - (*titlebar)->border.width = i; + titlebar->border.width = i; else return 0; break; case A_TK_BORDER_COLOR: if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->border.color, buf, len))) + if(xcolor_init_reply(xcolor_init_unchecked(&titlebar->border.color, buf, len))) simplewindow_border_color_set(&c->titlebar->sw, &c->titlebar->border.color); return 0; - case A_TK_FG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->colors.fg, buf, len))) - { - (*titlebar)->sw.ctx.fg = (*titlebar)->colors.fg; - (*titlebar)->need_update = true; - } - return 0; - case A_TK_BG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&(*titlebar)->colors.bg, buf, len))) - { - (*titlebar)->sw.ctx.bg = (*titlebar)->colors.bg; - (*titlebar)->need_update = true; - } - break; case A_TK_POSITION: buf = luaL_checklstring(L, 3, &len); position = position_fromstr(buf, len); - if(position != (*titlebar)->position) + if(position != titlebar->position) { - (*titlebar)->position = position; - c = client_getbytitlebar(*titlebar); + titlebar->position = position; + c = client_getbytitlebar(titlebar); titlebar_init(c); } break; @@ -383,97 +342,12 @@ luaA_titlebar_newindex(lua_State *L) return 0; } - if((c || (c = client_getbytitlebar(*titlebar)))) + if((c || (c = client_getbytitlebar(titlebar)))) client_need_arrange(c); return 0; } -/** Titlebar object. - * \param L The Lua VM state. - * \return The number of elements pushed on stack. - * \luastack - * \lfield client The client attached to this titlebar. - * \lfield align Alignment relative to the client. - * \lfield border_width Border width. - * \lfield border_color Border color. - * \lfield fg Foreground color. - * \lfield bg Background color. - * \lfield position Position. - */ -static int -luaA_titlebar_index(lua_State *L) -{ - size_t len; - wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar"); - const char *attr = luaL_checklstring(L, 2, &len); - client_t *c; - - if(luaA_usemetatable(L, 1, 2)) - return 1; - - switch(a_tokenize(attr, len)) - { - case A_TK_CLIENT: - if((c = client_getbytitlebar(*titlebar))) - return luaA_client_userdata_new(L, c); - else - return 0; - case A_TK_ALIGN: - lua_pushstring(L, draw_align_tostr((*titlebar)->align)); - break; - case A_TK_BORDER_WIDTH: - lua_pushnumber(L, (*titlebar)->border.width); - break; - case A_TK_BORDER_COLOR: - luaA_pushcolor(L, &(*titlebar)->border.color); - break; - case A_TK_FG: - luaA_pushcolor(L, &(*titlebar)->colors.fg); - break; - case A_TK_BG: - luaA_pushcolor(L, &(*titlebar)->colors.bg); - break; - case A_TK_POSITION: - lua_pushstring(L, position_tostr((*titlebar)->position)); - break; - default: - return 0; - } - - return 1; -} - -static int -luaA_titlebar_widgets(lua_State *L) -{ - wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar"); - - if(lua_gettop(L) == 2) - { - luaA_widget_set(L, 2, *titlebar, &(*titlebar)->widgets); - (*titlebar)->need_update = true; - return 1; - } - return luaA_widget_get(L, (*titlebar)->widgets); -} - -/** Convert a titlebar to a printable string. - * \param L The Lua VM state. - * \return The number of value pushed. - * - * \luastack - * \lvalue A titlebar. - * \lreturn A string. - */ -static int -luaA_titlebar_tostring(lua_State *L) -{ - wibox_t **p = luaA_checkudata(L, 1, "titlebar"); - lua_pushfstring(L, "[titlebar udata(%p)]", *p); - return 1; -} - const struct luaL_reg awesome_titlebar_methods[] = { { "__call", luaA_titlebar_new }, @@ -481,12 +355,6 @@ const struct luaL_reg awesome_titlebar_methods[] = }; const struct luaL_reg awesome_titlebar_meta[] = { - { "widgets", luaA_titlebar_widgets }, - { "__index", luaA_titlebar_index }, - { "__newindex", luaA_titlebar_newindex }, - { "__eq", luaA_titlebar_eq }, - { "__gc", luaA_titlebar_gc }, - { "__tostring", luaA_titlebar_tostring }, { NULL, NULL } }; diff --git a/titlebar.h b/titlebar.h index b0cd0b39..55288a9c 100644 --- a/titlebar.h +++ b/titlebar.h @@ -30,8 +30,10 @@ void titlebar_geometry_compute(client_t *, area_t, area_t *); void titlebar_draw(client_t *); void titlebar_init(client_t *); void titlebar_refresh(void); +void titlebar_client_detach(client_t *); +void titlebar_client_attach(client_t *, wibox_t *); -int luaA_titlebar_userdata_new(lua_State *, wibox_t *); +int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t); /** Add the titlebar geometry and border to a geometry. * \param t The titlebar diff --git a/wibox.c b/wibox.c index 88504936..1341a44e 100644 --- a/wibox.c +++ b/wibox.c @@ -19,10 +19,20 @@ * */ +#include "screen.h" #include "wibox.h" #include "statusbar.h" #include "titlebar.h" +#include "client.h" +extern awesome_t globalconf; + +DO_LUA_NEW(extern, wibox_t, wibox, "wibox", wibox_ref) +DO_LUA_GC(wibox_t, wibox, "wibox", wibox_unref) +DO_LUA_EQ(wibox_t, wibox, "wibox") + +/** Refresh all wiboxes. + */ void wibox_refresh(void) { @@ -30,4 +40,273 @@ wibox_refresh(void) titlebar_refresh(); } +/** Convert a wibox to a printable string. + * \param L The Lua VM state. + * + * \luastack + * \lvalue A wibox. + */ +static int +luaA_wibox_tostring(lua_State *L) +{ + wibox_t **p = luaA_checkudata(L, 1, "wibox"); + lua_pushfstring(L, "[wibox udata(%p)]", *p); + return 1; +} + +/** Create a new wibox. + * \param L The Lua VM state. + * + * \luastack + * \lparam A table with optionaly defined values: + * position, align, fg, bg, border_widht, border_color, width and height. + * \lreturn A brand new wibox. + */ +int +luaA_wibox_new(lua_State *L) +{ + wibox_t *w; + const char *buf; + size_t len; + xcolor_init_request_t reqs[3]; + int8_t i, reqs_nbr = -1; + + luaA_checktable(L, 2); + + w = p_new(wibox_t, 1); + + w->colors.fg = globalconf.colors.fg; + if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) + reqs[++reqs_nbr] = xcolor_init_unchecked(&w->colors.fg, buf, len); + + w->colors.bg = globalconf.colors.bg; + if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) + reqs[++reqs_nbr] = xcolor_init_unchecked(&w->colors.bg, buf, len); + + w->colors.bg = globalconf.colors.bg; + if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) + reqs[++reqs_nbr] = xcolor_init_unchecked(&w->colors.bg, buf, len); + + buf = luaA_getopt_lstring(L, 2, "align", "left", &len); + w->align = draw_align_fromstr(buf, len); + + w->width = luaA_getopt_number(L, 2, "width", 0); + w->height = luaA_getopt_number(L, 2, "height", 0); + if(w->height <= 0) + /* 1.5 as default factor, it fits nice but no one knows why */ + w->height = 1.5 * globalconf.font->height; + + buf = luaA_getopt_lstring(L, 2, "position", "top", &len); + w->position = position_fromstr(buf, len); + + w->screen = SCREEN_UNDEF; + + for(i = 0; i <= reqs_nbr; i++) + xcolor_init_reply(reqs[i]); + + return luaA_wibox_userdata_new(L, w); +} + +/** Wibox object. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lfield screen Screen number. + * \lfield client The client attached to this titlebar. + * \lfield border_width Border width. + * \lfield border_color Border color. + * \lfield align The alignment. + * \lfield fg Foreground color. + * \lfield bg Background color. + * \lfield position The position. + */ +static int +luaA_wibox_index(lua_State *L) +{ + size_t len; + wibox_t **wibox = luaA_checkudata(L, 1, "wibox"); + const char *attr = luaL_checklstring(L, 2, &len); + + if(luaA_usemetatable(L, 1, 2)) + return 1; + + switch(a_tokenize(attr, len)) + { + client_t *c; + + case A_TK_CLIENT: + if((c = client_getbytitlebar(*wibox))) + return luaA_client_userdata_new(L, c); + else + return 0; + case A_TK_SCREEN: + if((*wibox)->screen == SCREEN_UNDEF) + return 0; + lua_pushnumber(L, (*wibox)->screen + 1); + break; + case A_TK_BORDER_WIDTH: + lua_pushnumber(L, (*wibox)->border.width); + break; + case A_TK_BORDER_COLOR: + luaA_pushcolor(L, &(*wibox)->border.color); + break; + case A_TK_ALIGN: + lua_pushstring(L, draw_align_tostr((*wibox)->align)); + break; + case A_TK_FG: + luaA_pushcolor(L, &(*wibox)->colors.fg); + break; + case A_TK_BG: + luaA_pushcolor(L, &(*wibox)->colors.bg); + break; + case A_TK_POSITION: + lua_pushstring(L, position_tostr((*wibox)->position)); + break; + case A_TK_WIDTH: + lua_pushnumber(L, (*wibox)->width); + break; + case A_TK_HEIGHT: + lua_pushnumber(L, (*wibox)->height); + break; + default: + return 0; + } + + return 1; +} + +/** Get or set the wibox widgets. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lparam None, or a table of widgets to set. + * \lreturn The current wibox widgets. +*/ +static int +luaA_wibox_widgets(lua_State *L) +{ + wibox_t **wibox = luaA_checkudata(L, 1, "wibox"); + + if(lua_gettop(L) == 2) + { + luaA_widget_set(L, 2, *wibox, &(*wibox)->widgets); + (*wibox)->need_update = true; + (*wibox)->mouse_over = NULL; + return 1; + } + return luaA_widget_get(L, (*wibox)->widgets); +} + +/** Wibox newindex. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_newindex(lua_State *L) +{ + size_t len; + wibox_t **wibox = luaA_checkudata(L, 1, "wibox"); + const char *buf, *attr = luaL_checklstring(L, 2, &len); + awesome_token_t tok; + + switch((tok = a_tokenize(attr, len))) + { + case A_TK_FG: + if((buf = luaL_checklstring(L, 3, &len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->colors.fg, buf, len))) + { + (*wibox)->sw.ctx.fg = (*wibox)->colors.fg; + (*wibox)->need_update = true; + } + break; + case A_TK_BG: + if((buf = luaL_checklstring(L, 3, &len))) + if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->colors.bg, buf, len))) + { + (*wibox)->sw.ctx.bg = (*wibox)->colors.bg; + (*wibox)->need_update = true; + } + break; + case A_TK_POSITION: + switch((*wibox)->type) + { + case WIBOX_TYPE_TITLEBAR: + return luaA_titlebar_newindex(L, *wibox, tok); + case WIBOX_TYPE_STATUSBAR: + return luaA_statusbar_newindex(L, *wibox, tok); + case WIBOX_TYPE_NONE: + if((buf = luaL_checklstring(L, 3, &len))) + (*wibox)->position = position_fromstr(buf, len); + break; + } + break; + case A_TK_CLIENT: + /* first detach */ + switch((*wibox)->type) + { + case WIBOX_TYPE_NONE: + case WIBOX_TYPE_TITLEBAR: + break; + case WIBOX_TYPE_STATUSBAR: + statusbar_detach(*wibox); + break; + } + if(lua_isnil(L, 3)) + titlebar_client_detach(client_getbytitlebar(*wibox)); + else + { + client_t **c = luaA_checkudata(L, 3, "client"); + titlebar_client_attach(*c, *wibox); + } + break; + case A_TK_SCREEN: + switch((*wibox)->type) + { + case WIBOX_TYPE_NONE: + case WIBOX_TYPE_STATUSBAR: + break; + case WIBOX_TYPE_TITLEBAR: + titlebar_client_detach(client_getbytitlebar(*wibox)); + break; + } + if(lua_isnil(L, 3)) + statusbar_detach(*wibox); + else + { + int screen = luaL_checknumber(L, 3) - 1; + luaA_checkscreen(screen); + statusbar_attach(*wibox, &globalconf.screens[screen]); + } + break; + default: + switch((*wibox)->type) + { + case WIBOX_TYPE_TITLEBAR: + return luaA_titlebar_newindex(L, *wibox, tok); + case WIBOX_TYPE_STATUSBAR: + return luaA_statusbar_newindex(L, *wibox, tok); + case WIBOX_TYPE_NONE: + break; + } + } + + return 0; +} + +const struct luaL_reg awesome_wibox_methods[] = +{ + { "__call", luaA_wibox_new }, + { NULL, NULL } +}; +const struct luaL_reg awesome_wibox_meta[] = +{ + { "widgets", luaA_wibox_widgets }, + { "__index", luaA_wibox_index }, + { "__newindex", luaA_wibox_newindex }, + { "__gc", luaA_wibox_gc }, + { "__eq", luaA_wibox_eq }, + { "__tostring", luaA_wibox_tostring }, + { NULL, NULL }, +}; + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/wibox.h b/wibox.h index 1d3dd324..3c59aa1e 100644 --- a/wibox.h +++ b/wibox.h @@ -30,6 +30,9 @@ void wibox_refresh(void); +int luaA_wibox_new(lua_State *); +int luaA_wibox_userdata_new(lua_State *, wibox_t *); + static inline void wibox_delete(wibox_t **wibox) { diff --git a/widget.c b/widget.c index 34136025..e3f2b78d 100644 --- a/widget.c +++ b/widget.c @@ -26,7 +26,7 @@ #include "mouse.h" #include "widget.h" -#include "titlebar.h" +#include "wibox.h" #include "common/atoms.h" extern awesome_t globalconf; @@ -61,14 +61,12 @@ widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment * \param ev The button press event the widget received. * \param screen The screen number. * \param p The object where user clicked. - * \param type The object type. */ static void widget_common_button(widget_node_t *w, xcb_button_press_event_t *ev, int screen __attribute__ ((unused)), - wibox_t *p, - awesome_type_t type) + wibox_t *p) { button_array_t *b = &w->widget->buttons; @@ -76,7 +74,7 @@ widget_common_button(widget_node_t *w, if(ev->detail == b->tab[i]->button && XUTIL_MASK_CLEAN(ev->state) == b->tab[i]->mod) { - luaA_pushpointer(globalconf.L, p, type); + luaA_wibox_userdata_new(globalconf.L, p); luaA_dofunction(globalconf.L, ev->response_type == XCB_BUTTON_PRESS ? b->tab[i]->press : b->tab[i]->release, @@ -93,14 +91,13 @@ widget_common_button(widget_node_t *w, * \param x The x coordinates of the object. * \param y The y coordinates of the object. * pixmap when the object position is right or left. - * \param object The object pointer. - * \param type The object type. + * \param object The wibox. * \todo Remove GC. */ void widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_pixmap_t rotate_px, int screen, position_t position, - int x, int y, void *object, awesome_type_t type) + int x, int y, wibox_t *object) { xcb_pixmap_t rootpix; xcb_screen_t *s; @@ -160,16 +157,16 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_ for(w = wnode; w; w = w->next) if(w->widget->align == AlignLeft && w->widget->isvisible) - left += w->widget->draw(ctx, screen, w, left, (left + right), object, type); + left += w->widget->draw(ctx, screen, w, left, (left + right), object); /* renders right widget from last to first */ for(w = *widget_node_list_last(&wnode); w; w = w->prev) if(w->widget->align == AlignRight && w->widget->isvisible) - right += w->widget->draw(ctx, screen, w, right, (left + right), object, type); + right += w->widget->draw(ctx, screen, w, right, (left + right), object); for(w = wnode; w; w = w->next) if(w->widget->align == AlignFlex && w->widget->isvisible) - left += w->widget->draw(ctx, screen, w, left, (left + right), object, type); + left += w->widget->draw(ctx, screen, w, left, (left + right), object); switch(position) { @@ -415,7 +412,7 @@ luaA_widget_newindex(lua_State *L) * \return The number of elements pushed on stack. */ void -luaA_widget_set(lua_State *L, int idx, void *object, widget_node_t **widgets) +luaA_widget_set(lua_State *L, int idx, wibox_t *object, widget_node_t **widgets) { widget_node_t *witer; diff --git a/widget.h b/widget.h index f521e7e4..d842484d 100644 --- a/widget.h +++ b/widget.h @@ -31,8 +31,8 @@ void widget_invalidate_cache(int, int); int widget_calculate_offset(int, int, int, int); void widget_common_new(widget_t *); -void widget_render(widget_node_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, position_t, int, int, void *, awesome_type_t); -void luaA_widget_set(lua_State *, int, void *, widget_node_t **); +void widget_render(widget_node_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, position_t, int, int, wibox_t *); +void luaA_widget_set(lua_State *, int, wibox_t *, widget_node_t **); int luaA_widget_get(lua_State *, widget_node_t *); int luaA_widget_userdata_new(lua_State *, widget_t *); diff --git a/widgets/graph.c b/widgets/graph.c index eb3c7919..2868a885 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -136,7 +136,6 @@ graph_plot_add(graph_data_t *d, const char *title) * \param offset The offset to draw at. * \param used The already used width. * \param p A pointer to the object we're drawing onto. - * \param type The object type. * \return The widget width. */ static int @@ -145,8 +144,7 @@ graph_draw(draw_context_t *ctx, widget_node_t *w, int offset, int used __attribute__ ((unused)), - wibox_t *p __attribute__ ((unused)), - awesome_type_t type) + wibox_t *p __attribute__ ((unused))) { int margin_top, y; graph_data_t *d = w->widget->data; diff --git a/widgets/imagebox.c b/widgets/imagebox.c index 223b1c73..8502d4db 100644 --- a/widgets/imagebox.c +++ b/widgets/imagebox.c @@ -38,14 +38,13 @@ typedef struct * \param offset Offset to draw at. * \param used The size used on the element. * \param p A pointer to the object we're draw onto. - * \param type The type of the object. * \return The width used. */ static int imagebox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), widget_node_t *w, int offset, int used, - wibox_t *p, awesome_type_t type) + wibox_t *p) { imagebox_data_t *d = w->widget->data; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index 7e64bc39..a1377c1c 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -120,7 +120,6 @@ progressbar_bar_add(progressbar_data_t *d, const char *title) * \param offset Offset to draw at. * \param used Space already used. * \param object The object pointer we're drawing onto. - * \param type The object type. * \return The width used. */ static int @@ -129,8 +128,7 @@ progressbar_draw(draw_context_t *ctx, widget_node_t *w, int offset, int used __attribute__ ((unused)), - wibox_t *p __attribute__ ((unused)), - awesome_type_t type) + wibox_t *p __attribute__ ((unused))) { /* pb_.. values points to the widget inside a potential border */ int values_ticks, pb_x, pb_y, pb_height, pb_width, pb_progress, pb_offset; diff --git a/widgets/systray.c b/widgets/systray.c index 3f201ffb..35bebd9e 100644 --- a/widgets/systray.c +++ b/widgets/systray.c @@ -37,14 +37,10 @@ systray_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), widget_node_t *w, int offset, int used __attribute__ ((unused)), - wibox_t *p, - awesome_type_t type) + wibox_t *p) { uint32_t orient; - /* we are on a statusbar */ - assert(type == AWESOME_TYPE_STATUSBAR); - w->area.height = ctx->height; if(ctx->width - used > 0) diff --git a/widgets/taglist.c b/widgets/taglist.c index ea4bf3e6..5b31f93c 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -22,7 +22,7 @@ #include "client.h" #include "widget.h" #include "tag.h" -#include "luaa.h" +#include "wibox.h" #include "common/tokenize.h" extern awesome_t globalconf; @@ -76,15 +76,13 @@ taglist_drawn_area_getbyobj(taglist_drawn_area_t *list, wibox_t *p) * \param offset Offset to draw at. * \param used Space already used. * \param object The object pointer we're drawing onto. - * \param type The object type. * \return The width used. */ static int taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w, int offset, int used __attribute__ ((unused)), - wibox_t *object, - awesome_type_t type) + wibox_t *object) { taglist_data_t *data = w->widget->data; area_t area; @@ -162,14 +160,12 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w, * \param btype The button press event type. * \param screen The screen where the click was. * \param object The object we're onto. - * \param type The type object. */ static void taglist_button(widget_node_t *w, xcb_button_press_event_t *ev, int screen, - wibox_t *object, - awesome_type_t type) + wibox_t *object) { tag_array_t *tags = &globalconf.screens[screen].tags; taglist_data_t *data = w->widget->data; @@ -188,7 +184,7 @@ taglist_button(widget_node_t *w, if(ev->event_x >= AREA_LEFT(*area) && ev->event_x < AREA_RIGHT(*area)) { - luaA_pushpointer(globalconf.L, object, type); + luaA_wibox_userdata_new(globalconf.L, object); luaA_tag_userdata_new(globalconf.L, tag); luaA_dofunction(globalconf.L, ev->response_type == XCB_BUTTON_PRESS ? diff --git a/widgets/tasklist.c b/widgets/tasklist.c index cd43a2f8..b04fe4f0 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -21,8 +21,8 @@ #include "client.h" #include "widget.h" -#include "ewmh.h" #include "tag.h" +#include "wibox.h" #include "common/markup.h" #include "common/tokenize.h" @@ -172,14 +172,12 @@ tasklist_draw_item(draw_context_t *ctx, * \param offset The offset to draw at. * \param used The already used width. * \param p A pointer to the object we're drawing onto. - * \param type The object type. * \return The widget width. */ static int tasklist_draw(draw_context_t *ctx, int screen, widget_node_t *w, - int offset, int used, wibox_t *p, - awesome_type_t type) + int offset, int used, wibox_t *p) { client_t *c; tasklist_data_t *d = w->widget->data; @@ -273,14 +271,12 @@ tasklist_draw(draw_context_t *ctx, int screen, * \param ev The button press event. * \param screen The screen where the click was. * \param object The object we're onto. - * \param type The type object. */ static void tasklist_button(widget_node_t *w, xcb_button_press_event_t *ev, int screen, - wibox_t *object, - awesome_type_t type) + wibox_t *object) { tasklist_data_t *d = w->widget->data; int ci = 0; @@ -301,7 +297,7 @@ tasklist_button(widget_node_t *w, if(ev->detail == barr->tab[i]->button && XUTIL_MASK_CLEAN(ev->state) == barr->tab[i]->mod) { - luaA_pushpointer(globalconf.L, object, type); + luaA_wibox_userdata_new(globalconf.L, object); luaA_client_userdata_new(globalconf.L, odata->client_labels.tab[ci].client); luaA_dofunction(globalconf.L, ev->response_type == XCB_BUTTON_PRESS ? diff --git a/widgets/textbox.c b/widgets/textbox.c index 8d7e1313..a2ccb6de 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -46,15 +46,13 @@ typedef struct * \param offset Offset to draw at. * \param used The size used on the element. * \param p A pointer to the object we're draw onto. - * \param type The object type. * \return The width used. */ static int textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), widget_node_t *w, int offset, int used, - wibox_t *p __attribute__ ((unused)), - awesome_type_t type) + wibox_t *p __attribute__ ((unused))) { textbox_data_t *d = w->widget->data;