/[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 961 by astrand, Wed Aug 3 09:32:22 2005 UTC revision 965 by astrand, Wed Aug 3 11:47:20 2005 UTC
# Line 1  Line 1 
1  /*  /* -*- c-basic-offset: 8 -*-
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    
# Line 42  extern Display *g_display; Line 42  extern Display *g_display;
42  extern Window g_wnd;  extern Window g_wnd;
43  extern char keymapname[16];  extern char keymapname[16];
44  extern int g_keylayout;  extern int g_keylayout;
45    extern int g_keyboard_type;
46    extern int g_keyboard_subtype;
47    extern int g_keyboard_functionkeys;
48  extern int g_win_button_size;  extern int g_win_button_size;
49  extern BOOL g_enable_compose;  extern BOOL g_enable_compose;
50  extern BOOL g_use_rdp5;  extern BOOL g_use_rdp5;
# Line 156  add_sequence(char *rest, char *mapname) Line 159  add_sequence(char *rest, char *mapname)
159          DEBUG_KBD(("\n"));          DEBUG_KBD(("\n"));
160  }  }
161    
162    void
163    xkeymap_from_locale(const char *locale)
164    {
165            char *str, *ptr;
166            FILE *fp;
167    
168            /* Create a working copy */
169            str = strdup(locale);
170            if (str == NULL)
171            {
172                    perror("strdup");
173                    exit(1);
174            }
175    
176            /* Truncate at dot and at */
177            ptr = strrchr(str, '.');
178            if (ptr)
179                    *ptr = '\0';
180            ptr = strrchr(str, '@');
181            if (ptr)
182                    *ptr = '\0';
183    
184            /* Replace _ with - */
185            ptr = strrchr(str, '_');
186            if (ptr)
187                    *ptr = '-';
188    
189            /* Convert to lowercase */
190            ptr = str;
191            while (*ptr)
192            {
193                    *ptr = tolower((int) *ptr);
194                    ptr++;
195            }
196    
197            /* Try to open this keymap (da-dk) */
198            fp = xkeymap_open(str);
199            if (fp == NULL)
200            {
201                    /* Truncate at dash */
202                    ptr = strrchr(str, '-');
203                    if (ptr)
204                            *ptr = '\0';
205    
206                    /* Try the short name (da) */
207                    fp = xkeymap_open(str);
208            }
209    
210            if (fp)
211            {
212                    fclose(fp);
213                    STRNCPY(keymapname, str, sizeof(keymapname));
214                    fprintf(stderr, "Autoselected keyboard map %s.\n", keymapname);
215            }
216    }
217    
218    
219  /* Joins two path components. The result should be freed with  /* Joins two path components. The result should be freed with
220     xfree(). */     xfree(). */
221  static char *  static char *
# Line 254  xkeymap_read(char *mapname) Line 314  xkeymap_read(char *mapname)
314                  }                  }
315    
316                  /* Include */                  /* Include */
317                  if (strncmp(line, "include ", 8) == 0)                  if (strncmp(line, "include ", sizeof("include ") - 1) == 0)
318                  {                  {
319                          if (!xkeymap_read(line + 8))                          if (!xkeymap_read(line + sizeof("include ") - 1))
320                                  return False;                                  return False;
321                          continue;                          continue;
322                  }                  }
323    
324                  /* map */                  /* map */
325                  if (strncmp(line, "map ", 4) == 0)                  if (strncmp(line, "map ", sizeof("map ") - 1) == 0)
326                  {                  {
327                          g_keylayout = strtol(line + 4, NULL, 16);                          g_keylayout = strtol(line + sizeof("map ") - 1, NULL, 16);
328                          DEBUG_KBD(("Keylayout 0x%x\n", g_keylayout));                          DEBUG_KBD(("Keylayout 0x%x\n", g_keylayout));
329                          continue;                          continue;
330                  }                  }
331    
332                  /* compose */                  /* compose */
333                  if (strncmp(line, "enable_compose", 15) == 0)                  if (strncmp(line, "enable_compose", sizeof("enable_compose") - 1) == 0)
334                  {                  {
335                          DEBUG_KBD(("Enabling compose handling\n"));                          DEBUG_KBD(("Enabling compose handling\n"));
336                          g_enable_compose = True;                          g_enable_compose = True;
# Line 278  xkeymap_read(char *mapname) Line 338  xkeymap_read(char *mapname)
338                  }                  }
339    
340                  /* sequence */                  /* sequence */
341                  if (strncmp(line, "sequence", 8) == 0)                  if (strncmp(line, "sequence", sizeof("sequence") - 1) == 0)
342                    {
343                            add_sequence(line + sizeof("sequence") - 1, mapname);
344                            continue;
345                    }
346    
347                    /* keyboard_type */
348                    if (strncmp(line, "keyboard_type ", sizeof("keyboard_type ") - 1) == 0)
349                    {
350                            g_keyboard_type = strtol(line + sizeof("keyboard_type ") - 1, NULL, 16);
351                            DEBUG_KBD(("keyboard_type 0x%x\n", g_keyboard_type));
352                            continue;
353                    }
354    
355                    /* keyboard_subtype */
356                    if (strncmp(line, "keyboard_subtype ", sizeof("keyboard_subtype ") - 1) == 0)
357                  {                  {
358                          add_sequence(line + 8, mapname);                          g_keyboard_subtype =
359                                    strtol(line + sizeof("keyboard_subtype ") - 1, NULL, 16);
360                            DEBUG_KBD(("keyboard_subtype 0x%x\n", g_keyboard_subtype));
361                            continue;
362                    }
363    
364                    /* keyboard_functionkeys */
365                    if (strncmp(line, "keyboard_functionkeys ", sizeof("keyboard_functionkeys ") - 1) ==
366                        0)
367                    {
368                            g_keyboard_functionkeys =
369                                    strtol(line + sizeof("keyboard_functionkeys ") - 1, NULL, 16);
370                            DEBUG_KBD(("keyboard_functionkeys 0x%x\n", g_keyboard_functionkeys));
371                          continue;                          continue;
372                  }                  }
373    
# Line 359  void Line 446  void
446  xkeymap_init(void)  xkeymap_init(void)
447  {  {
448          unsigned int max_keycode;          unsigned int max_keycode;
         char *mapname_ptr;  
449    
450          if (strcmp(keymapname, "none"))          if (strcmp(keymapname, "none"))
451          {          {

Legend:
Removed from v.961  
changed lines
  Added in v.965

  ViewVC Help
Powered by ViewVC 1.1.26