From 6f716fe47cf11f0138cf03f7d88cffacbd8fe543 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Fri, 5 Dec 2025 01:06:57 +0100 Subject: [PATCH] fix: ignore bottom edge so gestures avoid osc --- scripts/touch-gestures.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/touch-gestures.lua b/scripts/touch-gestures.lua index 7ce2aab..d025b58 100644 --- a/scripts/touch-gestures.lua +++ b/scripts/touch-gestures.lua @@ -21,6 +21,7 @@ local config = { invert_vertical = false, -- true flips the swipe direction left_zone_ratio = 0.35, -- fraction of width reserved for brightness (left side) right_zone_ratio = 0.35, -- fraction of width reserved for volume (right side) + bottom_exclude_ratio = 0.15, -- ignore bottom portion (e.g., OSC area); 0 disables osd_duration = 1.2, -- seconds OSD stays visible; set 0 to disable log_debug = false, -- set true to log gesture details start_on_move = true, -- begin a gesture on move in edge zones (helps touch devices without BTN events) @@ -214,10 +215,16 @@ local function surface_size() return w, h end -local function pick_zone(x, width) +local function pick_zone(x, y, width, height) if width <= 0 then return nil end + if height and height > 0 and config.bottom_exclude_ratio > 0 then + local cutoff = height * (1 - config.bottom_exclude_ratio) + if y >= cutoff then + return nil + end + end local left_limit = width * config.left_zone_ratio local right_start = width * (1 - config.right_zone_ratio) if x <= left_limit then @@ -282,8 +289,8 @@ local function update_gesture(_, pos) end if not state.active and config.start_on_move then - local width = surface_size() - local zone = pick_zone(pos.x, width) + local width, height = surface_size() + local zone = pick_zone(pos.x, pos.y, width, height) if zone then start_gesture(pos, zone) else @@ -354,8 +361,8 @@ local function handle_touch(event) return end - local width = surface_size() - local zone = pick_zone(pos.x, width) + local width, height = surface_size() + local zone = pick_zone(pos.x, pos.y, width, height) if not zone then forwarding_click = true mp.commandv("keypress", "mouse_btn0")