From 94d3918d149533d0cbb22715cfc8efecb38159bc Mon Sep 17 00:00:00 2001 From: Yauhen Kirylau Date: Mon, 23 Jul 2018 00:33:59 +0200 Subject: [PATCH] fix(awful: widget: only_on_screen): update for screen API changes from #2293 (#2304) --- lib/awful/widget/only_on_screen.lua | 10 ++++++---- tests/examples/shims/screen.lua | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/awful/widget/only_on_screen.lua b/lib/awful/widget/only_on_screen.lua index 961f88699..6d8aae1d7 100644 --- a/lib/awful/widget/only_on_screen.lua +++ b/lib/awful/widget/only_on_screen.lua @@ -25,10 +25,12 @@ local function should_display_on(self, s) if not self._private.widget then return false end - local success, own_s = pcall(function() - return capi.screen[self._private.screen] - end) - return success and own_s == s + local own_s = self._private.screen + if type(own_s) == "number" and (own_s < 1 or own_s > capi.screen.count()) then + -- Invalid screen number + return false + end + return capi.screen[self._private.screen] == s end -- Layout this layout diff --git a/tests/examples/shims/screen.lua b/tests/examples/shims/screen.lua index 6e5d59dd8..f015dab05 100644 --- a/tests/examples/shims/screen.lua +++ b/tests/examples/shims/screen.lua @@ -2,7 +2,9 @@ local gears_obj = require("gears.object") local screen, meta = awesome._shim_fake_class() -screen.count = 1 +function screen.count() + return 1 +end local function create_screen(args) local s = gears_obj()