Keymaps are now searched in ~/.rdesktop/keymaps as well.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@956 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
85d2067013
commit
6c0bc284cd
1
proto.h
1
proto.h
@ -166,6 +166,7 @@ void ui_clip_request_data(uint32 format);
|
|||||||
void ui_clip_sync(void);
|
void ui_clip_sync(void);
|
||||||
void xclip_init(void);
|
void xclip_init(void);
|
||||||
/* xkeymap.c */
|
/* xkeymap.c */
|
||||||
|
FILE *xkeymap_open(const char *filename);
|
||||||
void xkeymap_init(void);
|
void xkeymap_init(void);
|
||||||
BOOL handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed);
|
BOOL handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed);
|
||||||
key_translation xkeymap_translate_key(uint32 keysym, unsigned int keycode, unsigned int state);
|
key_translation xkeymap_translate_key(uint32 keysym, unsigned int keycode, unsigned int state);
|
||||||
|
77
xkeymap.c
77
xkeymap.c
@ -155,12 +155,71 @@ add_sequence(char *rest, char *mapname)
|
|||||||
DEBUG_KBD(("\n"));
|
DEBUG_KBD(("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Joins two path components. The result should be freed with
|
||||||
|
xfree(). */
|
||||||
|
static char *
|
||||||
|
pathjoin(const char *a, const char *b)
|
||||||
|
{
|
||||||
|
char *result;
|
||||||
|
result = xmalloc(PATH_MAX * 2 + 1);
|
||||||
|
|
||||||
|
if (b[0] == '/')
|
||||||
|
{
|
||||||
|
strncpy(result, b, PATH_MAX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(result, a, PATH_MAX);
|
||||||
|
strcat(result, "/");
|
||||||
|
strncat(result, b, PATH_MAX);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to open a keymap with fopen() */
|
||||||
|
FILE *
|
||||||
|
xkeymap_open(const char *filename)
|
||||||
|
{
|
||||||
|
char *path1, *path2;
|
||||||
|
char *home;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
/* Try KEYMAP_PATH */
|
||||||
|
path1 = pathjoin(KEYMAP_PATH, filename);
|
||||||
|
fp = fopen(path1, "r");
|
||||||
|
xfree(path1);
|
||||||
|
if (fp)
|
||||||
|
return fp;
|
||||||
|
|
||||||
|
/* Try ~/.rdesktop/keymaps */
|
||||||
|
home = getenv("HOME");
|
||||||
|
if (home)
|
||||||
|
{
|
||||||
|
path1 = pathjoin(home, ".rdesktop/keymaps");
|
||||||
|
path2 = pathjoin(path1, filename);
|
||||||
|
xfree(path1);
|
||||||
|
fp = fopen(path2, "r");
|
||||||
|
xfree(path2);
|
||||||
|
if (fp)
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try current directory, in case we are running from the source
|
||||||
|
tree */
|
||||||
|
path1 = pathjoin("keymaps", filename);
|
||||||
|
fp = fopen(path1, "r");
|
||||||
|
xfree(path1);
|
||||||
|
if (fp)
|
||||||
|
return fp;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
xkeymap_read(char *mapname)
|
xkeymap_read(char *mapname)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[KEYMAP_MAX_LINE_LENGTH];
|
char line[KEYMAP_MAX_LINE_LENGTH];
|
||||||
char path[PATH_MAX], inplace_path[PATH_MAX];
|
|
||||||
unsigned int line_num = 0;
|
unsigned int line_num = 0;
|
||||||
unsigned int line_length = 0;
|
unsigned int line_length = 0;
|
||||||
char *keyname, *p;
|
char *keyname, *p;
|
||||||
@ -168,24 +227,12 @@ xkeymap_read(char *mapname)
|
|||||||
uint8 scancode;
|
uint8 scancode;
|
||||||
uint16 modifiers;
|
uint16 modifiers;
|
||||||
|
|
||||||
|
fp = xkeymap_open(mapname);
|
||||||
strcpy(path, KEYMAP_PATH);
|
|
||||||
strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH));
|
|
||||||
|
|
||||||
fp = fopen(path, "r");
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
/* in case we are running from the source tree */
|
error("Failed to open keymap %s\n", mapname);
|
||||||
strcpy(inplace_path, "keymaps/");
|
|
||||||
strncat(inplace_path, mapname, sizeof(inplace_path) - sizeof("keymaps/"));
|
|
||||||
|
|
||||||
fp = fopen(inplace_path, "r");
|
|
||||||
if (fp == NULL)
|
|
||||||
{
|
|
||||||
error("Failed to open keymap %s\n", path);
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: More tolerant on white space */
|
/* FIXME: More tolerant on white space */
|
||||||
while (fgets(line, sizeof(line), fp) != NULL)
|
while (fgets(line, sizeof(line), fp) != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user