Fixed "undead" window menus and made the windows use less resources

This commit is contained in:
Yessiest 2022-03-21 13:15:49 +00:00
parent 5a78139515
commit 8166cca713
1 changed files with 46 additions and 34 deletions

View File

@ -43,27 +43,15 @@ awful.screen.connect_for_each_screen(function(s)
toggle_tags
})
end)
return function(c)
local buttons = gears.table.join(
awful.button({ }, 1, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.resize(c)
end)
)
c.menu = menu({
before = {
{
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
local controls_widget = wibox.widget {
forced_width = 72,
forced_height = 24,
layout = wibox.layout.fixed.horizontal,
}
-- To conserve memory we keep one menu at a time
local menu_widget = menu({
before = {
controls_widget
},
items = {
{ "Move to tag" ,
@ -85,14 +73,38 @@ return function(c)
},
vertical = true
})
return function(c)
local buttons = gears.table.join(
awful.button({ }, 1, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.resize(c)
end)
)
c.menu_button = awful.titlebar.widget.iconwidget(c)
-- A little trick we do to conserve memory and cpu usage on regenerating
-- buttons is we pop up a menu in the location of the icon
-- and insert buttons into the controls widget layout.
c.hidden_floatingbutton = awful.titlebar.widget.floatingbutton(c)
c.hidden_stickybutton = awful.titlebar.widget.stickybutton(c)
c.hidden_ontopbutton = awful.titlebar.widget.ontopbutton(c)
c.menu_button:connect_signal("button::press", function()
c.menu.toggle()
menu_widget.toggle()
if controls_widget then
controls_widget:reset()
controls_widget:add(c.hidden_floatingbutton)
controls_widget:add(c.hidden_stickybutton)
controls_widget:add(c.hidden_ontopbutton)
end
c:emit_signal("request::activate", "titlebar", {raise = true})
end)
c:connect_signal("unfocus",function()
if c.menu.visible then
c.menu.toggle(0,0)
if menu_widget.visible then
menu_widget.toggle(0,0)
end
end)
return awful.titlebar(c) : setup {