From fa101a5740a3dd8b4e81570dcf6dfc4ba5beb710 Mon Sep 17 00:00:00 2001 From: bitbegin Date: Wed, 6 May 2020 10:28:43 +0800 Subject: [PATCH] FIX: `single ctrl` key not set flags in gdk's event/state --- modules/view/backends/gtk3/events.reds | 27 ++++++++++++++++++++++++ modules/view/backends/gtk3/handlers.reds | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/modules/view/backends/gtk3/events.reds b/modules/view/backends/gtk3/events.reds index 85554ffcf6..cf8d93ad21 100644 --- a/modules/view/backends/gtk3/events.reds +++ b/modules/view/backends/gtk3/events.reds @@ -429,6 +429,33 @@ keycode-ascii: [ ;-- 80h ] +special-key-to-flags: func [ + key [integer!] + return: [integer!] +][ + case [ + key = RED_VK_LCONTROL [ + EVT_FLAG_CTRL_DOWN + ] + key = RED_VK_RCONTROL [ + EVT_FLAG_CTRL_DOWN + ] + key = RED_VK_LSHIFT [ + EVT_FLAG_SHIFT_DOWN + ] + key = RED_VK_RSHIFT [ + EVT_FLAG_SHIFT_DOWN + ] + key = RED_VK_LMENU [ + EVT_FLAG_MENU_DOWN + ] + key = RED_VK_RMENU [ + EVT_FLAG_MENU_DOWN + ] + true [0] + ] +] + make-at: func [ widget [handle!] face [red-object!] diff --git a/modules/view/backends/gtk3/handlers.reds b/modules/view/backends/gtk3/handlers.reds index cb0a0e4644..a8ac7500c6 100644 --- a/modules/view/backends/gtk3/handlers.reds +++ b/modules/view/backends/gtk3/handlers.reds @@ -672,6 +672,10 @@ key-press-event: func [ key: translate-key event-key/keyval flags: check-extra-keys event-key/state special-key: either char-key? as-byte key [0][-1] ;-- special key or not + if all [key >= 80h special-key = -1][ + flags: flags or special-key-to-flags key + key: 0 + ] res: make-event widget key or flags EVT_KEY_DOWN if res <> EVT_NO_DISPATCH [ key2: gdk_keyval_to_unicode event-key/keyval