/[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 552 by astrand, Mon Dec 8 12:01:25 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;
45  extern BOOL g_enable_compose;  extern BOOL g_enable_compose;
46  extern BOOL g_use_rdp5;  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];
# Line 280  send_winkey(uint32 ev_time, BOOL pressed Line 282  send_winkey(uint32 ev_time, BOOL pressed
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
297     possible via keymap-files) */     possible via keymap-files) */
298  BOOL  BOOL
# Line 354  handle_special_keys(uint32 keysym, unsig Line 367  handle_special_keys(uint32 keysym, unsig
367                          if (g_win_button_size                          if (g_win_button_size
368                              && (get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R)))                              && (get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R)))
369                                  return True;                                  return True;
370                    case XK_Num_Lock:
371                            /* FIXME: We might want to do RDP_INPUT_SYNCHRONIZE here, if g_numlock_sync */
372                            if (!g_numlock_sync)
373                                    /* Inhibit */
374                                    return True;
375    
376    
377          }          }
378          return False;          return False;
# Line 500  ensure_remote_modifiers(uint32 ev_time, Line 519  ensure_remote_modifiers(uint32 ev_time,
519          if (is_modifier(tr.scancode))          if (is_modifier(tr.scancode))
520                  return;                  return;
521    
522          /* NumLock */          if (!g_numlock_sync)
         if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)  
             != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))  
523          {          {
524                  /* The remote modifier state is not correct */                  /* NumLock */
525                  uint16 new_remote_state;                  if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)
526                        != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))
                 if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))  
527                  {                  {
528                          DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));                          /* The remote modifier state is not correct */
529                          new_remote_state = KBD_FLAG_NUMLOCK;                          uint16 new_remote_state;
530                          remote_modifier_state = MapNumLockMask;  
531                  }                          if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))
532                  else                          {
533                  {                                  DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));
534                          DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));                                  new_remote_state = KBD_FLAG_NUMLOCK;
535                          new_remote_state = 0;                                  remote_modifier_state = MapNumLockMask;
536                          remote_modifier_state = 0;                          }
537                  }                          else
538                            {
539                                    DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));
540                                    new_remote_state = 0;
541                                    remote_modifier_state = 0;
542                            }
543    
544                  rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);                          rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);
545                    }
546          }          }
547    
548    
549          /* 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. */
550          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)
551              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))
# Line 571  ensure_remote_modifiers(uint32 ev_time, Line 594  ensure_remote_modifiers(uint32 ev_time,
594  }  }
595    
596    
597    unsigned int
598    read_keyboard_state()
599    {
600            unsigned int state;
601            Window wdummy;
602            int dummy;
603    
604            XQueryPointer(g_display, g_wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
605            return state;
606    }
607    
608    
609    uint16
610    ui_get_numlock_state(unsigned int state)
611    {
612            uint16 numlock_state = 0;
613    
614            if (get_key_state(state, XK_Num_Lock))
615                    numlock_state = KBD_FLAG_NUMLOCK;
616    
617            return numlock_state;
618    }
619    
620    
621  void  void
622  reset_modifier_keys(unsigned int state)  reset_modifier_keys()
623  {  {
624            unsigned int state = read_keyboard_state();
625    
626          /* reset keys */          /* reset keys */
627          uint32 ev_time;          uint32 ev_time;
628          ev_time = time(NULL);          ev_time = time(NULL);
# Line 600  reset_modifier_keys(unsigned int state) Line 649  reset_modifier_keys(unsigned int state)
649          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&          if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
650              !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))
651                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);
652    
653            reset_winkey(ev_time);
654    
655            if (g_numlock_sync)
656                    rdp_send_input(ev_time, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(state), 0);
657  }  }
658    
659    
# Line 641  update_modifier_state(uint8 scancode, BO Line 695  update_modifier_state(uint8 scancode, BO
695                  case SCANCODE_CHAR_NUMLOCK:                  case SCANCODE_CHAR_NUMLOCK:
696                          /* KeyReleases for NumLocks are sent immediately. Toggle the                          /* KeyReleases for NumLocks are sent immediately. Toggle the
697                             modifier state only on Keypress */                             modifier state only on Keypress */
698                          if (pressed)                          if (pressed && !g_numlock_sync)
699                          {                          {
700                                  BOOL newNumLockState;                                  BOOL newNumLockState;
701                                  newNumLockState =                                  newNumLockState =
# Line 650  update_modifier_state(uint8 scancode, BO Line 704  update_modifier_state(uint8 scancode, BO
704                                  MASK_CHANGE_BIT(remote_modifier_state,                                  MASK_CHANGE_BIT(remote_modifier_state,
705                                                  MapNumLockMask, newNumLockState);                                                  MapNumLockMask, newNumLockState);
706                          }                          }
                         break;  
707          }          }
708    
709  #ifdef WITH_DEBUG_KBD  #ifdef WITH_DEBUG_KBD

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

  ViewVC Help
Powered by ViewVC 1.1.26