diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-12-02 16:09:47 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-12-02 16:09:47 +0100 |
commit | f5ad91619df0a398fad00e01e30c0fbd278f963f (patch) | |
tree | 41d52f28edd7505540d3035332532057fbb53f40 | |
parent | c5282fe57820960f48a3e28f98609a848a972dfb (diff) |
pager: improve marking visible pages
Use a new desktop signal - page:hide - to make updates work correctly in
all cases.
Mark pages of the same desktop displayed on other screens with a
special color.
-rw-r--r-- | pager.lua | 28 | ||||
-rw-r--r-- | workspace.lua | 8 |
2 files changed, 20 insertions, 16 deletions
@@ -6,10 +6,14 @@ local wibox = require("wibox") local Page = {} -function Page:set_active(active) +function Page:set_visible(visible, this_screen) local border_color = nil - if active then - border_color = beautiful.border_focus or '#ffffff' + if visible then + if this_screen then + border_color = beautiful.border_focus or '#ffffff' + else + border_color = beautiful.border_marked or '#d00000' + end else border_color = beautiful.border_normal or '#000000' end @@ -74,7 +78,7 @@ function Page:new(tag, width, height, screen) tag:connect_signal('tagged', function (c) ret:update() end) tag:connect_signal('untagged', function (c) ret:update() end) - ret:set_active(false) + ret:set_visible(false, false) ret:update() return ret @@ -125,9 +129,14 @@ function PagerDesk:new(desktop, screen, width, height) desktop:connect_signal("page:view", function(desktop, s, page_idx) if s == ret.screen then - ret:_set_active(page_idx) title_page:set_text(string.format("%d", page_idx)) end + + ret.pages[page_idx]:set_visible(true, s == ret.screen) + end) + desktop:connect_signal("page:hide", + function(desktop, page_idx) + ret.pages[page_idx]:set_visible(false, false) end) client.connect_signal("focus", function(c) @@ -142,19 +151,10 @@ function PagerDesk:new(desktop, screen, width, height) ret.desktop = desktop ret.screen = screen - ret.active_page_idx = nil return ret end -function PagerDesk:_set_active(page_idx) - if self.active_page_idx then - self.pages[self.active_page_idx]:set_active(false) - end - self.pages[page_idx]:set_active(true) - self.active_page_idx = page_idx -end - local Pager = {} function Pager:set_desktop(desktop) diff --git a/workspace.lua b/workspace.lua index 2ba67e5..f0a6dcc 100644 --- a/workspace.lua +++ b/workspace.lua @@ -117,8 +117,12 @@ function Workspace:view(screen, desktop_idx, page_idx) else -- mark previous page as free if state_cur then - self.desktops[state_cur.desktop_idx].screen_map[state_cur.page_idx] = nil - self.desktops[state_cur.desktop_idx].indices_free:push(state_cur.page_idx) + local desk = self.desktops[state_cur.desktop_idx] + + desk.screen_map[state_cur.page_idx] = nil + desk.indices_free:push(state_cur.page_idx) + + desk:emit_signal("page:hide", state_cur.page_idx) end desktop.screen_map[page_idx] = screen |