Crylia / crylia-theme

A theme for AwesomeWM
523 stars 26 forks source link

[BUG] layout_box does not work on secondary screen #36

Closed psimovec closed 1 year ago

psimovec commented 1 year ago

Describe the bug Layout_box does not work on multiple monitors, it works properly only on the first monitor. Visually it is the same on every screen as on the first screen.

I have fixed the problem and included the patch on bottom of the post, just so you get the idea. If you think this patch should be added to your repo, I can make a pull request.

To Reproduce Steps to reproduce the behavior: prerequisity: Connect more screens/monitors to your PC.

  1. Change layout with shortcut or click layout_box widget on the secondary monitor -> clicking doesn't do anything, changing layout by shortcut doesn't visually change the icon on the screen

or

  1. Change layout on screen 1 -> layout_box icon changes on all screens (unexpected), but layout changes only on screen 1 (as expected)

Expected behavior Layout_box functionality should be linked to specific screen and to work on each screen.

Information (please complete the following information):

Additional context git diff of my fix, line numbers might not match.

diff --git a/crylia_bar/init.lua b/crylia_bar/init.lua
index f8b83c2..de6779d 100644
--- a/crylia_bar/init.lua
+++ b/crylia_bar/init.lua
@@ -31,7 +31,7 @@ awful.screen.connect_for_each_screen(
   s.date = require("src.widgets.date")()
   s.clock = require("src.widgets.clock")()
   --s.bluetooth = require("src.widgets.bluetooth")()
-  s.layoutlist = require("src.widgets.layout_list")()
+  s.layoutlist = require("src.widgets.layout_list")(s)
   s.powerbutton = require("src.widgets.power")()
   s.kblayout = require("src.widgets.kblayout")(s)
   s.taglist = require("src.widgets.taglist")(s)
diff --git a/src/widgets/layout_list.lua b/src/widgets/layout_list.lua
index bb28d1c..1fc4149 100644
--- a/src/widgets/layout_list.lua
+++ b/src/widgets/layout_list.lua
@@ -11,11 +11,11 @@ local wibox = require("wibox")
 require("src.core.signals")

 -- Returns the layoutbox widget
-return function()
+return function(s)
   local layout = wibox.widget {
     {
       {
-        awful.widget.layoutbox(),
+        awful.widget.layoutbox(s),
         id = "icon_layout",
         widget = wibox.container.place
       },
@@ -29,7 +29,8 @@ return function()
     shape = function(cr, width, height)
       gears.shape.rounded_rect(cr, width, height, 5)
     end,
-    widget = wibox.container.background
+    widget = wibox.container.background,
+    screen = s
   }

   -- Signals
@@ -38,7 +39,7 @@ return function()
   layout:connect_signal(
     "button::press",
     function()
-      awful.layout.inc(-1)
+      awful.layout.inc(-1, s)
     end
   )

P.S. I really like your awesome wm theme, thanks for sharing!

Crylia commented 1 year ago

Hey thanks for the added fix, if you want you can create a PR and I'll merge it later once I got time 👍