/[rdesktop]/sourceforge.net/trunk/rdesktop/xkeymap.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xkeymap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 212 by matthewc, Sun Oct 6 13:25:30 2002 UTC revision 910 by astrand, Tue Jun 7 11:21:53 2005 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X keyboard mapping     User interface services - X keyboard mapping
4     Copyright (C) Matthew Chapman 1999-2002  
5       Copyright (C) Matthew Chapman 1999-2005
6       Copyright (C) Peter Astrand <peter@cendio.se> 2003
7        
8     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 12  Line 14 
14     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.     GNU General Public License for more details.
17      
18     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
20     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */  */
22    
23    #ifdef RDP2VNC
24    #include "vnc/x11stubs.h"
25    #else
26  #include <X11/Xlib.h>  #include <X11/Xlib.h>
27  #define XK_MISCELLANY  #include <X11/keysym.h>
28  #include <X11/keysymdef.h>  #endif
29    
30  #include <ctype.h>  #include <ctype.h>
31  #include <limits.h>  #include <limits.h>
32  #include <time.h>  #include <time.h>
33  #include "rdesktop.h"  #include "rdesktop.h"
34  #include "scancodes.h"  #include "scancodes.h"
35    
36  #define KEYMAP_SIZE 4096  #define KEYMAP_SIZE 0xffff+1
37  #define KEYMAP_MASK (KEYMAP_SIZE - 1)  #define KEYMAP_MASK 0xffff
38  #define KEYMAP_MAX_LINE_LENGTH 80  #define KEYMAP_MAX_LINE_LENGTH 80
39    
40  extern Display *display;  extern Display *g_display;
41    extern Window g_wnd;
42  extern char keymapname[16];  extern char keymapname[16];
43  extern int keylayout;  extern int g_keylayout;
44  extern BOOL enable_compose;  extern int g_win_button_size;
45    extern BOOL g_enable_compose;
46    extern BOOL g_use_rdp5;
47    extern BOOL g_numlock_sync;
48    
49  static BOOL keymap_loaded;  static BOOL keymap_loaded;
50  static key_translation keymap[KEYMAP_SIZE];  static key_translation keymap[KEYMAP_SIZE];
51  static int min_keycode;  static int min_keycode;
52  static uint16 remote_modifier_state = 0;  static uint16 remote_modifier_state = 0;
53    static uint16 saved_remote_modifier_state = 0;
54    
55  static void update_modifier_state(uint8 scancode, BOOL pressed);  static void update_modifier_state(uint8 scancode, BOOL pressed);
56    
# Line 51  add_to_keymap(char *keyname, uint8 scanc Line 62  add_to_keymap(char *keyname, uint8 scanc
62          keysym = XStringToKeysym(keyname);          keysym = XStringToKeysym(keyname);
63          if (keysym == NoSymbol)          if (keysym == NoSymbol)
64          {          {
65                  error("Bad keysym %s in keymap %s\n", keyname, mapname);                  DEBUG_KBD(("Bad keysym \"%s\" in keymap %s (ignoring)\n", keyname, mapname));
66                  return;                  return;
67          }          }
68    
# Line 69  static BOOL Line 80  static BOOL
80  xkeymap_read(char *mapname)  xkeymap_read(char *mapname)
81  {  {
82          FILE *fp;          FILE *fp;
83          char line[KEYMAP_MAX_LINE_LENGTH], path[PATH_MAX];          char line[KEYMAP_MAX_LINE_LENGTH];
84            char path[PATH_MAX], inplace_path[PATH_MAX];
85          unsigned int line_num = 0;          unsigned int line_num = 0;
86          unsigned int line_length = 0;          unsigned int line_length = 0;
87          char *keyname, *p;          char *keyname, *p;
# Line 84  xkeymap_read(char *mapname) Line 96  xkeymap_read(char *mapname)
96          fp = fopen(path, "r");          fp = fopen(path, "r");
97          if (fp == NULL)          if (fp == NULL)
98          {          {
99                  error("Failed to open keymap %s\n", path);                  /* in case we are running from the source tree */
100                  return False;                  strcpy(inplace_path, "keymaps/");
101                    strncat(inplace_path, mapname, sizeof(inplace_path) - sizeof("keymaps/"));
102    
103                    fp = fopen(inplace_path, "r");
104                    if (fp == NULL)
105                    {
106                            error("Failed to open keymap %s\n", path);
107                            return False;
108                    }
109          }          }
110    
111          /* FIXME: More tolerant on white space */          /* FIXME: More tolerant on white space */
# Line 117  xkeymap_read(char *mapname) Line 137  xkeymap_read(char *mapname)
137                  /* map */                  /* map */
138                  if (strncmp(line, "map ", 4) == 0)                  if (strncmp(line, "map ", 4) == 0)
139                  {                  {
140                          keylayout = strtol(line + 4, NULL, 16);                          g_keylayout = strtol(line + 4, NULL, 16);
141                          DEBUG_KBD(("Keylayout 0x%x\n", keylayout));                          DEBUG_KBD(("Keylayout 0x%x\n", g_keylayout));
142                          continue;                          continue;
143                  }                  }
144    
# Line 126  xkeymap_read(char *mapname) Line 146  xkeymap_read(char *mapname)
146                  if (strncmp(line, "enable_compose", 15) == 0)                  if (strncmp(line, "enable_compose", 15) == 0)
147                  {                  {
148                          DEBUG_KBD(("Enabling compose handling\n"));                          DEBUG_KBD(("Enabling compose handling\n"));
149                          enable_compose = True;                          g_enable_compose = True;
150                          continue;                          continue;
151                  }                  }
152    
# Line 189  xkeymap_read(char *mapname) Line 209  xkeymap_read(char *mapname)
209                          /* Automatically add uppercase key, with same modifiers                          /* Automatically add uppercase key, with same modifiers
210                             plus shift */                             plus shift */
211                          for (p = keyname; *p; p++)                          for (p = keyname; *p; p++)
212                                  *p = toupper(*p);                                  *p = toupper((int) *p);
213                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);
214                          add_to_keymap(keyname, scancode, modifiers, mapname);                          add_to_keymap(keyname, scancode, modifiers, mapname);
215                  }                  }
# Line 205  void Line 225  void
225  xkeymap_init(void)  xkeymap_init(void)
226  {  {
227          unsigned int max_keycode;          unsigned int max_keycode;
228            char *mapname_ptr;
229    
230            /* Make keymapname lowercase */
231            mapname_ptr = keymapname;
232            while (*mapname_ptr)
233            {
234                    *mapname_ptr = tolower((int) *mapname_ptr);
235                    mapname_ptr++;
236            }
237    
238          if (strcmp(keymapname, "none"))          if (strcmp(keymapname, "none"))
239          {          {
# Line 212  xkeymap_init(void) Line 241  xkeymap_init(void)
241                          keymap_loaded = True;                          keymap_loaded = True;
242          }          }
243    
244          XDisplayKeycodes(display, &min_keycode, (int *) &max_keycode);          XDisplayKeycodes(g_display, &min_keycode, (int *) &max_keycode);
245    }
246    
247    static void
248    send_winkey(uint32 ev_time, BOOL pressed, BOOL leftkey)
249    {
250            uint8 winkey;
251    
252            if (leftkey)
253                    winkey = SCANCODE_CHAR_LWIN;
254            else
255                    winkey = SCANCODE_CHAR_RWIN;
256    
257            if (pressed)
258            {
259                    if (g_use_rdp5)
260                    {
261                            rdp_send_scancode(ev_time, RDP_KEYPRESS, winkey);
262                    }
263                    else
264                    {
265                            /* RDP4 doesn't support winkey. Fake with Ctrl-Esc */
266                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);
267                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);
268                    }
269            }
270            else
271            {
272                    /* key released */
273                    if (g_use_rdp5)
274                    {
275                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, winkey);
276                    }
277                    else
278                    {
279                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);
280                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
281                    }
282            }
283    }
284    
285    static void
286    reset_winkey(uint32 ev_time)
287    {
288            if (g_use_rdp5)
289            {
290                    /* For some reason, it seems to suffice to release
291                     *either* the left or right winkey. */
292                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LWIN);
293            }
294  }  }
295    
296  /* Handles, for example, multi-scancode keypresses (which is not  /* Handles, for example, multi-scancode keypresses (which is not
# Line 222  handle_special_keys(uint32 keysym, unsig Line 300  handle_special_keys(uint32 keysym, unsig
300  {  {
301          switch (keysym)          switch (keysym)
302          {          {
303                  case XK_Break:                  case XK_Return:
                 case XK_Pause:  
304                          if ((get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R))                          if ((get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R))
305                                  && (get_key_state(state, XK_Control_L) || get_key_state(state, XK_Control_R)))                              && (get_key_state(state, XK_Control_L)
306                                    || get_key_state(state, XK_Control_R)))
307                          {                          {
308                                  /* Ctrl-Alt-Break: toggle full screen */                                  /* Ctrl-Alt-Enter: toggle full screen */
309                                  if (pressed)                                  if (pressed)
310                                          xwin_toggle_fullscreen();                                          xwin_toggle_fullscreen();
311                                    return True;
312                            }
313                            break;
314    
315                    case XK_Break:
316                            /* Send Break sequence E0 46 E0 C6 */
317                            if (pressed)
318                            {
319                                    rdp_send_scancode(ev_time, RDP_KEYPRESS,
320                                                      (SCANCODE_EXTENDED | 0x46));
321                                    rdp_send_scancode(ev_time, RDP_KEYPRESS,
322                                                      (SCANCODE_EXTENDED | 0xc6));
323                          }                          }
324                          else if (keysym == XK_Break)                          /* No release sequence */
325                            return True;
326                            break;
327    
328                    case XK_Pause:
329                            /* According to MS Keyboard Scan Code
330                               Specification, pressing Pause should result
331                               in E1 1D 45 E1 9D C5. I'm not exactly sure
332                               of how this is supposed to be sent via
333                               RDP. The code below seems to work, but with
334                               the side effect that Left Ctrl stays
335                               down. Therefore, we release it when Pause
336                               is released. */
337                            if (pressed)
338                          {                          {
339                                  /* Send Break sequence E0 46 E0 C6 */                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
340                                  if (pressed)                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
341                                  {                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x45, 0);
342                                          rdp_send_scancode(ev_time, RDP_KEYPRESS,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
343                                                            (SCANCODE_EXTENDED | 0x46));                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x9d, 0);
344                                          rdp_send_scancode(ev_time, RDP_KEYPRESS,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xc5, 0);
                                                           (SCANCODE_EXTENDED | 0xc6));  
                                 }  
                                 /* No break sequence */  
345                          }                          }
346                          else /* XK_Pause */                          else
347                          {                          {
348                                  /* According to MS Keyboard Scan Code                                  /* Release Left Ctrl */
349                                     Specification, pressing Pause should result                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYRELEASE,
350                                     in E1 1D 45 E1 9D C5. I'm not exactly sure                                                 0x1d, 0);
                                    of how this is supposed to be sent via  
                                    RDP. The code below seems to work, but with  
                                    the side effect that Left Ctrl stays  
                                    down. Therefore, we release it when Pause  
                                    is released. */  
                                 if (pressed)  
                                 {  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x45, 0);  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x9d, 0);  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xc5, 0);  
                                 }  
                                 else  
                                 {  
                                         /* Release Left Ctrl */  
                                         rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d,  
                                                        0);  
                                 }  
351                          }                          }
352                          return True;                          return True;
353                            break;
354    
355                  case XK_Meta_L: /* Windows keys */                  case XK_Meta_L: /* Windows keys */
356                  case XK_Super_L:                  case XK_Super_L:
357                  case XK_Hyper_L:                  case XK_Hyper_L:
358                            send_winkey(ev_time, pressed, True);
359                            return True;
360                            break;
361    
362                  case XK_Meta_R:                  case XK_Meta_R:
363                  case XK_Super_R:                  case XK_Super_R:
364                  case XK_Hyper_R:                  case XK_Hyper_R:
365                          if (pressed)                          send_winkey(ev_time, pressed, False);
366                          {                          return True;
367                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);                          break;
368                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);  
369                          }                  case XK_space:
370                          else                          /* Prevent access to the Windows system menu in single app mode */
371                          {                          if (g_win_button_size
372                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);                              && (get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R)))
373                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);                                  return True;
374                          }                          break;
375    
376                    case XK_Num_Lock:
377                            /* Synchronize on key release */
378                            if (g_numlock_sync && !pressed)
379                                    rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0,
380                                                   ui_get_numlock_state(read_keyboard_state()), 0);
381    
382                            /* Inhibit */
383                          return True;                          return True;
384                            break;
385    
386          }          }
387          return False;          return False;
388  }  }
# Line 318  xkeymap_translate_key(uint32 keysym, uns Line 412  xkeymap_translate_key(uint32 keysym, uns
412                  }                  }
413          }          }
414    
415            if ((tr.modifiers & MapLeftShiftMask) && ((remote_modifier_state & MapLeftCtrlMask)
416                                                      || (remote_modifier_state & MapRightCtrlMask))
417                && get_key_state(state, XK_Caps_Lock))
418            {
419                    DEBUG_KBD(("CapsLock + Ctrl pressed, releasing LeftShift\n"));
420                    tr.modifiers ^= MapLeftShiftMask;
421            }
422    
423          if (tr.scancode != 0)          if (tr.scancode != 0)
424          {          {
425                  DEBUG_KBD(("Found key translation, scancode=0x%x, modifiers=0x%x\n",                  DEBUG_KBD(("Found key translation, scancode=0x%x, modifiers=0x%x\n",
# Line 326  xkeymap_translate_key(uint32 keysym, uns Line 428  xkeymap_translate_key(uint32 keysym, uns
428          }          }
429    
430          if (keymap_loaded)          if (keymap_loaded)
431                  error("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));                  warning("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));
432    
433          /* not in keymap, try to interpret the raw scancode */          /* not in keymap, try to interpret the raw scancode */
434          if ((keycode >= min_keycode) && (keycode <= 0x60))          if (((int) keycode >= min_keycode) && (keycode <= 0x60))
435          {          {
436                  tr.scancode = keycode - min_keycode;                  tr.scancode = keycode - min_keycode;
437    
# Line 384  get_ksname(uint32 keysym) Line 486  get_ksname(uint32 keysym)
486          return ksname;          return ksname;
487  }  }
488    
489    static BOOL
490  void  is_modifier(uint8 scancode)
 ensure_remote_modifiers(uint32 ev_time, key_translation tr)  
491  {  {
492          /* If this key is a modifier, do nothing */          switch (scancode)
         switch (tr.scancode)  
493          {          {
494                  case SCANCODE_CHAR_LSHIFT:                  case SCANCODE_CHAR_LSHIFT:
495                  case SCANCODE_CHAR_RSHIFT:                  case SCANCODE_CHAR_RSHIFT:
# Line 400  ensure_remote_modifiers(uint32 ev_time, Line 500  ensure_remote_modifiers(uint32 ev_time,
500                  case SCANCODE_CHAR_LWIN:                  case SCANCODE_CHAR_LWIN:
501                  case SCANCODE_CHAR_RWIN:                  case SCANCODE_CHAR_RWIN:
502                  case SCANCODE_CHAR_NUMLOCK:                  case SCANCODE_CHAR_NUMLOCK:
503                          return;                          return True;
504                  default:                  default:
505                          break;                          break;
506          }          }
507            return False;
508    }
509    
510    void
511    save_remote_modifiers(uint8 scancode)
512    {
513            if (is_modifier(scancode))
514                    return;
515    
516            saved_remote_modifier_state = remote_modifier_state;
517    }
518    
519    void
520    restore_remote_modifiers(uint32 ev_time, uint8 scancode)
521    {
522            key_translation dummy;
523    
524            if (is_modifier(scancode))
525                    return;
526    
527            dummy.scancode = 0;
528            dummy.modifiers = saved_remote_modifier_state;
529            ensure_remote_modifiers(ev_time, dummy);
530    }
531    
532    void
533    ensure_remote_modifiers(uint32 ev_time, key_translation tr)
534    {
535            /* If this key is a modifier, do nothing */
536            if (is_modifier(tr.scancode))
537                    return;
538    
539            if (!g_numlock_sync)
540            {
541                    /* NumLock */
542                    if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)
543                        != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))
544                    {
545                            /* The remote modifier state is not correct */
546                            uint16 new_remote_state;
547    
548                            if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))
549                            {
550                                    DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));
551                                    new_remote_state = KBD_FLAG_NUMLOCK;
552                                    remote_modifier_state = MapNumLockMask;
553                            }
554                            else
555                            {
556                                    DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));
557                                    new_remote_state = 0;
558                                    remote_modifier_state = 0;
559                            }
560    
561                            rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);
562                    }
563            }
564    
565    
566          /* Shift. Left shift and right shift are treated as equal; either is fine. */          /* Shift. Left shift and right shift are treated as equal; either is fine. */
567          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)
# Line 449  ensure_remote_modifiers(uint32 ev_time, Line 607  ensure_remote_modifiers(uint32 ev_time,
607                  }                  }
608          }          }
609    
         /* NumLock */  
         if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)  
             != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))  
         {  
                 /* The remote modifier state is not correct */  
                 uint16 new_remote_state = 0;  
610    
611                  if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))  }
                 {  
                         DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));  
                         new_remote_state |= KBD_FLAG_NUMLOCK;  
                 }  
                 else  
                 {  
                         DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));  
                 }  
612    
613                  rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);  
614                  update_modifier_state(SCANCODE_CHAR_NUMLOCK, True);  unsigned int
615          }  read_keyboard_state()
616    {
617    #ifdef RDP2VNC
618            return 0;
619    #else
620            unsigned int state;
621            Window wdummy;
622            int dummy;
623    
624            XQueryPointer(g_display, g_wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
625            return state;
626    #endif
627    }
628    
629    
630    uint16
631    ui_get_numlock_state(unsigned int state)
632    {
633            uint16 numlock_state = 0;
634    
635            if (get_key_state(state, XK_Num_Lock))
636                    numlock_state = KBD_FLAG_NUMLOCK;
637    
638            return numlock_state;
639  }  }
640    
641    
642  void  void
643  reset_modifier_keys(unsigned int state)  reset_modifier_keys()
644  {  {
645            unsigned int state = read_keyboard_state();
646    
647          /* reset keys */          /* reset keys */
648          uint32 ev_time;          uint32 ev_time;
649          ev_time = time(NULL);          ev_time = time(NULL);
650    
651          if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask) && !get_key_state(state, XK_Shift_L))          if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask)
652                && !get_key_state(state, XK_Shift_L))
653                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);
654    
655          if (MASK_HAS_BITS(remote_modifier_state, MapRightShiftMask) && !get_key_state(state, XK_Shift_R))          if (MASK_HAS_BITS(remote_modifier_state, MapRightShiftMask)
656                && !get_key_state(state, XK_Shift_R))
657                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);
658    
659          if (MASK_HAS_BITS(remote_modifier_state, MapLeftCtrlMask) && !get_key_state(state, XK_Control_L))          if (MASK_HAS_BITS(remote_modifier_state, MapLeftCtrlMask)
660                && !get_key_state(state, XK_Control_L))
661                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
662    
663          if (MASK_HAS_BITS(remote_modifier_state, MapRightCtrlMask) && !get_key_state(state, XK_Control_R))          if (MASK_HAS_BITS(remote_modifier_state, MapRightCtrlMask)
664                && !get_key_state(state, XK_Control_R))
665                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL);
666    
667          if (MASK_HAS_BITS(remote_modifier_state, MapLeftAltMask) && !get_key_state(state, XK_Alt_L))          if (MASK_HAS_BITS(remote_modifier_state, MapLeftAltMask) && !get_key_state(state, XK_Alt_L))
668                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT);
669    
670          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
671              !get_key_state(state, XK_Alt_R) && !get_key_state(state, XK_Mode_switch))              !get_key_state(state, XK_Alt_R) && !get_key_state(state, XK_Mode_switch)
672                && !get_key_state(state, XK_ISO_Level3_Shift))
673                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);
674    
675            reset_winkey(ev_time);
676    
677            if (g_numlock_sync)
678                    rdp_send_input(ev_time, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(state), 0);
679  }  }
680    
681    
# Line 538  update_modifier_state(uint8 scancode, BO Line 717  update_modifier_state(uint8 scancode, BO
717                  case SCANCODE_CHAR_NUMLOCK:                  case SCANCODE_CHAR_NUMLOCK:
718                          /* KeyReleases for NumLocks are sent immediately. Toggle the                          /* KeyReleases for NumLocks are sent immediately. Toggle the
719                             modifier state only on Keypress */                             modifier state only on Keypress */
720                          if (pressed)                          if (pressed && !g_numlock_sync)
721                          {                          {
722                                  BOOL newNumLockState;                                  BOOL newNumLockState;
723                                  newNumLockState =                                  newNumLockState =
# Line 547  update_modifier_state(uint8 scancode, BO Line 726  update_modifier_state(uint8 scancode, BO
726                                  MASK_CHANGE_BIT(remote_modifier_state,                                  MASK_CHANGE_BIT(remote_modifier_state,
727                                                  MapNumLockMask, newNumLockState);                                                  MapNumLockMask, newNumLockState);
728                          }                          }
                         break;  
729          }          }
730    
731  #ifdef WITH_DEBUG_KBD  #ifdef WITH_DEBUG_KBD

Legend:
Removed from v.212  
changed lines
  Added in v.910

  ViewVC Help
Powered by ViewVC 1.1.26