From 6fb36b2df2aeb5d32fd7e83f473ecf9f1f091dea Mon Sep 17 00:00:00 2001 From: elenapan Date: Thu, 19 Mar 2020 04:36:15 +0200 Subject: [PATCH] Improve widgets when used with multiple monitors A dimmed screen mask is added to non primary screens when the widget becomes visible. Affected widgets: - App drawer - Dashboard --- config/awesome/elemental/app_drawer.lua | 23 +++++++++++++++------- config/awesome/elemental/dashboard.lua | 25 ++++++++++++++++-------- config/awesome/elemental/lock_screen.lua | 11 +---------- config/awesome/helpers.lua | 9 +++++++++ 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/config/awesome/elemental/app_drawer.lua b/config/awesome/elemental/app_drawer.lua index 9174f71..37e8dc5 100644 --- a/config/awesome/elemental/app_drawer.lua +++ b/config/awesome/elemental/app_drawer.lua @@ -95,16 +95,25 @@ app_drawer.bg = "#00000000" -- app_drawer.bg = beautiful.app_drawer_bg or x.background or "#111111" app_drawer.fg = beautiful.app_drawer_fg or x.foreground or "#FEFEFE" --- Create an container box --- local app_drawer_box = wibox.container.background() --- app_drawer_box.bg = app_drawer.bg --- app_drawer_box.shape = gears.shape.rounded_rect --- app_drawer_box.shape_border_radius = 20 +-- Add app drawer or mask to each screen +for s in screen do + if s == screen.primary then + s.app_drawer = app_drawer + else + s.app_drawer = helpers.screen_mask(s, beautiful.lock_screen_bg or beautiful.exit_screen_bg or x.background) + end +end + +local function set_visibility(v) + for s in screen do + s.app_drawer.visible = v + end +end local app_drawer_grabber function app_drawer_hide() awful.keygrabber.stop(app_drawer_grabber) - app_drawer.visible = false + set_visibility(false) end function app_drawer_show() @@ -134,7 +143,7 @@ function app_drawer_show() end end) - app_drawer.visible = true + set_visibility(true) end app_drawer:buttons(gears.table.join( diff --git a/config/awesome/elemental/dashboard.lua b/config/awesome/elemental/dashboard.lua index 1f6a067..de76a9b 100644 --- a/config/awesome/elemental/dashboard.lua +++ b/config/awesome/elemental/dashboard.lua @@ -16,17 +16,26 @@ local screen_width = awful.screen.focused().geometry.width local screen_height = awful.screen.focused().geometry.height -- Create the widget -dashboard = wibox({visible = false, ontop = true, type = "dock"}) +dashboard = wibox({visible = false, ontop = true, type = "dock", screen = screen.primary}) awful.placement.maximize(dashboard) dashboard.bg = beautiful.dashboard_bg or beautiful.exit_screen_bg or beautiful.wibar_bg or "#111111" dashboard.fg = beautiful.dashboard_fg or beautiful.exit_screen_fg or beautiful.wibar_fg or "#FEFEFE" --- Create an container box --- local dashboard_box = wibox.container.background() --- dashboard_box.bg = dashboard.bg --- dashboard_box.shape = gears.shape.rounded_rect --- dashboard_box.shape_border_radius = 20 +-- Add dashboard or mask to each screen +for s in screen do + if s == screen.primary then + s.dashboard = dashboard + else + s.dashboard = helpers.screen_mask(s, dashboard.bg) + end +end + +local function set_visibility(v) + for s in screen do + s.dashboard.visible = v + end +end dashboard:buttons(gears.table.join( -- Middle click - Hide dashboard @@ -684,7 +693,7 @@ dashboard:setup { local dashboard_grabber function dashboard_hide() awful.keygrabber.stop(dashboard_grabber) - dashboard.visible = false + set_visibility(false) end @@ -704,5 +713,5 @@ function dashboard_show() dashboard_hide() end end) - dashboard.visible = true + set_visibility(true) end diff --git a/config/awesome/elemental/lock_screen.lua b/config/awesome/elemental/lock_screen.lua index 1cf2b75..76063b7 100644 --- a/config/awesome/elemental/lock_screen.lua +++ b/config/awesome/elemental/lock_screen.lua @@ -28,15 +28,6 @@ local lock_animation_icon = wibox.widget { -- It will not be visible anywhere. local some_textbox = wibox.widget.textbox() --- This function adds blurry mask to a screen -local function screen_mask(s) - local mask = wibox({visible = false, ontop = true, type = "splash", screen = s}) - awful.placement.maximize(mask) - mask.bg = beautiful.lock_screen_bg or "#21252b" - mask.fg = beautiful.lock_screen_fg or "#abb2bf" - return mask -end - -- Create the lock screen wibox -- Set the type to "splash" and set all "splash" windows to be blurred in your -- compositor configuration file @@ -51,7 +42,7 @@ for s in screen do if s == screen.primary then s.mylockscreen = lock_screen else - s.mylockscreen = screen_mask(s) + s.mylockscreen = helpers.screen_mask(s, beautiful.lock_screen_bg or beautiful.exit_screen_bg or x.background) end end diff --git a/config/awesome/helpers.lua b/config/awesome/helpers.lua index c8bc84c..2fb75af 100644 --- a/config/awesome/helpers.lua +++ b/config/awesome/helpers.lua @@ -436,4 +436,13 @@ function helpers.float_and_resize(c, width, height) c:raise() end +-- Adds a maximized mask to a screen +function helpers.screen_mask(s, bg) + local mask = wibox({visible = false, ontop = true, type = "splash", screen = s}) + awful.placement.maximize(mask) + mask.bg = bg + return mask +end + + return helpers