From c0c88e397a6c7dcdc78f0f67ee8bdb8e0d0760c5 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 15 Mar 2024 11:17:57 -0300 Subject: [PATCH] [x11] Fix bug w/modifiers being reported incorrectly on KeyUp event (fix aseprite/aseprite#4368) --- os/x11/window.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/os/x11/window.cpp b/os/x11/window.cpp index e84192e56..f81e86c17 100644 --- a/os/x11/window.cpp +++ b/os/x11/window.cpp @@ -1,5 +1,5 @@ // LAF OS Library -// Copyright (C) 2018-2022 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2017-2018 David Capello // // This file is released under the terms of the MIT license. @@ -1093,21 +1093,33 @@ void WindowX11::processX11Event(XEvent& event) } case XK_Shift_L: case XK_Shift_R: - modifiers |= kKeyShiftModifier; + if (event.type == KeyPress) + modifiers |= kKeyShiftModifier; + else + modifiers &= ~kKeyShiftModifier; break; case XK_Control_L: case XK_Control_R: - modifiers |= kKeyCtrlModifier; + if (event.type == KeyPress) + modifiers |= kKeyCtrlModifier; + else + modifiers &= ~kKeyCtrlModifier; break; case XK_Alt_L: case XK_Alt_R: - modifiers |= kKeyAltModifier; + if (event.type == KeyPress) + modifiers |= kKeyAltModifier; + else + modifiers &= ~kKeyAltModifier; break; case XK_Meta_L: case XK_Super_L: case XK_Meta_R: case XK_Super_R: - modifiers |= kKeyWinModifier; + if (event.type == KeyPress) + modifiers |= kKeyWinModifier; + else + modifiers &= ~kKeyWinModifier; break; } ev.setModifiers((KeyModifiers)modifiers);