awful.menu: store active child
This fix the menu when they are multiple submenu entries. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
ca38f96625
commit
0cddba4d82
|
@ -56,7 +56,6 @@ end
|
||||||
--- Hide a menu popup.
|
--- Hide a menu popup.
|
||||||
-- @param menu The menu to hide.
|
-- @param menu The menu to hide.
|
||||||
function hide(menu)
|
function hide(menu)
|
||||||
if menu then
|
|
||||||
-- Remove items from screen
|
-- Remove items from screen
|
||||||
for i = 1, #menu.items do
|
for i = 1, #menu.items do
|
||||||
-- Call mouse_leave to clear menu entry
|
-- Call mouse_leave to clear menu entry
|
||||||
|
@ -65,7 +64,9 @@ function hide(menu)
|
||||||
end
|
end
|
||||||
menu.items[i].screen = nil
|
menu.items[i].screen = nil
|
||||||
end
|
end
|
||||||
hide(menu.child)
|
if menu.active_child then
|
||||||
|
menu.active_child:hide()
|
||||||
|
active_child = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,15 +81,19 @@ end
|
||||||
|
|
||||||
local function exec(data, action, num)
|
local function exec(data, action, num)
|
||||||
if type(action[2]) == "table" then
|
if type(action[2]) == "table" then
|
||||||
if not data.child then
|
if not data.child[num] then
|
||||||
data.child = new({ items=action[2] }, data, num)
|
data.child[num] = new({ items = action[2] }, data, num)
|
||||||
end
|
end
|
||||||
data.child:show()
|
if data.active_child then
|
||||||
|
data.active_child:hide()
|
||||||
|
end
|
||||||
|
data.active_child = data.child[num]
|
||||||
|
data.active_child:show()
|
||||||
elseif type(action[2]) == "string" then
|
elseif type(action[2]) == "string" then
|
||||||
hide(get_parents(data))
|
get_parents(data):hide()
|
||||||
util.spawn(action[2])
|
util.spawn(action[2])
|
||||||
elseif type(action[2]) == "function" then
|
elseif type(action[2]) == "function" then
|
||||||
hide(get_parents(data))
|
get_parents(data):hide()
|
||||||
action[2]()
|
action[2]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -250,6 +255,7 @@ function new(menu, parent, num)
|
||||||
data.num = num or 1
|
data.num = num or 1
|
||||||
data.theme = parent and parent.theme or load_theme(menu)
|
data.theme = parent and parent.theme or load_theme(menu)
|
||||||
data.parent = parent
|
data.parent = parent
|
||||||
|
data.child = {}
|
||||||
data.h = parent and parent.h or data.theme.menu_height
|
data.h = parent and parent.h or data.theme.menu_height
|
||||||
data.w = parent and parent.w or data.theme.menu_width
|
data.w = parent and parent.w or data.theme.menu_width
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue