From 84839d456d1b50291c71bad9a7aa1d31b3484a18 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 17 Aug 2009 16:56:03 +0200 Subject: [PATCH] wibox: port to new object system Signed-off-by: Julien Danjou --- common/tokenize.gperf | 2 + event.c | 20 +- lib/awful/menu.lua.in | 13 +- lib/awful/mouse.lua.in | 12 +- lib/awful/wibox.lua.in | 91 ++-- lib/invaders.lua.in | 141 +++---- luaa.c | 5 +- property.c | 6 +- titlebar.c | 149 +++---- titlebar.h | 13 +- wibox.c | 1096 ++++++++++++++++++++++++++++++++---------------- wibox.h | 26 +- 12 files changed, 941 insertions(+), 633 deletions(-) diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 04bdcb92..af81c3db 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -120,3 +120,5 @@ word word_char workarea wrap +x +y diff --git a/event.c b/event.c index 94c367f6..8a52fdab 100644 --- a/event.c +++ b/event.c @@ -429,13 +429,9 @@ event_handle_leavenotify(void *data __attribute__ ((unused)), wibox->mouse_over = NULL; } - if(wibox->mouse_leave) - { - luaA_object_push(globalconf.L, wibox); - luaA_object_push_item(globalconf.L, -1, wibox->mouse_leave); - lua_remove(globalconf.L, -2); - luaA_dofunction(globalconf.L, 0, 0); - } + luaA_object_push(globalconf.L, wibox); + luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0); + lua_pop(globalconf.L, 1); } return 0; @@ -466,13 +462,9 @@ event_handle_enternotify(void *data __attribute__ ((unused)), if(w) event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w); - if(wibox->mouse_enter) - { - luaA_object_push(globalconf.L, wibox); - luaA_object_push_item(globalconf.L, -1, wibox->mouse_enter); - lua_remove(globalconf.L, -2); - luaA_dofunction(globalconf.L, 0, 0); - } + luaA_object_push(globalconf.L, wibox); + luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0); + lua_pop(globalconf.L, 1); } if((c = client_getbytitlebarwin(ev->event)) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index d49b37ed..7720e4e9 100644 --- a/lib/awful/menu.lua.in +++ b/lib/awful/menu.lua.in @@ -168,7 +168,6 @@ end local function add_item(data, num, item_info) local item = wibox({ - position = "floating", fg = data.theme.fg_normal, bg = data.theme.bg_normal, border_color = data.theme.border, @@ -205,7 +204,7 @@ local function add_item(data, num, item_info) local mouse_enter_func = function () item_enter(data, num, true) end label:add_signal("mouse::enter", mouse_enter_func) - item.mouse_enter = mouse_enter_func + item:add_signal("mouse::enter", mouse_enter_func) -- Create the submenu icon widget local submenu @@ -294,12 +293,10 @@ function show(menu, keygrabber) set_coords(menu, screen_index) for num, item in pairs(menu.items) do local wibox = item.wibox - wibox:geometry({ - width = menu.w, - height = menu.h, - x = menu.x, - y = menu.y + (num - 1) * (menu.h + menu.theme.border_width) - }) + wibox.width = menu.w + wibox.height = menu.h + wibox.x = menu.x + wibox.y = menu.y + (num - 1) * (menu.h - menu.theme.border_width) wibox.screen = screen_index end diff --git a/lib/awful/mouse.lua.in b/lib/awful/mouse.lua.in index f0ab7528..6a37a9f4 100644 --- a/lib/awful/mouse.lua.in +++ b/lib/awful/mouse.lua.in @@ -273,21 +273,19 @@ end --- Move the wibox under the cursor --@param w The wibox to move, or none to use that under the pointer function wibox.move(w) - if not w then w = wibox_under_pointer() end + local w = w or wibox_under_pointer() if not w then return end local offset = { - x = w:geometry()["x"] - capi.mouse.coords()["x"], - y = w:geometry()["y"] - capi.mouse.coords()["y"] + x = w.x - capi.mouse.coords().x, + y = w.y - capi.mouse.coords().y } capi.mousegrabber.run(function (mouse) local button_down = false if awibox.get_position(w) == "floating" then - w:geometry({ - x = capi.mouse.coords()["x"] + offset["x"], - y = capi.mouse.coords()["y"] + offset["y"], - }) + w.x = capi.mouse.coords().x + offset.x + w.y = capi.mouse.coords().y + offset.y else local wa = awibox.get_workarea(capi.mouse.screen) diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in index 1bba62d5..e91a2655 100644 --- a/lib/awful/wibox.lua.in +++ b/lib/awful/wibox.lua.in @@ -36,15 +36,15 @@ function get_workarea(s) for _, wprop in ipairs(wiboxes) do if wprop.wibox.visible and wprop.wibox.screen == s then if wprop.position == "top" then - area.y = area.y + wprop.wibox:geometry().height + (2 * wprop.wibox.border_width) - area.height = area.height - (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.y = area.y + wprop.wibox.height + (2 * wprop.wibox.border_width) + area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width)) elseif wprop.position == "bottom" then - area.height = area.height - (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width)) elseif wprop.position == "left" then - area.x = area.x + (wprop.wibox:geometry().width + (2 * wprop.wibox.border_width)) - area.width = area.width - (wprop.wibox:geometry().width + (2 * wprop.wibox.border_width)) + area.x = area.x + wprop.wibox.width + (2 * wprop.wibox.border_width) + area.width = area.width - (wprop.wibox.width + (2 * wprop.wibox.border_width)) elseif wprop.position == "right" then - area.width = area.width - (wprop.wibox:geometry().width + (2 * wprop.wibox.border_width)) + area.width = area.width - (wprop.wibox.width + (2 * wprop.wibox.border_width)) end end end @@ -62,19 +62,19 @@ local function compute_area(wibox, position, s) and not (ignore and wprop.position == position) then if (wprop.position == "right" or wprop.position == "left") and wprop.position == position then - area.x = area.x + (wibox:geometry().width + (2 * wibox.border_width)) + area.x = area.x + (wibox.width + (2 * wibox.border_width)) elseif wprop.position == "top" then if position == "top" then - area.y = area.y + (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.y = area.y + (wprop.wibox.height + (2 * wprop.wibox.border_width)) elseif position == "left" or position == "right" then - area.height = area.height - (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) - area.y = area.y + (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width)) + area.y = area.y + (wprop.wibox.height + (2 * wprop.wibox.border_width)) end elseif wprop.position == "bottom" then if position == "bottom" then - area.y = area.y - (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.y = area.y - (wprop.wibox.height + (2 * wprop.wibox.border_width)) elseif position == "left" or position == "right" then - area.height = area.height - (wprop.wibox:geometry().height + (2 * wprop.wibox.border_width)) + area.height = area.height - (wprop.wibox.height + (2 * wprop.wibox.border_width)) end end end @@ -102,19 +102,17 @@ end function set_position(wibox, position, screen) local area = compute_area(wibox, position, screen) - local wingeom = wibox:geometry() - -- The "length" of a wibox is always chosen to be the optimal size -- (non-floating). -- The "width" of a wibox is kept if it exists. if position == "right" then - wingeom.x = area.x + area.width - (wingeom.width + 2 * wibox.border_width) + wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) elseif position == "left" then - wingeom.x = area.x + wibox.x = area.x elseif position == "bottom" then - wingeom.y = (area.y + area.height) - (wingeom.height + 2 * wibox.border_width) + wibox.y = (area.y + area.height) - (wibox.height + 2 * wibox.border_width) elseif position == "top" then - wingeom.y = area.y + wibox.y = area.y end for _, wprop in ipairs(wiboxes) do @@ -123,8 +121,6 @@ function set_position(wibox, position, screen) break end end - - wibox:geometry(wingeom) end -- Reset all wiboxes positions. @@ -180,49 +176,40 @@ end function align(wibox, align, screen) local position = get_position(wibox) local area = compute_area(wibox, position, screen) - local wingeom = wibox:geometry() - wingeom.height = wingeom.height + 2 * wibox.border_width - wingeom.width = wingeom.width + 2 * wibox.border_width if position == "right" then if align == "right" then - wingeom.y = area.y + wibox.y = area.y elseif align == "left" then - wingeom.y = area.y + area.height - wingeom.height + wibox.y = area.y + area.height - (wibox.height + 2 * wibox.border_width) elseif align == "center" then - wingeom.y = area.y + (area.height - wingeom.height) / 2 + wibox.y = area.y + (area.height - wibox.height) / 2 end elseif position == "left" then if align == "right" then - wingeom.y = (area.y + area.height) - wingeom.height + wibox.y = (area.y + area.height) - (wibox.height + 2 * wibox.border_width) elseif align == "left" then - wingeom.y = area.y + wibox.y = area.y elseif align == "center" then - wingeom.y = area.y + (area.height - wingeom.height) / 2 + wibox.y = area.y + (area.height - wibox.height) / 2 end elseif position == "bottom" then if align == "right" then - wingeom.x = area.x + area.width - wingeom.width + wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) elseif align == "left" then - wingeom.x = area.x + wibox.x = area.x elseif align == "center" then - wingeom.x = area.x + (area.width - wingeom.width) / 2 + wibox.x = area.x + (area.width - wibox.width) / 2 end elseif position == "top" then if align == "right" then - wingeom.x = area.x + area.width - wingeom.width + wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) elseif align == "left" then - wingeom.x = area.x + wibox.x = area.x elseif align == "center" then - wingeom.x = area.x + (area.width - wingeom.width) / 2 + wibox.x = area.x + (area.width - wibox.width) / 2 end end - - -- Reset height and width - wingeom.height = wingeom.height - 2 * wibox.border_width - wingeom.width = wingeom.width - 2 * wibox.border_width - - wibox:geometry(wingeom) end --- Stretch a wibox so it takes all screen width or height. @@ -230,14 +217,11 @@ end function stretch(wibox) local position = get_position(wibox) local area = compute_area(wibox, position) - local wingeom = {} if position == "right" or position == "left" then - wingeom.height = area.height - (2 * wibox.border_width) - wibox:geometry(wingeom) + wibox.height = area.height - (2 * wibox.border_width) align(wibox, "center") else - wingeom.width = area.width - (2 * wibox.border_width) - wibox:geometry(wingeom) + wibox.width = area.width - (2 * wibox.border_width) align(wibox, "left") end end @@ -341,20 +325,17 @@ end -- @param corner_size The size in pixel of the rounded corners. function rounded_corners(wibox, corner_size) local border = wibox.border_width - local geometry = wibox:geometry() - local width = geometry.width - local height = geometry.height -- Corners can't be larger than half the wibox' space - if width / 2 < corner_size then - corner_size = width / 2 + if wibox.width / 2 < corner_size then + corner_size = wibox.width / 2 end - if height / 2 < corner_size then - corner_size = height / 2 + if wibox.height / 2 < corner_size then + corner_size = wibox.height / 2 end - wibox.shape_clip = do_rounded_corners(width, height, corner_size) - wibox.shape_bounding = do_rounded_corners(width + border * 2, height + border * 2, corner_size + border) + wibox.shape_clip = do_rounded_corners(wibox.width, wibox.height, corner_size) + wibox.shape_bounding = do_rounded_corners(wibox.width + border * 2, wibox.height + border * 2, corner_size + border) end local function update_wiboxes_position(obj, prop) diff --git a/lib/invaders.lua.in b/lib/invaders.lua.in index 1ca042df..eb50197b 100644 --- a/lib/invaders.lua.in +++ b/lib/invaders.lua.in @@ -62,11 +62,11 @@ local shots = { } local enemies = { } function player.new () - p = wibox({ bg = gamedata.solidbg or "#12345600" }) - p:geometry({ width = 24, - height = 16, - x = gamedata.field.x + (gamedata.field.w / 2), - y = gamedata.field.y + gamedata.field.h - (16 + 5) }) + p = wibox({ bg = gamedata.solidbg or "#12345600", + width = 24, + height = 16, + x = gamedata.field.x + (gamedata.field.w / 2), + y = gamedata.field.y + gamedata.field.h - (16 + 5) }) p.screen = gamedata.screen w = widget({ type = "imagebox" }) @@ -78,32 +78,28 @@ end function player.move(x) if not gamedata.running then return false end - local g = gamedata.player:geometry() - if x < 0 and g.x > gamedata.field.x then - g.x = g.x + x - elseif x > 0 and g.x < gamedata.field.x + gamedata.field.w - 30 then - g.x = g.x + x + if x < 0 and gamedata.player.x > gamedata.field.x then + gamedata.player.x = gamedata.player.x + x + elseif x > 0 and gamedata.player.x < gamedata.field.x + gamedata.field.w - 30 then + gamedata.player.x = gamedata.player.x + x end - - gamedata.player:geometry(g) end function player.fire() if not gamedata.running then return false end if gamedata.ammo == 1 then gamedata.ammo = 0 - local gb = gamedata.player:geometry() - shots.fire(gb.x + 9, gb.y - 10, "#00FF00") + shots.fire(gamedata.player.x + 9, gamedata.player.y - 10, "#00FF00") end end function shots.fire (x, y, color) - local s = wibox({ bg = color }) - s:geometry({ width = 4, - height = 10, - x = x, - y = y }) + local s = wibox({ bg = color, + width = 4, + height = 10, + x = x, + y = y }) s.screen = gamedata.screen if not gamedata.shot or gamedata.shot.screen == nil then @@ -114,11 +110,11 @@ end function shots.fire_enemy (x, y, color) if gamedata.enemies.shots.fired < gamedata.enemies.shots.max then gamedata.enemies.shots.fired = gamedata.enemies.shots.fired + 1 - local s = wibox({ bg = color }) - s:geometry({ width = 4, - height = 10, - x = x, - y = y }) + local s = wibox({ bg = color, + width = 4, + height = 10, + x = x, + y = y }) s.screen = gamedata.screen for i = 1, gamedata.enemies.shots.max do if not gamedata.enemies.shots[i] or gamedata.enemies.shots[i].screen == nil then @@ -136,13 +132,11 @@ function shots.handle() local s = gamedata.shot if s and s.screen then gamedata.ammo = 0 - local g = s:geometry() - if g.y < gamedata.field.y + 15 then + if s.y < gamedata.field.y + 15 then s.screen = nil gamedata.ammo = 1 else - g.y = g.y - 6 - s:geometry(g) + s.y = s.y - 6 end end end @@ -155,13 +149,11 @@ function shots.handle_enemy () for i = 1, gamedata.enemies.shots.max do local s = gamedata.enemies.shots[i] if s and s.screen then - local g = s:geometry() - if g.y > gamedata.field.y + gamedata.field.h - 15 then + if s.y > gamedata.field.y + gamedata.field.h - 15 then s.screen = nil gamedata.enemies.shots.fired = gamedata.enemies.shots.fired - 1 else - g.y = g.y + 3 - s:geometry(g) + s.y = s.y + 3 end if game.collide(gamedata.player, s) then game.over() @@ -171,11 +163,11 @@ function shots.handle_enemy () end function enemies.new (t) - e = wibox({ bg = gamedata.solidbg or "#12345600" }) - e:geometry({ height = gamedata.enemies.h, - width = gamedata.enemies.w, - x = gamedata.field.x, - y = gamedata.field.y }) + e = wibox({ bg = gamedata.solidbg or "#12345600", + height = gamedata.enemies.h, + width = gamedata.enemies.w, + x = gamedata.field.x, + y = gamedata.field.y }) e.screen = gamedata.screen w = widget({ type = "imagebox" }) w.image = gamedata.enemies[t] @@ -222,13 +214,11 @@ function enemies.handle () for x = 1, #gamedata.enemies.data[y] do local e = gamedata.enemies.data[y][x] if e.screen then - local g = e:geometry() gamedata.enemies.number = gamedata.enemies.number + 1 if gamedata.enemies.speed_count == (gamedata.enemies.speed - 1) then - g.y = math.floor(gamedata.field.y + gamedata.enemies.y + ((y - 1) * gamedata.enemies.h * 2)) - g.x = math.floor(gamedata.field.x + gamedata.enemies.x + ((x - 1) * gamedata.enemies.w * 2)) - e:geometry(g) - if game.collide(gamedata.player, e) or g.y > gamedata.field.y + gamedata.field.h - 20 then + e.y = math.floor(gamedata.field.y + gamedata.enemies.y + ((y - 1) * gamedata.enemies.h * 2)) + e.x = math.floor(gamedata.field.x + gamedata.enemies.x + ((x - 1) * gamedata.enemies.w * 2)) + if game.collide(gamedata.player, e) or e.y > gamedata.field.y + gamedata.field.h - 20 then game.over() end end @@ -316,12 +306,9 @@ function keyhandler(mod, key, event) end function game.collide(o1, o2) - g1 = o1:geometry() - g2 = o2:geometry() - --check if o2 is inside o1 - if g2.x >= g1.x and g2.x <= g1.x + g1.width - and g2.y >= g1.y and g2.y <= g1.y + g1.height then + if o2.x >= o1.x and o2.x <= o1.x + o1.width + and o2.y >= o1.y and o2.y <= o1.y + o1.height then return true end @@ -441,11 +428,11 @@ function game.highscore (score) end gamedata.highscore.window = wibox({ bg = gamedata.btheme.bg_focus or "#333333", - fg = gamedata.btheme.fg_focus or "#FFFFFF" }) - gamedata.highscore.window:geometry({ height = 20, - width = 300, - x = gamedata.field.x + math.floor(gamedata.field.w / 2) - 150, - y = gamedata.field.y + math.floor(gamedata.field.h / 2) }) + fg = gamedata.btheme.fg_focus or "#FFFFFF", + height = 20, + width = 300, + x = gamedata.field.x + math.floor(gamedata.field.w / 2) - 150, + y = gamedata.field.y + math.floor(gamedata.field.h / 2) }) gamedata.highscore.window.screen = gamedata.screen gamedata.namebox = widget({ type = "textbox" }) @@ -487,11 +474,11 @@ function run(args) gamedata.cachedir = awful.util.getdir("cache") if gamedata.solidbg then - gamedata.field.background = wibox({ bg = gamedata.solidbg }) - gamedata.field.background:geometry({ x = gamedata.field.x, - y = gamedata.field.y, - height = gamedata.field.h, - width = gamedata.field.w }) + gamedata.field.background = wibox({ bg = gamedata.solidbg, + x = gamedata.field.x, + y = gamedata.field.y, + height = gamedata.field.h, + width = gamedata.field.w }) gamedata.field.background.screen = gamedata.screen end @@ -502,11 +489,11 @@ function run(args) gamedata.field.caption.text = " Awesome Invaders" gamedata.field.north = wibox({ bg = gamedata.btheme.bg_focus or "#333333", - fg = gamedata.btheme.fg_focus or "#FFFFFF" }) - gamedata.field.north:geometry({ width = gamedata.field.w + 10, - height = gamedata.field.caption:extents()["height"], - x = gamedata.field.x - 5, - y = gamedata.field.y - gamedata.field.caption:extents()["height"] }) + fg = gamedata.btheme.fg_focus or "#FFFFFF", + width = gamedata.field.w + 10, + height = gamedata.field.caption:extents()["height"], + x = gamedata.field.x - 5, + y = gamedata.field.y - gamedata.field.caption:extents()["height"] }) gamedata.field.north.screen = gamedata.screen gamedata.field.north.widgets = { @@ -522,27 +509,27 @@ function run(args) } gamedata.field.south = wibox({ bg = gamedata.btheme.bg_focus or "#333333", - fg = gamedata.btheme.fg_focus or "#FFFFFF" }) - gamedata.field.south:geometry({ width = gamedata.field.w, - height = 5, - x = gamedata.field.x, - y = gamedata.field.y + gamedata.field.h - 5 }) + fg = gamedata.btheme.fg_focus or "#FFFFFF", + width = gamedata.field.w, + height = 5, + x = gamedata.field.x, + y = gamedata.field.y + gamedata.field.h - 5 }) gamedata.field.south.screen = gamedata.screen gamedata.field.west = wibox({ bg = gamedata.btheme.bg_focus or "#333333", - fg = gamedata.btheme.fg_focus or "#FFFFFF" }) - gamedata.field.west:geometry({ width = 5, - height = gamedata.field.h, - x = gamedata.field.x - 5, - y = gamedata.field.y }) + fg = gamedata.btheme.fg_focus or "#FFFFFF", + width = 5, + height = gamedata.field.h, + x = gamedata.field.x - 5, + y = gamedata.field.y }) gamedata.field.west.screen = gamedata.screen gamedata.field.east = wibox({ bg = gamedata.btheme.bg_focus or "#333333", - fg = gamedata.btheme.fg_focus or "#FFFFFF" }) - gamedata.field.east:geometry({ width = 5, - height = gamedata.field.h, - x = gamedata.field.x + gamedata.field.w, - y = gamedata.field.y }) + fg = gamedata.btheme.fg_focus or "#FFFFFF", + width = 5, + height = gamedata.field.h, + x = gamedata.field.x + gamedata.field.w, + y = gamedata.field.y }) gamedata.field.east.screen = gamedata.screen gamedata.enemies.speed = 5 diff --git a/luaa.c b/luaa.c index 32e89629..4733d08a 100644 --- a/luaa.c +++ b/luaa.c @@ -57,8 +57,6 @@ extern const struct luaL_reg awesome_screen_methods[]; extern const struct luaL_reg awesome_screen_meta[]; extern const struct luaL_reg awesome_client_methods[]; extern const struct luaL_reg awesome_client_meta[]; -extern const struct luaL_reg awesome_wibox_methods[]; -extern const struct luaL_reg awesome_wibox_meta[]; /** Quit awesome. * \param L The Lua VM state. @@ -741,8 +739,7 @@ luaA_init(xdgHandle* xdg) tag_class_setup(L); /* Export wibox */ - luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new, - awesome_wibox_methods, awesome_wibox_meta); + wibox_class_setup(L); /* Export widget */ widget_class_setup(L); diff --git a/property.c b/property.c index 1773fb07..2abad892 100644 --- a/property.c +++ b/property.c @@ -568,7 +568,11 @@ property_handle_net_wm_opacity(void *data __attribute__ ((unused)), wibox_t *wibox = wibox_getbywin(window); if(wibox) - wibox->opacity = window_opacity_get_from_reply(reply); + { + luaA_object_push(globalconf.L, wibox); + wibox_set_opacity(globalconf.L, -1, window_opacity_get_from_reply(reply)); + lua_pop(globalconf.L, -1); + } else { client_t *c = client_getbywin(window); diff --git a/titlebar.c b/titlebar.c index f18ec280..793b7add 100644 --- a/titlebar.c +++ b/titlebar.c @@ -85,7 +85,7 @@ void titlebar_unban(wibox_t *titlebar) { /* Do this manually because the system doesn't know we moved the toolbar. - * Note that !isvisible titlebars are unmapped and for fullscreen it'll + * Note that !visible titlebars are unmapped and for fullscreen it'll * end up offscreen anyway. */ if(titlebar && titlebar->isbanned) { @@ -279,9 +279,9 @@ titlebar_client_attach(client_t *c) void titlebar_set_visible(wibox_t *t, bool visible) { - if(visible != t->isvisible) + if(visible != t->visible) { - if((t->isvisible = visible)) + if((t->visible = visible)) titlebar_unban(t); else titlebar_ban(t); @@ -291,112 +291,77 @@ titlebar_set_visible(wibox_t *t, bool visible) } } -/** 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. - */ int -luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok) +luaA_titlebar_set_position(lua_State *L, int udx) { - client_t *c = NULL; - - switch(tok) + wibox_t *titlebar = luaA_checkudata(L, udx, &wibox_class); + size_t len; + const char *buf = luaL_checklstring(L, -1, &len); + position_t position = position_fromstr(buf, len); + if(position != titlebar->position) { - position_t position; - int i; - size_t len; - const char *buf; - - case A_TK_ALIGN: - if((buf = luaL_checklstring(L, 3, &len))) - titlebar->align = draw_align_fromstr(buf, len); - else - return 0; - break; - case A_TK_BORDER_WIDTH: - if((i = luaL_checknumber(L, 3)) >= 0) - wibox_border_width_set(titlebar, 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))) - wibox_border_color_set(titlebar, &titlebar->border.color); - return 0; - case A_TK_POSITION: - buf = luaL_checklstring(L, 3, &len); - position = position_fromstr(buf, len); - if(position != titlebar->position) + switch(position) { - switch(position) + case Left: + switch(titlebar->position) { + int tmp; case Left: - switch(titlebar->position) - { - int tmp; - case Left: - case Right: - break; - case Top: - case Bottom: - tmp = titlebar->geometry.width; - titlebar->geometry.width = titlebar->geometry.height; - titlebar->geometry.height = tmp; - break; - } - wibox_orientation_set(titlebar, North); + case Right: break; + case Top: + case Bottom: + tmp = titlebar->geometry.width; + titlebar->geometry.width = titlebar->geometry.height; + titlebar->geometry.height = tmp; + break; + } + wibox_set_orientation(L, udx, North); + break; + case Right: + switch(titlebar->position) + { + int tmp; + case Left: case Right: - switch(titlebar->position) - { - int tmp; - case Left: - case Right: - break; - case Top: - case Bottom: - tmp = titlebar->geometry.width; - titlebar->geometry.width = titlebar->geometry.height; - titlebar->geometry.height = tmp; - break; - } - wibox_orientation_set(titlebar, South); break; case Top: case Bottom: - switch(titlebar->position) - { - int tmp; - case Left: - case Right: - tmp = titlebar->geometry.width; - titlebar->geometry.width = titlebar->geometry.height; - titlebar->geometry.height = tmp; - break; - case Top: - case Bottom: - break; - } - wibox_orientation_set(titlebar, East); + tmp = titlebar->geometry.width; + titlebar->geometry.width = titlebar->geometry.height; + titlebar->geometry.height = tmp; break; } - titlebar->position = position; - if((c = client_getbytitlebar(titlebar))) + wibox_set_orientation(L, udx, South); + break; + case Top: + case Bottom: + switch(titlebar->position) { - titlebar_update_geometry(c); - /* call geometry hook for client because some like to - * set titlebar width in that hook, which make sense */ - hook_property(c, "geometry"); + int tmp; + case Left: + case Right: + tmp = titlebar->geometry.width; + titlebar->geometry.width = titlebar->geometry.height; + titlebar->geometry.height = tmp; + break; + case Top: + case Bottom: + break; } + wibox_set_orientation(L, udx, East); + break; + } + titlebar->position = position; + client_t *c; + if((c = client_getbytitlebar(titlebar))) + { + titlebar_update_geometry(c); + /* call geometry hook for client because some like to + * set titlebar width in that hook, which make sense */ + hook_property(c, "geometry"); } - break; - default: - return 0; } - return 0; } diff --git a/titlebar.h b/titlebar.h index a4886986..16397b56 100644 --- a/titlebar.h +++ b/titlebar.h @@ -36,7 +36,7 @@ void titlebar_set_visible(wibox_t *, bool); void titlebar_ban(wibox_t *); void titlebar_unban(wibox_t *); -int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t); +int luaA_titlebar_set_position(lua_State *, int); static inline bool titlebar_isvisible(client_t *c, screen_t *screen) @@ -45,7 +45,7 @@ titlebar_isvisible(client_t *c, screen_t *screen) { if(c->isfullscreen) return false; - if(!c->titlebar || !c->titlebar->isvisible) + if(!c->titlebar || !c->titlebar->visible) return false; return true; } @@ -65,7 +65,7 @@ titlebar_geometry_add(wibox_t *t, int border, area_t geometry) * This can then be substracted/added to the witdh/height/x/y. * In this case the border is included, because it belongs to a different window. */ - if(t && t->isvisible) + if(t && t->visible) switch(t->position) { case Top: @@ -106,7 +106,7 @@ titlebar_geometry_remove(wibox_t *t, int border, area_t geometry) * This can then be substracted/added to the witdh/height/x/y. * In this case the border is included, because it belongs to a different window. */ - if(t && t->isvisible) + if(t && t->visible) switch(t->position) { case Top: @@ -147,7 +147,10 @@ titlebar_update_geometry(client_t *c) /* Client geometry without titlebar, but including borders, since that is always consistent. */ titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &geom); - wibox_moveresize(c->titlebar, geom); + luaA_object_push(globalconf.L, c); + luaA_object_push_item(globalconf.L, -1, c->titlebar); + wibox_moveresize(globalconf.L, -1, geom); + lua_pop(globalconf.L, 2); } #endif diff --git a/wibox.c b/wibox.c index ce3adf16..d4ca27b2 100644 --- a/wibox.c +++ b/wibox.c @@ -31,6 +31,8 @@ #include "common/xcursor.h" #include "common/xutil.h" +LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox) + /** Take care of garbage collecting a wibox. * \param L The Lua VM state. * \return The number of elements pushed on stack, 0! @@ -110,7 +112,7 @@ wibox_shape_update(wibox_t *wibox) } shape_update(wibox->window, XCB_SHAPE_SK_CLIP, wibox->shape.clip, 0); - shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border.width); + shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border_width); wibox->need_shape_update = false; } @@ -162,13 +164,13 @@ wibox_init(wibox_t *w, int phys_screen) xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root, w->geometry.x, w->geometry.y, w->geometry.width, w->geometry.height, - w->border.width, XCB_COPY_FROM_PARENT, s->root_visual, + w->border_width, XCB_COPY_FROM_PARENT, s->root_visual, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK, (const uint32_t []) { XCB_BACK_PIXMAP_PARENT_RELATIVE, - w->border.color.pixel, + w->border_color.pixel, 1, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW @@ -205,20 +207,29 @@ wibox_refresh_pixmap(wibox_t *w) } /** Set a wibox opacity. - * \param w The wibox the adjust the opacity of. + * \param L The Lua VM state. + * \param w The index wibox the adjust the opacity of. * \param opacity A value between 0 and 1 which describes the opacity. */ static inline void -wibox_opacity_set(wibox_t *w, double opacity) +wibox_opacity_set(lua_State *L, int udx, double opacity) { + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); w->opacity = opacity; if(w->window != XCB_NONE) window_opacity_set(w->window, opacity); + luaA_object_emit_signal(globalconf.L, udx, "property::opacity", 0); } +/** Move and/or resize a wibox + * \param L The Lua VM state. + * \param udx The index of the wibox. + * \param geometry The new geometry. + */ void -wibox_moveresize(wibox_t *w, area_t geometry) +wibox_moveresize(lua_State *L, int udx, area_t geometry) { + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); if(w->window) { int number_of_vals = 0; @@ -265,9 +276,30 @@ wibox_moveresize(wibox_t *w, area_t geometry) xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals); w->screen = screen_getbycoord(w->screen, w->geometry.x, w->geometry.y); + + if(mask_vals & XCB_CONFIG_WINDOW_X) + luaA_object_emit_signal(L, udx, "property::x", 0); + if(mask_vals & XCB_CONFIG_WINDOW_Y) + luaA_object_emit_signal(L, udx, "property::y", 0); + if(mask_vals & XCB_CONFIG_WINDOW_WIDTH) + luaA_object_emit_signal(L, udx, "property::width", 0); + if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT) + luaA_object_emit_signal(L, udx, "property::height", 0); } else - w->geometry = geometry; + { +#define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \ + if(w->geometry.prop != geometry.prop) \ + { \ + w->geometry.prop = geometry.prop; \ + luaA_object_emit_signal(L, udx, "property::" #prop, 0); \ + } + DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x) + DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y) + DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width) + DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height) +#undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT + } wibox_need_update(w); } @@ -289,37 +321,58 @@ wibox_refresh_pixmap_partial(wibox_t *wibox, w, h); } +void +wibox_set_opacity(lua_State *L, int udx, double opacity) +{ + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); + if(w->opacity != opacity) + { + w->opacity = opacity; + if(w->window) + window_opacity_set(w->window, opacity); + luaA_object_emit_signal(L, udx, "property::opacity", 0); + } +} + /** Set a wibox border width. - * \param w The wibox to change border width. + * \param L The Lua VM state. + * \param idx The wibox to change border width. * \param border_width The border width in pixel. */ -void -wibox_border_width_set(wibox_t *w, uint32_t border_width) +static void +wibox_set_border_width(lua_State *L, int udx, uint32_t border_width) { + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &border_width); - w->border.width = border_width; + w->border_width = border_width; + luaA_object_emit_signal(L, udx, "property::border_width", 0); } /** Set a wibox border color. - * \param w The wibox to change border width. + * \param L The Lua VM state. + * \param idx The wibox to change border width. * \param color The border color. */ -void -wibox_border_color_set(wibox_t *w, const xcolor_t *color) +static void +wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color) { + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); xcb_change_window_attributes(globalconf.connection, w->window, XCB_CW_BORDER_PIXEL, &color->pixel); - w->border.color = *color; + w->border_color = *color; + luaA_object_emit_signal(L, udx, "property::border_color", 0); } /** Set wibox orientation. + * \param L The Lua VM state. * \param w The wibox. * \param o The new orientation. */ void -wibox_orientation_set(wibox_t *w, orientation_t o) +wibox_set_orientation(lua_State *L, int udx, orientation_t o) { + wibox_t *w = luaA_checkudata(L, udx, &wibox_class); if(o != w->orientation) { xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen); @@ -328,6 +381,7 @@ wibox_orientation_set(wibox_t *w, orientation_t o) if(w->pixmap != w->ctx.pixmap) xcb_free_pixmap(globalconf.connection, w->ctx.pixmap); wibox_draw_context_update(w, s); + luaA_object_emit_signal(L, udx, "property::orientation", 0); } } @@ -379,7 +433,7 @@ wibox_systray_refresh(wibox_t *wibox) xembed_window_t *em; int phys_screen = wibox->ctx.phys_screen; - if(wibox->isvisible + if(wibox->visible && systray->widget->isvisible && systray->geometry.width) { @@ -549,7 +603,7 @@ wibox_getbywin(xcb_window_t win) static void wibox_draw(wibox_t *wibox) { - if(wibox->isvisible) + if(wibox->visible) { widget_render(wibox); wibox_refresh_pixmap(wibox); @@ -586,16 +640,17 @@ wibox_refresh(void) * \param v The visible value. */ static void -wibox_setvisible(wibox_t *wibox, bool v) +wibox_set_visible(lua_State *L, int udx, bool v) { - if(v != wibox->isvisible) + wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class); + if(v != wibox->visible) { - wibox->isvisible = v; + wibox->visible = v; wibox->mouse_over = NULL; if(wibox->screen) { - if(wibox->isvisible) + if(wibox->visible) wibox_map(wibox); else xcb_unmap_window(globalconf.connection, wibox->window); @@ -604,6 +659,8 @@ wibox_setvisible(wibox_t *wibox, bool v) wibox_systray_refresh(wibox); } + luaA_object_emit_signal(L, udx, "property::visible", 0); + hook_property(wibox, "visible"); } } @@ -633,21 +690,23 @@ wibox_wipe(wibox_t *w) } /** Remove a wibox from a screen. - * \param wibox Wibox to detach from screen. + * \param L The Lua VM state. + * \param udx Wibox to detach from screen. */ static void -wibox_detach(wibox_t *wibox) +wibox_detach(lua_State *L, int udx) { + wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class); if(wibox->screen) { bool v; /* save visible state */ - v = wibox->isvisible; - wibox->isvisible = false; + v = wibox->visible; + wibox->visible = false; wibox_systray_refresh(wibox); /* restore visibility */ - wibox->isvisible = v; + wibox->visible = v; wibox->mouse_over = NULL; @@ -663,6 +722,7 @@ wibox_detach(wibox_t *wibox) hook_property(wibox, "screen"); wibox->screen = NULL; + luaA_object_emit_signal(L, udx, "property::screen", 0); luaA_object_unref(globalconf.L, wibox); } @@ -672,13 +732,16 @@ wibox_detach(wibox_t *wibox) * \param s The screen to attach the wibox to. */ static void -wibox_attach(screen_t *s) +wibox_attach(lua_State *L, int udx, screen_t *s) { int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s)); + /* duplicate wibox */ + lua_pushvalue(L, udx); + /* ref it */ wibox_t *wibox = luaA_object_ref(globalconf.L, -1); - wibox_detach(wibox); + wibox_detach(L, udx); /* Set the wibox screen */ wibox->screen = s; @@ -689,10 +752,10 @@ wibox_attach(screen_t *s) /* If it does not match, move it to the screen coordinates */ if(cscreen != wibox->screen) - wibox_moveresize(wibox, (area_t) { .x = s->geometry.x, - .y = s->geometry.y, - .width = wibox->geometry.width, - .height = wibox->geometry.height }); + wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x, + .y = s->geometry.y, + .width = wibox->geometry.width, + .height = wibox->geometry.height }); wibox_array_append(&globalconf.wiboxes, wibox); @@ -701,14 +764,16 @@ wibox_attach(screen_t *s) window_set_cursor(wibox->window, xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor))); - wibox_opacity_set(wibox, wibox->opacity); + if(wibox->opacity != -1) + window_opacity_set(wibox->window, wibox->opacity); - if(wibox->isvisible) + if(wibox->visible) wibox_map(wibox); else wibox_need_update(wibox); hook_property(wibox, "screen"); + luaA_object_emit_signal(L, udx, "property::screen", 0); } /** Create a new wibox. @@ -722,42 +787,32 @@ wibox_attach(screen_t *s) static int luaA_wibox_new(lua_State *L) { - wibox_t *w; - const char *buf; - size_t len; - xcolor_init_request_t reqs[3]; - int i, reqs_nbr = -1; + luaA_class_new(L, &wibox_class); - luaA_checktable(L, 2); + wibox_t *w = luaA_checkudata(L, -1, &wibox_class); - w = wibox_new(L); + if(!w->ctx.fg.initialized) + w->ctx.fg = globalconf.colors.fg; - w->ctx.fg = globalconf.colors.fg; - if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&w->ctx.fg, buf, len); + if(!w->ctx.bg.initialized) + w->ctx.bg = globalconf.colors.bg; - w->ctx.bg = globalconf.colors.bg; - if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&w->ctx.bg, buf, len); + if(!w->border_color.initialized) + w->border_color = globalconf.colors.bg; - w->border.color = globalconf.colors.bg; - if((buf = luaA_getopt_lstring(L, 2, "border_color", NULL, &len))) - reqs[++reqs_nbr] = xcolor_init_unchecked(&w->border.color, buf, len); + w->visible = true; - w->ontop = luaA_getopt_boolean(L, 2, "ontop", false); + if(!w->opacity) + w->opacity = -1; - w->opacity = -1; - w->border.width = luaA_getopt_number(L, 2, "border_width", 0); - w->geometry.x = luaA_getopt_number(L, 2, "x", 0); - w->geometry.y = luaA_getopt_number(L, 2, "y", 0); - w->geometry.width = luaA_getopt_number(L, 2, "width", 100); - w->geometry.height = luaA_getopt_number(L, 2, "height", globalconf.font->height * 1.5); + if(!w->cursor) + w->cursor = a_strdup("left_ptr"); - w->isvisible = true; - w->cursor = a_strdup("left_ptr"); + if(!w->geometry.width) + w->geometry.width = 1; - for(i = 0; i <= reqs_nbr; i++) - xcolor_init_reply(reqs[i]); + if(!w->geometry.height) + w->geometry.height = 1; return 1; } @@ -812,109 +867,6 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item) } } -/** 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 (titlebar). - * \lfield border_width Border width. - * \lfield border_color Border color. - * \lfield align The alignment (titlebar). - * \lfield fg Foreground color. - * \lfield bg Background color. - * \lfield bg_image Background image. - * \lfield position The position (titlebar). - * \lfield ontop On top of other windows. - * \lfield cursor The mouse cursor. - * \lfield visible Visibility. - * \lfield orientation The drawing orientation: east, north or south. - * \lfield widgets An array with all widgets drawn on this wibox. - * \lfield opacity The opacity of the wibox, between 0 and 1. - * \lfield mouse_enter A function to execute when the mouse enter the widget. - * \lfield mouse_leave A function to execute when the mouse leave the widget. - * \lfield shape_clip Image describing the window's content shape. - * \lfield shape_bounding Image describing the window's border shape. - */ -static int -luaA_wibox_index(lua_State *L) -{ - size_t len; - wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class); - const char *attr = luaL_checklstring(L, 2, &len); - - if(luaA_usemetatable(L, 1, 2)) - return 1; - - switch(a_tokenize(attr, len)) - { - case A_TK_VISIBLE: - lua_pushboolean(L, wibox->isvisible); - break; - case A_TK_CLIENT: - return luaA_object_push(L, client_getbytitlebar(wibox)); - case A_TK_SCREEN: - if(!wibox->screen) - return 0; - lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1); - break; - case A_TK_BORDER_WIDTH: - lua_pushnumber(L, wibox->border.width); - break; - case A_TK_BORDER_COLOR: - luaA_pushxcolor(L, wibox->border.color); - break; - case A_TK_ALIGN: - if(wibox->type == WIBOX_TYPE_NORMAL) - luaA_deprecate(L, "awful.wibox.align"); - lua_pushstring(L, draw_align_tostr(wibox->align)); - break; - case A_TK_FG: - luaA_pushxcolor(L, wibox->ctx.fg); - break; - case A_TK_BG: - luaA_pushxcolor(L, wibox->ctx.bg); - break; - case A_TK_BG_IMAGE: - luaA_object_push_item(L, 1, wibox->bg_image); - break; - case A_TK_POSITION: - if(wibox->type == WIBOX_TYPE_NORMAL) - luaA_deprecate(L, "awful.wibox.attach"); - lua_pushstring(L, position_tostr(wibox->position)); - break; - case A_TK_ONTOP: - lua_pushboolean(L, wibox->ontop); - break; - case A_TK_ORIENTATION: - lua_pushstring(L, orientation_tostr(wibox->orientation)); - break; - case A_TK_WIDGETS: - return luaA_object_push_item(L, 1, wibox->widgets_table); - case A_TK_CURSOR: - lua_pushstring(L, wibox->cursor); - break; - case A_TK_OPACITY: - if (wibox->opacity >= 0) - lua_pushnumber(L, wibox->opacity); - else - return 0; - break; - case A_TK_MOUSE_ENTER: - return luaA_object_push_item(L, 1, wibox->mouse_enter); - case A_TK_MOUSE_LEAVE: - return luaA_object_push_item(L, 1, wibox->mouse_leave); - case A_TK_SHAPE_BOUNDING: - return luaA_object_push_item(L, 1, wibox->shape.bounding); - case A_TK_SHAPE_CLIP: - return luaA_object_push_item(L, 1, wibox->shape.clip); - default: - return 0; - } - - return 1; -} - /* Set or get the wibox geometry. * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -937,213 +889,514 @@ luaA_wibox_geometry(lua_State *L) wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width); wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height); - switch(wibox->type) - { - case WIBOX_TYPE_TITLEBAR: - wibox_moveresize(wibox, (area_t) { .x = wibox->geometry.x, - .y = wibox->geometry.y, - .width = wingeom.width, - .height = wingeom.height }); - break; - case WIBOX_TYPE_NORMAL: - wibox_moveresize(wibox, wingeom); - break; - } + if(wingeom.width > 0 && wingeom.height > 0) + switch(wibox->type) + { + case WIBOX_TYPE_TITLEBAR: + wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x, + .y = wibox->geometry.y, + .width = wingeom.width, + .height = wingeom.height }); + break; + case WIBOX_TYPE_NORMAL: + wibox_moveresize(L, 1, wingeom); + break; + } } return luaA_pusharea(L, wibox->geometry); } -/** Wibox newindex. +LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean) +LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring) +LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean) +LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber) +LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor) + +static int +luaA_wibox_set_x(lua_State *L, wibox_t *wibox) +{ + wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1), + .y = wibox->geometry.y, + .width = wibox->geometry.width, + .height = wibox->geometry.height }); + return 0; +} + +static int +luaA_wibox_get_x(lua_State *L, wibox_t *wibox) +{ + lua_pushnumber(L, wibox->geometry.x); + return 1; +} + +static int +luaA_wibox_set_y(lua_State *L, wibox_t *wibox) +{ + wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x, + .y = luaL_checknumber(L, -1), + .width = wibox->geometry.width, + .height = wibox->geometry.height }); + return 0; +} + +static int +luaA_wibox_get_y(lua_State *L, wibox_t *wibox) +{ + lua_pushnumber(L, wibox->geometry.y); + return 1; +} + +static int +luaA_wibox_set_width(lua_State *L, wibox_t *wibox) +{ + int width = luaL_checknumber(L, -1); + if(width <= 0) + luaL_error(L, "invalid width"); + wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x, + .y = wibox->geometry.y, + .width = width, + .height = wibox->geometry.height }); + return 0; +} + +static int +luaA_wibox_get_width(lua_State *L, wibox_t *wibox) +{ + lua_pushnumber(L, wibox->geometry.width); + return 1; +} + +static int +luaA_wibox_set_height(lua_State *L, wibox_t *wibox) +{ + int height = luaL_checknumber(L, -1); + if(height <= 0) + luaL_error(L, "invalid height"); + wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x, + .y = wibox->geometry.y, + .width = wibox->geometry.width, + .height = height }); + return 0; +} + +static int +luaA_wibox_get_height(lua_State *L, wibox_t *wibox) +{ + lua_pushnumber(L, wibox->geometry.height); + return 1; +} + +/** Set the wibox foreground color. * \param L The Lua VM state. + * \param wibox The wibox object. * \return The number of elements pushed on stack. */ static int -luaA_wibox_newindex(lua_State *L) +luaA_wibox_set_fg(lua_State *L, wibox_t *wibox) { size_t len; - wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class); - const char *buf, *attr = luaL_checklstring(L, 2, &len); - awesome_token_t tok; + const char *buf = luaL_checklstring(L, -1, &len); + if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len))) + wibox->need_update = true; + luaA_object_emit_signal(L, -3, "property::fg", 0); + return 0; +} - switch((tok = a_tokenize(attr, len))) - { - bool b; +/** Get the wibox foreground color. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_fg(lua_State *L, wibox_t *wibox) +{ + return luaA_pushxcolor(L, wibox->ctx.fg); +} - case A_TK_FG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len))) - wibox->need_update = true; - break; - case A_TK_BG: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len))) - wibox->need_update = true; - break; - case A_TK_BG_IMAGE: - luaA_object_unref_item(L, 1, wibox->bg_image); - wibox->bg_image = luaA_object_ref_item(L, 1, 3); +/** Set the wibox background color. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_bg(lua_State *L, wibox_t *wibox) +{ + size_t len; + const char *buf = luaL_checklstring(L, -1, &len); + if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len))) wibox->need_update = true; + luaA_object_emit_signal(L, -3, "property::bg", 0); + return 0; +} + +/** Get the wibox background color. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_bg(lua_State *L, wibox_t *wibox) +{ + return luaA_pushxcolor(L, wibox->ctx.bg); +} + +/** Set the wibox background image. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox) +{ + luaA_checkudata(L, -1, &image_class); + luaA_object_unref_item(L, -3, wibox->bg_image); + wibox->bg_image = luaA_object_ref_item(L, -3, -1); + wibox->need_update = true; + luaA_object_emit_signal(L, -2, "property::bg_image", 0); + return 0; +} + +/** Get the wibox background image. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox) +{ + return luaA_object_push_item(L, 1, wibox->bg_image); +} + +/** Set the wibox on top status. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox) +{ + bool b = luaA_checkboolean(L, -1); + if(b != wibox->ontop) + { + wibox->ontop = b; + client_stack(); + luaA_object_emit_signal(L, -3, "property::ontop", 0); + } + return 0; +} + +/** Set the wibox opacity. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox) +{ + if(lua_isnil(L, -1)) + wibox_opacity_set(L, -3, -1); + else + { + double d = luaL_checknumber(L, -1); + if(d >= 0 && d <= 1) + wibox_opacity_set(L, -3, d); + } + return 0; +} + +/** Get the wibox opacity. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox) +{ + if (wibox->opacity >= 0) + { + lua_pushnumber(L, wibox->opacity); + return 1; + } + return 0; +} + +/** Set the wibox alignment. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_align(lua_State *L, wibox_t *wibox) +{ + size_t len; + const char *buf = luaL_checklstring(L, -1, &len); + wibox->align = draw_align_fromstr(buf, len); + luaA_object_emit_signal(L, -3, "property::align", 0); + switch(wibox->type) + { + case WIBOX_TYPE_NORMAL: + luaA_deprecate(L, "awful.wibox.align"); break; - case A_TK_ALIGN: - buf = luaL_checklstring(L, 3, &len); - wibox->align = draw_align_fromstr(buf, len); - switch(wibox->type) - { - case WIBOX_TYPE_NORMAL: - luaA_deprecate(L, "awful.wibox.align"); - break; - case WIBOX_TYPE_TITLEBAR: - titlebar_update_geometry(client_getbytitlebar(wibox)); - break; - } + case WIBOX_TYPE_TITLEBAR: + titlebar_update_geometry(client_getbytitlebar(wibox)); break; - case A_TK_POSITION: - switch(wibox->type) - { - case WIBOX_TYPE_NORMAL: - if((buf = luaL_checklstring(L, 3, &len))) - { - luaA_deprecate(L, "awful.wibox.attach"); - wibox->position = position_fromstr(buf, len); - } - break; - case WIBOX_TYPE_TITLEBAR: - return luaA_titlebar_newindex(L, wibox, tok); - } - break; - case A_TK_CLIENT: - /* first detach */ - if(lua_isnil(L, 3)) - titlebar_client_detach(client_getbytitlebar(wibox)); - else + } + return 0; +} + +/** Get the wibox alignment. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_align(lua_State *L, wibox_t *wibox) +{ + if(wibox->type == WIBOX_TYPE_NORMAL) + luaA_deprecate(L, "awful.wibox.align"); + lua_pushstring(L, draw_align_tostr(wibox->align)); + return 1; +} + +/** Set the wibox position. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_position(lua_State *L, wibox_t *wibox) +{ + switch(wibox->type) + { + case WIBOX_TYPE_NORMAL: + { + size_t len; + const char *buf; + if((buf = luaL_checklstring(L, -1, &len))) { - client_t *c = luaA_client_checkudata(L, -1); - lua_pushvalue(L, 1); - titlebar_client_attach(c); + luaA_deprecate(L, "awful.wibox.attach"); + wibox->position = position_fromstr(buf, len); } - break; - case A_TK_CURSOR: - if((buf = luaL_checkstring(L, 3))) + } + break; + case WIBOX_TYPE_TITLEBAR: + return luaA_titlebar_set_position(L, -3); + } + return 0; +} + +/** Get the wibox position. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_position(lua_State *L, wibox_t *wibox) +{ + if(wibox->type == WIBOX_TYPE_NORMAL) + luaA_deprecate(L, "awful.wibox.attach"); + lua_pushstring(L, position_tostr(wibox->position)); + return 1; +} + +/** Set the wibox (titlebar) client. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_client(lua_State *L, wibox_t *wibox) +{ + /* first detach */ + if(lua_isnil(L, -1)) + titlebar_client_detach(client_getbytitlebar(wibox)); + else + { + client_t *c = luaA_client_checkudata(L, -1); + lua_pushvalue(L, -3); + titlebar_client_attach(c); + } + return 0; +} + +/** Get the wibox (titlebar) client. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_client(lua_State *L, wibox_t *wibox) +{ + return luaA_object_push(L, client_getbytitlebar(wibox)); +} + +/** Set the wibox cursor. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox) +{ + const char *buf = luaL_checkstring(L, -1); + if(buf) + { + uint16_t cursor_font = xcursor_font_fromstr(buf); + if(cursor_font) { - uint16_t cursor_font = xcursor_font_fromstr(buf); - if(cursor_font) - { - xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font); - p_delete(&wibox->cursor); - wibox->cursor = a_strdup(buf); - window_set_cursor(wibox->window, cursor); - } + xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font); + p_delete(&wibox->cursor); + wibox->cursor = a_strdup(buf); + window_set_cursor(wibox->window, cursor); + luaA_object_emit_signal(L, -3, "property::cursor", 0); } - break; - case A_TK_SCREEN: - if(lua_isnil(L, 3)) + } + return 0; +} + +/** Set the wibox screen. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_screen(lua_State *L, wibox_t *wibox) +{ + if(lua_isnil(L, -1)) + { + wibox_detach(L, -3); + titlebar_client_detach(client_getbytitlebar(wibox)); + } + else + { + int screen = luaL_checknumber(L, -1) - 1; + luaA_checkscreen(screen); + if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen)) { - wibox_detach(wibox); titlebar_client_detach(client_getbytitlebar(wibox)); + wibox_attach(L, -3, &globalconf.screens.tab[screen]); } - else - { - int screen = luaL_checknumber(L, 3) - 1; - luaA_checkscreen(screen); - if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen)) - { - titlebar_client_detach(client_getbytitlebar(wibox)); - lua_pushvalue(L, 1); - wibox_attach(&globalconf.screens.tab[screen]); - } - } - break; - case A_TK_ONTOP: - b = luaA_checkboolean(L, 3); - if(b != wibox->ontop) - { - wibox->ontop = b; - client_stack(); - } - break; - case A_TK_ORIENTATION: - if((buf = luaL_checklstring(L, 3, &len))) - { - wibox_orientation_set(wibox, orientation_fromstr(buf, len)); - wibox_need_update(wibox); - } - break; - case A_TK_BORDER_COLOR: - if((buf = luaL_checklstring(L, 3, &len))) - if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border.color, buf, len))) - if(wibox->window) - wibox_border_color_set(wibox, &wibox->border.color); - break; - case A_TK_VISIBLE: - b = luaA_checkboolean(L, 3); - if(b != wibox->isvisible) - switch(wibox->type) - { - case WIBOX_TYPE_NORMAL: - wibox_setvisible(wibox, b); - break; - case WIBOX_TYPE_TITLEBAR: - titlebar_set_visible(wibox, b); - break; - } - break; - case A_TK_WIDGETS: - if(luaA_isloop(L, 3)) - { - luaA_warn(L, "table is looping, cannot use this as widget table"); - return 0; - } - /* duplicate table because next function will eat it */ - lua_pushvalue(L, 3); - /* register object */ - wibox->widgets_table = luaA_object_ref_item(L, 1, -1); - wibox_need_update(wibox); - luaA_table2wtable(L); - break; - case A_TK_OPACITY: - if(lua_isnil(L, 3)) - wibox_opacity_set(wibox, -1); - else - { - double d = luaL_checknumber(L, 3); - if(d >= 0 && d <= 1) - wibox_opacity_set(wibox, d); - } - break; - case A_TK_MOUSE_ENTER: - luaA_checkfunction(L, 3); - luaA_object_unref_item(L, 1, wibox->mouse_enter); - wibox->mouse_enter = luaA_object_ref_item(L, 1, 3); - return 0; - case A_TK_MOUSE_LEAVE: - luaA_checkfunction(L, 3); - luaA_object_unref_item(L, 1, wibox->mouse_leave); - wibox->mouse_leave = luaA_object_ref_item(L, 1, 3); + } + return 0; +} + +/** Get the wibox screen. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_screen(lua_State *L, wibox_t *wibox) +{ + if(!wibox->screen) return 0; - case A_TK_SHAPE_BOUNDING: - luaA_object_unref_item(L, 1, wibox->shape.bounding); - wibox->shape.bounding = luaA_object_ref_item(L, 1, 3); - wibox->need_shape_update = true; - break; - case A_TK_SHAPE_CLIP: - luaA_object_unref_item(L, 1, wibox->shape.clip); - wibox->shape.clip = luaA_object_ref_item(L, 1, 3); - wibox->need_shape_update = true; - break; - default: + lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1); + return 1; +} + +/** Set the wibox orientation. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox) +{ + size_t len; + const char *buf = luaL_checklstring(L, -1, &len); + if(buf) + { + wibox_set_orientation(L, -3, orientation_fromstr(buf, len)); + wibox_need_update(wibox); + } + return 0; +} + +/** Get the wibox orientation. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox) +{ + lua_pushstring(L, orientation_tostr(wibox->orientation)); + return 1; +} + +/** Set the wibox border color. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox) +{ + size_t len; + const char *buf = luaL_checklstring(L, -1, &len); + if(buf) + if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len))) + if(wibox->window) + wibox_set_border_color(L, -3, &wibox->border_color); + return 0; +} + +/** Set the wibox visibility. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_visible(lua_State *L, wibox_t *wibox) +{ + bool b = luaA_checkboolean(L, -1); + if(b != wibox->visible) switch(wibox->type) { - case WIBOX_TYPE_TITLEBAR: - return luaA_titlebar_newindex(L, wibox, tok); case WIBOX_TYPE_NORMAL: + wibox_set_visible(L, -3, b); + break; + case WIBOX_TYPE_TITLEBAR: + titlebar_set_visible(wibox, b); break; } - } + return 0; +} +/** Set the wibox widgets. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox) +{ + if(luaA_isloop(L, -1)) + { + luaA_warn(L, "table is looping, cannot use this as widget table"); + return 0; + } + /* duplicate table because next function will eat it */ + lua_pushvalue(L, -1); + wibox->widgets_table = luaA_object_ref_item(L, -4, -1); + luaA_object_emit_signal(L, -3, "property::widgets", 0); + wibox_need_update(wibox); + luaA_table2wtable(L); return 0; } +/** Get the wibox widgets. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox) +{ + return luaA_object_push_item(L, 1, wibox->widgets_table); +} + /** Get or set mouse buttons bindings to a wibox. * \param L The Lua VM state. * \luastack @@ -1159,27 +1412,162 @@ luaA_wibox_buttons(lua_State *L) if(lua_gettop(L) == 2) { luaA_button_array_set(L, 1, 2, &wibox->buttons); - return 1; + luaA_object_emit_signal(L, 1, "property::buttons", 0); } return luaA_button_array_get(L, 1, &wibox->buttons); } -const struct luaL_reg awesome_wibox_methods[] = +/** Set the wibox border width. + * \param L The Lua VM state. + * \param wibox The wibox object. + * \return The number of elements pushed on stack. + */ +static int +luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox) { - LUA_CLASS_METHODS(wibox) - { "__call", luaA_wibox_new }, - { NULL, NULL } -}; -const struct luaL_reg awesome_wibox_meta[] = + wibox_set_border_width(L, -3, luaL_checknumber(L, -1)); + return 0; +} + +static int +luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox) { - LUA_OBJECT_META(wibox) - { "buttons", luaA_wibox_buttons }, - { "geometry", luaA_wibox_geometry }, - { "__index", luaA_wibox_index }, - { "__newindex", luaA_wibox_newindex }, - { "__gc", luaA_wibox_gc }, - { NULL, NULL }, -}; + luaA_object_unref_item(L, -3, wibox->shape.bounding); + wibox->shape.bounding = luaA_object_ref_item(L, -3, -1); + wibox->need_shape_update = true; + luaA_object_emit_signal(L, -2, "property::shape_bounding", 0); + return 0; +} + +static int +luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox) +{ + return luaA_object_push_item(L, 1, wibox->shape.bounding); +} + +static int +luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox) +{ + luaA_object_unref_item(L, -3, wibox->shape.clip); + wibox->shape.clip = luaA_object_ref_item(L, -3, -1); + wibox->need_shape_update = true; + luaA_object_emit_signal(L, -2, "property::shape_clip", 0); + return 0; +} + +static int +luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox) +{ + return luaA_object_push_item(L, 1, wibox->shape.clip); +} + +void +wibox_class_setup(lua_State *L) +{ + static const struct luaL_reg wibox_methods[] = + { + LUA_CLASS_METHODS(wibox) + { "__call", luaA_wibox_new }, + { NULL, NULL } + }; + + static const struct luaL_reg wibox_meta[] = + { + LUA_OBJECT_META(wibox) + LUA_CLASS_META + { "buttons", luaA_wibox_buttons }, + { "geometry", luaA_wibox_geometry }, + { "__gc", luaA_wibox_gc }, + { NULL, NULL }, + }; + + luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new, + wibox_methods, wibox_meta); + luaA_class_add_property(&wibox_class, A_TK_WIDGETS, + (lua_class_propfunc_t) luaA_wibox_set_widgets, + (lua_class_propfunc_t) luaA_wibox_get_widgets, + (lua_class_propfunc_t) luaA_wibox_set_widgets); + luaA_class_add_property(&wibox_class, A_TK_OPACITY, + (lua_class_propfunc_t) luaA_wibox_set_opacity, + (lua_class_propfunc_t) luaA_wibox_get_opacity, + (lua_class_propfunc_t) luaA_wibox_set_opacity); + luaA_class_add_property(&wibox_class, A_TK_VISIBLE, + (lua_class_propfunc_t) luaA_wibox_set_visible, + (lua_class_propfunc_t) luaA_wibox_get_visible, + (lua_class_propfunc_t) luaA_wibox_set_visible); + luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR, + (lua_class_propfunc_t) luaA_wibox_set_border_color, + (lua_class_propfunc_t) luaA_wibox_get_border_color, + (lua_class_propfunc_t) luaA_wibox_set_border_color); + luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH, + (lua_class_propfunc_t) luaA_wibox_set_border_width, + (lua_class_propfunc_t) luaA_wibox_get_border_width, + (lua_class_propfunc_t) NULL); + luaA_class_add_property(&wibox_class, A_TK_ORIENTATION, + (lua_class_propfunc_t) luaA_wibox_set_orientation, + (lua_class_propfunc_t) luaA_wibox_get_orientation, + (lua_class_propfunc_t) luaA_wibox_set_orientation); + luaA_class_add_property(&wibox_class, A_TK_ONTOP, + (lua_class_propfunc_t) luaA_wibox_set_ontop, + (lua_class_propfunc_t) luaA_wibox_get_ontop, + (lua_class_propfunc_t) luaA_wibox_set_ontop); + luaA_class_add_property(&wibox_class, A_TK_SCREEN, + NULL, + (lua_class_propfunc_t) luaA_wibox_get_screen, + (lua_class_propfunc_t) luaA_wibox_set_screen); + luaA_class_add_property(&wibox_class, A_TK_CURSOR, + (lua_class_propfunc_t) luaA_wibox_set_cursor, + (lua_class_propfunc_t) luaA_wibox_get_cursor, + (lua_class_propfunc_t) luaA_wibox_set_cursor); + luaA_class_add_property(&wibox_class, A_TK_CLIENT, + (lua_class_propfunc_t) luaA_wibox_set_client, + (lua_class_propfunc_t) luaA_wibox_get_client, + (lua_class_propfunc_t) luaA_wibox_set_client); + luaA_class_add_property(&wibox_class, A_TK_POSITION, + (lua_class_propfunc_t) luaA_wibox_set_position, + (lua_class_propfunc_t) luaA_wibox_get_position, + (lua_class_propfunc_t) luaA_wibox_set_position); + luaA_class_add_property(&wibox_class, A_TK_ALIGN, + (lua_class_propfunc_t) luaA_wibox_set_align, + (lua_class_propfunc_t) luaA_wibox_get_align, + (lua_class_propfunc_t) luaA_wibox_set_align); + luaA_class_add_property(&wibox_class, A_TK_FG, + (lua_class_propfunc_t) luaA_wibox_set_fg, + (lua_class_propfunc_t) luaA_wibox_get_fg, + (lua_class_propfunc_t) luaA_wibox_set_fg); + luaA_class_add_property(&wibox_class, A_TK_BG, + (lua_class_propfunc_t) luaA_wibox_set_bg, + (lua_class_propfunc_t) luaA_wibox_get_bg, + (lua_class_propfunc_t) luaA_wibox_set_bg); + luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE, + (lua_class_propfunc_t) luaA_wibox_set_bg_image, + (lua_class_propfunc_t) luaA_wibox_get_bg_image, + (lua_class_propfunc_t) luaA_wibox_set_bg_image); + luaA_class_add_property(&wibox_class, A_TK_X, + (lua_class_propfunc_t) luaA_wibox_set_x, + (lua_class_propfunc_t) luaA_wibox_get_x, + (lua_class_propfunc_t) luaA_wibox_set_x); + luaA_class_add_property(&wibox_class, A_TK_Y, + (lua_class_propfunc_t) luaA_wibox_set_y, + (lua_class_propfunc_t) luaA_wibox_get_y, + (lua_class_propfunc_t) luaA_wibox_set_y); + luaA_class_add_property(&wibox_class, A_TK_WIDTH, + (lua_class_propfunc_t) luaA_wibox_set_width, + (lua_class_propfunc_t) luaA_wibox_get_width, + (lua_class_propfunc_t) luaA_wibox_set_width); + luaA_class_add_property(&wibox_class, A_TK_HEIGHT, + (lua_class_propfunc_t) luaA_wibox_set_height, + (lua_class_propfunc_t) luaA_wibox_get_height, + (lua_class_propfunc_t) luaA_wibox_set_height); + luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING, + (lua_class_propfunc_t) luaA_wibox_set_shape_bounding, + (lua_class_propfunc_t) luaA_wibox_get_shape_bounding, + (lua_class_propfunc_t) luaA_wibox_set_shape_bounding); + luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP, + (lua_class_propfunc_t) luaA_wibox_set_shape_clip, + (lua_class_propfunc_t) luaA_wibox_get_shape_clip, + (lua_class_propfunc_t) luaA_wibox_set_shape_clip); +} // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/wibox.h b/wibox.h index 432d79db..33a4197b 100644 --- a/wibox.h +++ b/wibox.h @@ -39,7 +39,7 @@ struct wibox_t /** Ontop */ bool ontop; /** Visible */ - bool isvisible; + bool visible; /** Position */ position_t position; /** Wibox type */ @@ -53,8 +53,6 @@ struct wibox_t void *widgets_table; /** Widget the mouse is over */ widget_t *mouse_over; - /** Mouse over event handler */ - void *mouse_enter, *mouse_leave; /** Need update */ bool need_update; /** Need shape update */ @@ -75,14 +73,10 @@ struct wibox_t xcb_gcontext_t gc; /** The window geometry. */ area_t geometry; - /** The window border */ - struct - { - /** The window border width */ - uint16_t width; - /** The window border color */ - xcolor_t color; - } border; + /** The window border width */ + uint16_t border_width; + /** The window border color */ + xcolor_t border_color; /** Draw context */ draw_context_t ctx; /** Orientation */ @@ -109,16 +103,16 @@ void luaA_wibox_invalidate_byitem(lua_State *, const void *); wibox_t * wibox_getbywin(xcb_window_t); -void wibox_moveresize(wibox_t *, area_t); +void wibox_moveresize(lua_State *, int, area_t); void wibox_refresh_pixmap_partial(wibox_t *, int16_t, int16_t, uint16_t, uint16_t); void wibox_init(wibox_t *, int); void wibox_wipe(wibox_t *); -void wibox_border_width_set(wibox_t *, uint32_t); -void wibox_border_color_set(wibox_t *, const xcolor_t *); -void wibox_orientation_set(wibox_t *, orientation_t); +void wibox_set_opacity(lua_State *, int, double); +void wibox_set_orientation(lua_State *, int, orientation_t); + +void wibox_class_setup(lua_State *); lua_class_t wibox_class; -LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox) #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 -- 2.11.4.GIT