/[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 331 by astrand, Tue Feb 18 13:44:27 2003 UTC revision 466 by astrand, Mon Sep 8 08:27:57 2003 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    
5     Copyright (C) Matthew Chapman 1999-2002     Copyright (C) Matthew Chapman 1999-2002
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>
 #define XK_MISCELLANY  
27  #include <X11/keysym.h>  #include <X11/keysym.h>
28    #endif
29    
30  #include <ctype.h>  #include <ctype.h>
31  #include <limits.h>  #include <limits.h>
32  #include <time.h>  #include <time.h>
# Line 31  Line 37 
37  #define KEYMAP_MASK 0xffff  #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 char keymapname[16];  extern char keymapname[16];
42  extern int keylayout;  extern int keylayout;
43  extern int win_button_size;  extern int g_win_button_size;
44  extern BOOL enable_compose;  extern BOOL g_enable_compose;
45    extern BOOL g_use_rdp5;
46    
47  static BOOL keymap_loaded;  static BOOL keymap_loaded;
48  static key_translation keymap[KEYMAP_SIZE];  static key_translation keymap[KEYMAP_SIZE];
49  static int min_keycode;  static int min_keycode;
50  static uint16 remote_modifier_state = 0;  static uint16 remote_modifier_state = 0;
51    static uint16 saved_remote_modifier_state = 0;
52    
53  static void update_modifier_state(uint8 scancode, BOOL pressed);  static void update_modifier_state(uint8 scancode, BOOL pressed);
54    
# Line 136  xkeymap_read(char *mapname) Line 144  xkeymap_read(char *mapname)
144                  if (strncmp(line, "enable_compose", 15) == 0)                  if (strncmp(line, "enable_compose", 15) == 0)
145                  {                  {
146                          DEBUG_KBD(("Enabling compose handling\n"));                          DEBUG_KBD(("Enabling compose handling\n"));
147                          enable_compose = True;                          g_enable_compose = True;
148                          continue;                          continue;
149                  }                  }
150    
# Line 231  xkeymap_init(void) Line 239  xkeymap_init(void)
239                          keymap_loaded = True;                          keymap_loaded = True;
240          }          }
241    
242          XDisplayKeycodes(display, &min_keycode, (int *) &max_keycode);          XDisplayKeycodes(g_display, &min_keycode, (int *) &max_keycode);
243    }
244    
245    static void
246    send_winkey(uint32 ev_time, BOOL pressed, BOOL leftkey)
247    {
248            uint8 winkey;
249    
250            if (leftkey)
251                    winkey = SCANCODE_CHAR_LWIN;
252            else
253                    winkey = SCANCODE_CHAR_RWIN;
254    
255            if (pressed)
256            {
257                    if (g_use_rdp5)
258                    {
259                            rdp_send_scancode(ev_time, RDP_KEYPRESS, winkey);
260                    }
261                    else
262                    {
263                            /* RDP4 doesn't support winkey. Fake with Ctrl-Esc */
264                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);
265                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);
266                    }
267            }
268            else
269            {
270                    /* key released */
271                    if (g_use_rdp5)
272                    {
273                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, winkey);
274                    }
275                    else
276                    {
277                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);
278                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
279                    }
280            }
281  }  }
282    
283  /* Handles, for example, multi-scancode keypresses (which is not  /* Handles, for example, multi-scancode keypresses (which is not
# Line 294  handle_special_keys(uint32 keysym, unsig Line 340  handle_special_keys(uint32 keysym, unsig
340                  case XK_Meta_L: /* Windows keys */                  case XK_Meta_L: /* Windows keys */
341                  case XK_Super_L:                  case XK_Super_L:
342                  case XK_Hyper_L:                  case XK_Hyper_L:
343                            send_winkey(ev_time, pressed, True);
344                            return True;
345    
346                  case XK_Meta_R:                  case XK_Meta_R:
347                  case XK_Super_R:                  case XK_Super_R:
348                  case XK_Hyper_R:                  case XK_Hyper_R:
349                          if (pressed)                          send_winkey(ev_time, pressed, False);
                         {  
                                 rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);  
                                 rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);  
                         }  
                         else  
                         {  
                                 rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);  
                                 rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);  
                         }  
350                          return True;                          return True;
351    
352                  case XK_space:                  case XK_space:
353                          /* Prevent access to the Windows system menu in single app mode */                          /* Prevent access to the Windows system menu in single app mode */
354                          if (win_button_size                          if (g_win_button_size
355                              && (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)))
356                                  return True;                                  return True;
357    
# Line 355  xkeymap_translate_key(uint32 keysym, uns Line 395  xkeymap_translate_key(uint32 keysym, uns
395                  warning("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));
396    
397          /* not in keymap, try to interpret the raw scancode */          /* not in keymap, try to interpret the raw scancode */
398          if ((keycode >= min_keycode) && (keycode <= 0x60))          if (((int) keycode >= min_keycode) && (keycode <= 0x60))
399          {          {
400                  tr.scancode = keycode - min_keycode;                  tr.scancode = keycode - min_keycode;
401    
# Line 410  get_ksname(uint32 keysym) Line 450  get_ksname(uint32 keysym)
450          return ksname;          return ksname;
451  }  }
452    
453    void
454    save_remote_modifiers()
455    {
456            saved_remote_modifier_state = remote_modifier_state;
457    }
458    
459    void
460    restore_remote_modifiers(uint32 ev_time)
461    {
462            key_translation dummy;
463    
464            dummy.scancode = 0;
465            dummy.modifiers = saved_remote_modifier_state;
466            ensure_remote_modifiers(ev_time, dummy);
467    }
468    
469  void  void
470  ensure_remote_modifiers(uint32 ev_time, key_translation tr)  ensure_remote_modifiers(uint32 ev_time, key_translation tr)

Legend:
Removed from v.331  
changed lines
  Added in v.466

  ViewVC Help
Powered by ViewVC 1.1.26