mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
wibox: port to new object system
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
a916f2cd55
commit
84839d456d
12 changed files with 954 additions and 646 deletions
|
@ -120,3 +120,5 @@ word
|
|||
word_char
|
||||
workarea
|
||||
wrap
|
||||
x
|
||||
y
|
||||
|
|
20
event.c
20
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))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
5
luaa.c
5
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
151
titlebar.c
151
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);
|
||||
break;
|
||||
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, North);
|
||||
break;
|
||||
case Right:
|
||||
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:
|
||||
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, 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_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;
|
||||
}
|
||||
|
||||
|
|
13
titlebar.h
13
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
|
||||
|
|
26
wibox.h
26
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
|
||||
|
|
Loading…
Reference in a new issue