/[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 470 by astrand, Mon Sep 15 08:03:30 2003 UTC revision 543 by astrand, Mon Nov 3 13:33:35 2003 UTC
# Line 38  Line 38 
38  #define KEYMAP_MAX_LINE_LENGTH 80  #define KEYMAP_MAX_LINE_LENGTH 80
39    
40  extern Display *g_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 keylayout;
44  extern int g_win_button_size;  extern int g_win_button_size;
# Line 185  xkeymap_read(char *mapname) Line 186  xkeymap_read(char *mapname)
186                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);
187                  }                  }
188    
                 if (strstr(line_rest, "numlock"))  
                 {  
                         MASK_ADD_BITS(modifiers, MapNumLockMask);  
                 }  
   
189                  if (strstr(line_rest, "localstate"))                  if (strstr(line_rest, "localstate"))
190                  {                  {
191                          MASK_ADD_BITS(modifiers, MapLocalStateMask);                          MASK_ADD_BITS(modifiers, MapLocalStateMask);
# Line 500  ensure_remote_modifiers(uint32 ev_time, Line 496  ensure_remote_modifiers(uint32 ev_time,
496          if (is_modifier(tr.scancode))          if (is_modifier(tr.scancode))
497                  return;                  return;
498    
         /* 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;  
   
                 if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))  
                 {  
                         DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));  
                         new_remote_state = KBD_FLAG_NUMLOCK;  
                         remote_modifier_state = MapNumLockMask;  
                 }  
                 else  
                 {  
                         DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));  
                         new_remote_state = 0;  
                         remote_modifier_state = 0;  
                 }  
   
                 rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);  
         }  
   
499          /* 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. */
500          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)
501              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))
# Line 571  ensure_remote_modifiers(uint32 ev_time, Line 544  ensure_remote_modifiers(uint32 ev_time,
544  }  }
545    
546    
547    unsigned int
548    read_keyboard_state()
549    {
550            unsigned int state;
551            Window wdummy;
552            int dummy;
553    
554            XQueryPointer(g_display, g_wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
555            return state;
556    }
557    
558    
559    uint16
560    ui_get_numlock_state(unsigned int state)
561    {
562            uint16 numlock_state = 0;
563    
564            if (get_key_state(state, XK_Num_Lock))
565                    numlock_state = KBD_FLAG_NUMLOCK;
566    
567            return numlock_state;
568    }
569    
570    
571  void  void
572  reset_modifier_keys(unsigned int state)  reset_modifier_keys()
573  {  {
574            unsigned int state = read_keyboard_state();
575    
576          /* reset keys */          /* reset keys */
577          uint32 ev_time;          uint32 ev_time;
578          ev_time = time(NULL);          ev_time = time(NULL);
# Line 600  reset_modifier_keys(unsigned int state) Line 599  reset_modifier_keys(unsigned int state)
599          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
600              !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))
601                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);
602    
603            rdp_send_input(ev_time, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(state), 0);
604  }  }
605    
606    
# Line 638  update_modifier_state(uint8 scancode, BO Line 639  update_modifier_state(uint8 scancode, BO
639                  case SCANCODE_CHAR_RWIN:                  case SCANCODE_CHAR_RWIN:
640                          MASK_CHANGE_BIT(remote_modifier_state, MapRightWinMask, pressed);                          MASK_CHANGE_BIT(remote_modifier_state, MapRightWinMask, pressed);
641                          break;                          break;
                 case SCANCODE_CHAR_NUMLOCK:  
                         /* KeyReleases for NumLocks are sent immediately. Toggle the  
                            modifier state only on Keypress */  
                         if (pressed)  
                         {  
                                 BOOL newNumLockState;  
                                 newNumLockState =  
                                         (MASK_HAS_BITS  
                                          (remote_modifier_state, MapNumLockMask) == False);  
                                 MASK_CHANGE_BIT(remote_modifier_state,  
                                                 MapNumLockMask, newNumLockState);  
                         }  
                         break;  
642          }          }
643    
644  #ifdef WITH_DEBUG_KBD  #ifdef WITH_DEBUG_KBD

Legend:
Removed from v.470  
changed lines
  Added in v.543

  ViewVC Help
Powered by ViewVC 1.1.26