mike-jumper commented on a change in pull request #350:
URL: https://github.com/apache/guacamole-server/pull/350#discussion_r745394856



##########
File path: src/terminal/terminal.c
##########
@@ -1590,17 +1590,129 @@ static int __guac_terminal_send_key(guac_terminal* 
term, int keysym, int pressed
                 if (keysym == 0xFF54 || keysym == 0xFF99) return 
guac_terminal_send_string(term, "\x1B[B"); /* Down */
             }
 
+            /* Shift + Function keys. */
+            if (term->mod_shift) { 
+                if (keysym == 0xFFBE || keysym == 0xFF91) return 
guac_terminal_send_string(term, "\x1B[1;2P"); /* F1  */
+                if (keysym == 0xFFBF || keysym == 0xFF92) return 
guac_terminal_send_string(term, "\x1B[1;2Q"); /* F2  */
+                if (keysym == 0xFFC0 || keysym == 0xFF93) return 
guac_terminal_send_string(term, "\x1B[1;2R"); /* F3  */
+                if (keysym == 0xFFC1 || keysym == 0xFF94) return 
guac_terminal_send_string(term, "\x1B[1;2S"); /* F4  */
+                if (keysym == 0xFFC2) return guac_terminal_send_string(term, 
"\x1B[15;2~"); /* F5  */
+                if (keysym == 0xFFC3) return guac_terminal_send_string(term, 
"\x1B[17;2~"); /* F6  */
+                if (keysym == 0xFFC4) return guac_terminal_send_string(term, 
"\x1B[18;2~"); /* F7  */
+                if (keysym == 0xFFC5) return guac_terminal_send_string(term, 
"\x1B[19;2~"); /* F8  */
+                if (keysym == 0xFFC6) return guac_terminal_send_string(term, 
"\x1B[20;2~"); /* F9  */
+                if (keysym == 0xFFC7) return guac_terminal_send_string(term, 
"\x1B[21;2~"); /* F10 */
+                if (keysym == 0xFFC8) return guac_terminal_send_string(term, 
"\x1B[23;2~"); /* F11 */
+                if (keysym == 0xFFC9) return guac_terminal_send_string(term, 
"\x1B[24;2~"); /* F12 */
+            }
+
+            /* Alt + Function keys. */
+            if (term->mod_alt) { 
+                if (keysym == 0xFFBE || keysym == 0xFF91) return 
guac_terminal_send_string(term, "\x1B[1;3P"); /* F1  */
+                if (keysym == 0xFFBF || keysym == 0xFF92) return 
guac_terminal_send_string(term, "\x1B[1;3Q"); /* F2  */
+                if (keysym == 0xFFC0 || keysym == 0xFF93) return 
guac_terminal_send_string(term, "\x1B[1;3R"); /* F3  */
+                if (keysym == 0xFFC1 || keysym == 0xFF94) return 
guac_terminal_send_string(term, "\x1B[1;3S"); /* F4  */
+                if (keysym == 0xFFC2) return guac_terminal_send_string(term, 
"\x1B[15;3~"); /* F5  */
+                if (keysym == 0xFFC3) return guac_terminal_send_string(term, 
"\x1B[17;3~"); /* F6  */
+                if (keysym == 0xFFC4) return guac_terminal_send_string(term, 
"\x1B[18;3~"); /* F7  */
+                if (keysym == 0xFFC5) return guac_terminal_send_string(term, 
"\x1B[19;3~"); /* F8  */
+                if (keysym == 0xFFC6) return guac_terminal_send_string(term, 
"\x1B[20;3~"); /* F9  */
+                if (keysym == 0xFFC7) return guac_terminal_send_string(term, 
"\x1B[21;3~"); /* F10 */
+                if (keysym == 0xFFC8) return guac_terminal_send_string(term, 
"\x1B[23;3~"); /* F11 */
+                if (keysym == 0xFFC9) return guac_terminal_send_string(term, 
"\x1B[24;3~"); /* F12 */
+            }
+
+            /* Shift + Alt + Function keys. */
+            if(term->mod_shift && term->mod_alt){

Review comment:
       I really think there has to be a better way. For example, looking at the 
numeric values in the escape sequences, each combination of modifiers appears 
to have a corresponding integer value. That value appears to be 1 plus the 
bitwise OR of the following flag values:
   
   Modifier | Value
   -------- | -----
   Shift    | 1
   Alt      | 2
   Ctrl     | 4
   
   For example:
   
   Ctrl+Alt = `(4 | 2) + 1` = 7, hence each escape sequence for Ctrl+Alt+FN 
will use a value of 7 to represent the modifiers applicable.
   
   This appears to be documented here:
   
   https://www.xfree86.org/current/ctlseqs.html#PC-Style%20Function%20Keys
   
   There will certainly be some special cases for the various function keys, 
but not to the extent that we need to have the same checks duplicated 8 times.




-- 
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