Skip to content

Commit

Permalink
Disabled touch input: always active gestures (#10624)
Browse files Browse the repository at this point in the history
  • Loading branch information
hius07 committed Jul 3, 2023
1 parent 08dd973 commit adfbbd9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
29 changes: 29 additions & 0 deletions frontend/dispatcher.lua
Expand Up @@ -72,6 +72,8 @@ local settingsList = {
poweroff = {category="none", event="RequestPowerOff", title=_("Power off"), device=true, condition=Device:canPowerOff(), separator=true},
toggle_hold_corners = {category="none", event="IgnoreHoldCorners", title=_("Toggle hold corners"), device=true},
touch_input_on = {category="none", event="IgnoreTouchInput", arg=false, title=_("Enable touch input"), device=true},
touch_input_off = {category="none", event="IgnoreTouchInput", arg=true, title=_("Disable touch input"), device=true},
toggle_touch_input = {category="none", event="IgnoreTouchInput", title=_("Toggle touch input"), device=true, separator=true},
toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()},
toggle_rotation = {category="none", event="SwapRotation", title=_("Toggle orientation"), device=true},
Expand Down Expand Up @@ -264,6 +266,8 @@ local dispatcher_menu_order = {
"poweroff",
"toggle_hold_corners",
"touch_input_on",
"touch_input_off",
"toggle_touch_input",
"toggle_gsensor",
"rotation_mode",
Expand Down Expand Up @@ -949,6 +953,31 @@ function Dispatcher:addSubMenu(caller, menu, location, settings)
end
end,
})
table.insert(menu, {
text = _("Always active"),
checked_func = function()
return location[settings] ~= nil
and location[settings].settings ~= nil
and location[settings].settings.always_active
end,
callback = function()
if location[settings] then
if location[settings].settings then
if location[settings].settings.always_active then
location[settings].settings.always_active = nil
if next(location[settings].settings) == nil then
location[settings].settings = nil
end
else
location[settings].settings.always_active = true
end
else
location[settings].settings = {["always_active"] = true}
end
caller.updated = true
end
end,
})
table.insert(menu, {
text = _("Sort"),
checked_func = function()
Expand Down
5 changes: 3 additions & 2 deletions plugins/gestures.koplugin/main.lua
Expand Up @@ -121,7 +121,7 @@ Multiswipes allow you to perform complex gestures built up out of multiple swipe
These advanced gestures consist of either straight swipes or diagonal swipes. To ensure accuracy, they can't be mixed.]])

-- If the gesture contains the "toggle_touch_input" action,
-- If the gesture contains "toggle_touch_input" or "touch_input_on" actions, or is set "Always active" manually,
-- mark it "always active" to make sure that InputContainer won't block it after the IgnoreTouchInput Event.
function Gestures:isGestureAlwaysActive(ges, multiswipe_directions)
-- Handle multiswipes properly
Expand All @@ -134,7 +134,8 @@ function Gestures:isGestureAlwaysActive(ges, multiswipe_directions)
end
end

return self.gestures[ges] and self.gestures[ges].toggle_touch_input
local gest = self.gestures[ges]
return gest and (gest.toggle_touch_input or gest.touch_input_on or (gest.settings and gest.settings.always_active))
end

function Gestures:init()
Expand Down

0 comments on commit adfbbd9

Please sign in to comment.