Skip to content

Commit 462fde5

Browse files
committed
devel/dflayout: cleanup focus checking and updating chaining
Use hasFocus instead of "not defocused". hasFocus also checks that the ZScreen is the topmost. Check demo availability before updating from main window.
1 parent c2001bb commit 462fde5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

devel/dflayout.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ local utils = require('utils')
1313
---@field update fun() called by main window to recompute demo frames
1414

1515
local visible_when_not_focused = true
16-
function visible()
17-
if visible_when_not_focused then return true end
16+
function demos_are_visible()
1817
if not screen then return false end
19-
return screen:isActive() and not screen.defocused
18+
if visible_when_not_focused then return true end
19+
return screen:isActive() and screen:hasFocus()
2020
end
2121

2222
DemoWindow = defclass(DemoWindow, widgets.Window)
@@ -114,7 +114,7 @@ end
114114

115115
function DemoScreen:postComputeFrame(frame_body)
116116
for _, demo in ipairs(self.demos) do
117-
if demo.active and demo.update then
117+
if demo.available() and demo.active then
118118
demo.update()
119119
end
120120
end
@@ -129,7 +129,7 @@ local fort_toolbars_demo = {
129129
}
130130

131131
local function fort_toolbars_visible()
132-
return visible() and fort_toolbars_demo.active
132+
return demos_are_visible() and fort_toolbars_demo.active
133133
end
134134

135135
local secondary_visible = false

0 commit comments

Comments
 (0)