From 0e7329bd8275e46705a97a584c548a3998d08a25 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Fri, 9 Feb 2024 16:55:04 -0800 Subject: [PATCH] Add environment variable to disable touch gestures Requested by some of our users due to them accidentally firing them off. Defaults to gestures enabled --- src/wlserver.cpp | 54 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/wlserver.cpp b/src/wlserver.cpp index e7fb7c9eb..31e0998a8 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -2048,34 +2048,38 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time ) if ( get_effective_touch_mode() == WLSERVER_TOUCH_CLICK_PASSTHROUGH ) { - bool start_gesture = false; wlr_seat_touch_notify_motion( wlserver.wlr.seat, time, touch_id, wlserver.mouse_surface_cursorx, wlserver.mouse_surface_cursory ); - // Round the x-coordinate to the nearest whole number - uint32_t roundedCursorX = static_cast(std::round(wlserver.mouse_surface_cursorx)); - // Grab 2% of the display to be used for the edge range - double edge_range = g_nOutputWidth * 0.02; - - // if the touch cursor x position is less or equal to the range then start the gesture for left to right - if (roundedCursorX <= edge_range) { - start_gesture = true; - } - // if the touch cursor x position is the output width minus the edge range value then we are doing right to left - if (roundedCursorX >= g_nOutputWidth - edge_range) { - start_gesture = true; - } - // when the gesture is started and we are moving to the end of the edge range open home - if (start_gesture && roundedCursorX >= 1 && roundedCursorX <= edge_range) { - wl_log.infof("Detected Home gesture"); - wlserver_open_steam_menu(0); - start_gesture = false; + if(!getenv("GAMESCOPE_DISABLE_TOUCH_GESTURES")) { + bool start_gesture = false; + + // Round the x-coordinate to the nearest whole number + uint32_t roundedCursorX = static_cast(std::round(wlserver.mouse_surface_cursorx)); + // Grab 2% of the display to be used for the edge range + double edge_range = g_nOutputWidth * 0.02; + + // if the touch cursor x position is less or equal to the range then start the gesture for left to right + if (roundedCursorX <= edge_range) { + start_gesture = true; + } + // if the touch cursor x position is the output width minus the edge range value then we are doing right to left + if (roundedCursorX >= g_nOutputWidth - edge_range) { + start_gesture = true; + } + // when the gesture is started and we are moving to the end of the edge range open home + if (start_gesture && roundedCursorX >= 1 && roundedCursorX <= edge_range) { + wl_log.infof("Detected Home gesture"); + wlserver_open_steam_menu(0); + start_gesture = false; + } + // when the gesture is started and we are moving from the output width minus the edge range to the output width open QAM + if (start_gesture && roundedCursorX >= g_nOutputWidth - edge_range && roundedCursorX <= g_nOutputWidth ) { + wl_log.infof("Detected QAM gesture"); + wlserver_open_steam_menu(1); + start_gesture = false; + } } - // when the gesture is started and we are moving from the output width minus the edge range to the output width open QAM - if (start_gesture && roundedCursorX >= g_nOutputWidth - edge_range && roundedCursorX <= g_nOutputWidth ) { - wl_log.infof("Detected QAM gesture"); - wlserver_open_steam_menu(1); - start_gesture = false; - } } + } else if ( get_effective_touch_mode() == WLSERVER_TOUCH_CLICK_DISABLED ) { return;