DevOps9-debug commented on code in PR #621:
URL: https://github.com/apache/guacamole-server/pull/621#discussion_r2463269387


##########
src/protocols/rdp/keyboard.c:
##########
@@ -562,7 +561,229 @@ static void 
guac_rdp_keyboard_send_missing_key(guac_rdp_keyboard* keyboard,
 
     guac_client* client = keyboard->client;
     guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+     
+    /* If system modifiers (Ctrl/Alt) are held, prefer sending US scancode so
+     * that shortcuts like Ctrl+C/V/A work even in Unicode/failsafe layout. */
+    int ctrl_or_alt_pressed =
+          guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_LCTRL)
+       || guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_RCTRL)
+       || guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_LALT)
+       || guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_RALT);
+
+    /* Normalize Cyrillic letters to Latin equivalents when Ctrl/Alt pressed
+     * so that shortcuts like Ctrl+C, Ctrl+V, etc. work even in Russian layout.
+     */
+    if (ctrl_or_alt_pressed) {
+
+       
+/* Treat Ctrl or Alt (but NOT AltGr) as shortcut modifiers */
+int ctrl_pressed =
+      guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_LCTRL)
+   || guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_RCTRL);
+
+int alt_pressed =
+      guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_LALT)
+   || guac_rdp_keyboard_is_pressed(keyboard, GUAC_RDP_KEYSYM_RALT);
+
+/* AltGr appears as Ctrl+Alt together; don’t hijack that. */
+int altgr = ctrl_pressed && alt_pressed;
+
+/* We only force scancodes for real shortcuts: Ctrl-only OR Alt-only. */
+int shortcut_mod = !altgr && (ctrl_pressed || alt_pressed);
+
+if (shortcut_mod) {
+    /* Map both Latin and Russian keysyms for C/V to US scancodes.
+     * US Set 1 scancodes: C=0x2E, V=0x2F.
+     * This makes Ctrl+C / Ctrl+V work in ru-RU and en-US equally.
+     */
+    int sc = 0;
+
+    switch (keysym) {
+            /* --- Ctrl+C --- */
+            case 'c': case 'C':
+            case 0x441:  /* Cyrillic small 'с' */
+            case 0x421:  /* Cyrillic capital 'С' */
+                sc = 0x2E; /* US 'C' key */
+                break;
+
+            /* --- Ctrl+V --- */
+            case 'v': case 'V':
+            case 0x43C:  /* Cyrillic small 'м' */
+            case 0x41C:  /* Cyrillic capital 'М' */
+                sc = 0x2F; /* US 'V' key */
+                break;
+
+            default:
+                sc = 0;
+        }
 
+    if (sc) {
+        guac_client_log(client, GUAC_LOG_DEBUG,
+            "Shortcut: modifiers active, sending US scancode 0x%X for keysym 
0x%X",
+            sc, keysym);
+        /* press + release with no extended flags */
+        guac_rdp_send_key_event(rdp_client, sc, 0, 1);
+        guac_rdp_send_key_event(rdp_client, sc, 0, 0);
+        return;
+    }
+}

Review Comment:
   done,



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to