From 780f63f1a047d9e70ed4f0f9a4f435644bb7c186 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Mon, 18 Apr 2022 15:54:23 +0400 Subject: [PATCH] Removed duplicated context menus for windows --- core/layout.lua | 1 - core/titlebar.lua | 146 +++++++++++++++++++++++----------------------- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/core/layout.lua b/core/layout.lua index 05b6468..8dbe5b0 100644 --- a/core/layout.lua +++ b/core/layout.lua @@ -34,7 +34,6 @@ require("core.widgets.menubar") awful.screen.connect_for_each_screen(function(s) -- Wallpaper set_wallpaper(s) - -- Each screen has its own tag table. awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) diff --git a/core/titlebar.lua b/core/titlebar.lua index 45662df..958f5d6 100644 --- a/core/titlebar.lua +++ b/core/titlebar.lua @@ -2,87 +2,89 @@ local awful = require("awful") local gears = require("gears") local wibox = require("wibox") local menu = require("widgets.polymenu") -local move_screentags = {} -local toggle_screentags = {} -awful.screen.connect_for_each_screen(function(s) - local move_tags = {} - local toggle_tags = {} - for _,tag in pairs(s.tags) do - table.insert(move_tags,{ - tag.name, - function() - if client.focus then - client.focus:tags({tag}) +-- To conserve memory we keep one menu at a time +if not menu_widget then + local move_screentags = {} + local toggle_screentags = {} + awful.screen.connect_for_each_screen(function(s) + local move_tags = {} + local toggle_tags = {} + for _,tag in pairs(s.tags) do + table.insert(move_tags,{ + tag.name, + function() + if client.focus then + client.focus:tags({tag}) + end end - end - }) - table.insert(toggle_tags,{ - tag.name, - function() - if client.focus then - local tags = client.focus:tags() - for k,v in pairs(tags) do - if v == tag then - table.remove(tags,k) - client.focus:tags(tags) - return + }) + table.insert(toggle_tags,{ + tag.name, + function() + if client.focus then + local tags = client.focus:tags() + for k,v in pairs(tags) do + if v == tag then + table.remove(tags,k) + client.focus:tags(tags) + return + end end + table.insert(tags,tag) + client.focus:tags(tags) end - table.insert(tags,tag) - client.focus:tags(tags) end - end + }) + end + table.insert(move_screentags,{ + "Screen "..tostring(s.index), + move_tags }) - end - table.insert(move_screentags,{ - "Screen "..tostring(s.index), - move_tags - }) - table.insert(toggle_screentags,{ - "Screen "..tostring(s.index), - toggle_tags - }) -end) -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 - }, - after = { - require("widgets.client-volume")({}) - }, - items = { - { "Move to tag" , - move_screentags - }, - { "Toggle on tag", - toggle_screentags - }, - { "Stop task", - function() - awful.spawn("kill "..tostring(c.pid)) - end + table.insert(toggle_screentags,{ + "Screen "..tostring(s.index), + toggle_tags + }) + end) + controls_widget = wibox.widget { + forced_width = 72, + forced_height = 24, + layout = wibox.layout.fixed.horizontal, + } + menu_widget = menu({ + before = { + controls_widget }, - { "Kill task", - function() - awful.spawn("kill -s KILL "..tostring(c.pid)) - end + after = { + require("widgets.client-volume")({}) }, - { "Debug info", - { - before = { - require("widgets.window-debug")() + items = { + { "Move to tag" , + move_screentags + }, + { "Toggle on tag", + toggle_screentags + }, + { "Stop task", + function() + awful.spawn("kill "..tostring(c.pid)) + end + }, + { "Kill task", + function() + awful.spawn("kill -s KILL "..tostring(c.pid)) + end + }, + { "Debug info", + { + before = { + require("widgets.window-debug")() + } } } - } - }, - vertical = true -}) + }, + vertical = true + }) +end return function(c) local buttons = gears.table.join(