-
Notifications
You must be signed in to change notification settings - Fork 9
/
pcp-ScreenSaversApplet-lua.patch
124 lines (113 loc) · 5.24 KB
/
pcp-ScreenSaversApplet-lua.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
diff --git share/jive/applets/ScreenSavers/ScreenSaversApplet.lua share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
index bc86281..76c1697 100644
--- share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
+++ share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
@@ -21,6 +21,10 @@ ScreenSaversApplet overrides the following methods:
-- stuff we use
local ipairs, pairs, tostring, tonumber, bit = ipairs, pairs, tostring, tonumber, bit
+---------------------------------------------------------------------
+local io = require("io")
+---------------------------------------------------------------------
+
local os = require("os")
local oo = require("loop.simple")
@@ -234,15 +237,17 @@ function _activate(self, the_screensaver, force, isServerRequest)
end
local screensaver = self.screensavers[self.currentSS]
+---------------------------------------------------------------------
-- In some situations the timer restart below tries to activate a SS when one is already running.
- -- We don't want to do this for BlankScreen when BlankScreen is already active
- -- This causes the backlight to turn on again after 10 seconds. #14986
- if self:isScreensaverActive() and self.current == 'BlankScreen' then
- log:warn("BlankScreen SS is currently active and we're trying to reactivate it. Nothing to activate then, so return")
+ -- We don't want to do this for BlankScreen/DisplayOff when BlankScreen/DisplayOff is already active
+ -- This causes the backlight to turn on again after 10 seconds. #14986 (10 seconds is default value, this is tied to the screensaver delay option)
+ if self:isScreensaverActive() and (self.current == 'BlankScreen' or self.current == "DisplayOff") then
+ log:warn("BlankScreen/DisplayOff SS is currently active and we're trying to reactivate it. Nothing to activate then, so return")
return
else
log:debug('DEBUG: self:isScreensaverActive()', self:isScreensaverActive(), ' self.current: ', self.current)
end
+---------------------------------------------------------------------
-- check if the top window will allow screensavers, if not then
-- set the screensaver to activate 10 seconds after the window
@@ -557,25 +562,32 @@ function screensaverWindow(self, window, scrollAllowed, ssAllowedActions, mouseA
return EVENT_UNUSED
end)
+---------------------------------------------------------------------
if not self:isSoftPowerOn() then
--allow input to pass through, so that the following listeners will be honored
- self:_setSSAllowedActions(true, {}, true)
-
- window:ignoreAllInputExcept( { "power", "power_on", "power_off" },
- function(actionEvent)
- self:_powerActionHandler(actionEvent)
- end)
- window:addListener(bit.bor(EVENT_MOUSE_PRESS, EVENT_MOUSE_HOLD, EVENT_MOUSE_DRAG),
- function (event)
- self:_showPowerOnWindow()
- return EVENT_CONSUME
- end)
- window:addListener( EVENT_SCROLL,
- function ()
- self:_showPowerOnWindow()
- end)
+ if _read("/usr/local/etc/pcp/pcpversion.cfg") ~= nil then
+ if appletManager:callService("getEnablePowerOnButtonWhenOff") then
+ self:_setSSAllowedActions(true, {}, true)
+ window:ignoreAllInputExcept( { "power", "power_on", "power_off" },
+ function(actionEvent)
+ self:_powerActionHandler(actionEvent)
+ end)
+ window:addListener(bit.bor(EVENT_MOUSE_PRESS, EVENT_MOUSE_HOLD, EVENT_MOUSE_DRAG),
+ function (event)
+ self:_showPowerOnWindow()
+ return EVENT_CONSUME
+ end)
+ window:addListener( EVENT_SCROLL,
+ function ()
+ self:_showPowerOnWindow()
+ end)
+ else
+ self:_setSSAllowedActions(nil, nil, nil)
+ end
+ end
end
+---------------------------------------------------------------------
log:debug("Overriding the default window action 'bump' handling to allow action to fall through to framework listeners")
window:removeDefaultActionListeners()
@@ -817,8 +829,10 @@ function openSettings(self, menuItem)
},
})
+---------------------------------------------------------------------
-- only present a WHEN OFF option when there is a local player present
- if Player:getLocalPlayer() then
+ -- or when running on piCorePlayer with an official display attached
+ if Player:getLocalPlayer() or _read("/usr/local/etc/pcp/pcpversion.cfg") ~= nil then
menu:addItem(
{
text = self:string("SCREENSAVER_WHEN_OFF"),
@@ -830,6 +844,7 @@ function openSettings(self, menuItem)
}
)
end
+---------------------------------------------------------------------
menu:setComparator(menu.itemComparatorWeightAlpha)
for setting_name, screensaver in pairs(self.screensaverSettings) do
@@ -859,7 +874,17 @@ function openSettings(self, menuItem)
return window
end
-
+---------------------------------------------------------------------
+function _read(file)
+ local fh, err = io.open(file, "r")
+ if err then
+ return nil
+ end
+ local fc = fh:read("*all")
+ fh:close()
+ return fc
+end
+---------------------------------------------------------------------
--[[
=head1 LICENSE