[Xquartz-dev] My hack for reading .Xmodmap

Jeremy Huddleston jeremyhu at apple.com
Tue Nov 3 16:48:47 PST 2009


Here's the change I went with based on your original patch:

http://cgit.freedesktop.org/~jeremyhu/xserver/commit/?id=5e79976c13c5b94b12392b493846ca26be11750b

comments on yours:
1) hardcoded 1024... use PATH_MAX instead.
2) You only used ~/.Xmodmap if you also had a system one.

--Jeremy

On Oct 18, 2009, at 19:45, Martin Otte wrote:

> Hi,
> 
> I was doing some experimenting with the latest servers, and found that the only way to get my custom .Xmodmap to be loaded automatically at startup was to force it to be read at the end of the DarwinKeyboardReloadHandler routine.
> 
> Is it safe to call xmodmap at the end of the DarwinKeyboardReloadHandler routine? Using xmodmap is much easier than trying to parse the .Xmodmap files and then calling XkbApplyMappingChange. I had to background the calls to xmodmap or else the server would hang waiting for the xmodmap processes. I also only call xmodmap on the second (or any subsequent) calls to DarwinKeyboardReloadHandler. Here is my ugly hack to quartzKeyboard.c that seems to be working for me:
> 
> diff -up xorg-server-1.4.2-apple49/hw/xquartz/quartzKeyboard.c.orig xorg-server-1.4.2-apple49/hw/xquartz/quartzKeyboard.c
> --- xorg-server-1.4.2-apple49/hw/xquartz/quartzKeyboard.c.orig  2009-10-14 11:06:49.000000000 -0400
> +++ xorg-server-1.4.2-apple49/hw/xquartz/quartzKeyboard.c       2009-10-14 00:07:14.000000000 -0400
> @@ -172,6 +172,7 @@ const static struct {
> 
> darwinKeyboardInfo keyInfo;
> pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
> +int ran_darwin_kbdreload = 0;
> 
> static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) {
>     // FIXME: to be implemented
> @@ -372,6 +373,9 @@ void DarwinKeyboardReloadHandler(void) {
>     CFIndex initialKeyRepeatValue, keyRepeatValue;
>     BOOL ok;
>     DeviceIntPtr pDev = darwinKeyboard;
> +    const char *xmodmap = PROJECTROOT "/bin/xmodmap";
> +    const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
> +    char *homedir, usermodmap[1024], cmd[1024];
> 
>     DEBUG_LOG("DarwinKeyboardReloadHandler\n");
> 
> @@ -415,6 +419,28 @@ void DarwinKeyboardReloadHandler(void) {
>         }
>         XkbUpdateCoreDescription(darwinKeyboard, 0);
>     } pthread_mutex_unlock(&keyInfo_mutex);
> +
> +    if (ran_darwin_kbdreload > 0 && access(xmodmap, F_OK) == 0) {
> +
> +      /* Check for system .Xmodmap */
> +      if (access(sysmodmap, F_OK) == 0) {
> +       snprintf (cmd, sizeof(cmd), "exec %s %s &", xmodmap, sysmodmap);
> +       System(cmd);
> +      }
> +
> +      /* Check for user's local .Xmodmap */
> +      homedir = getenv("HOME");
> +      if (homedir != NULL) {
> +       snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir);
> +       if (access(usermodmap, F_OK) == 0) {
> +         snprintf (cmd, sizeof(cmd), "exec %s %s &", xmodmap, usermodmap);
> +         System(cmd);
> +       }
> +      }
> +
> +    } else
> +      ran_darwin_kbdreload++;
> +
> }
> 
> //-----------------------------------------------------------------------------
> 
> 
> Thanks,
> Martin
> <xquartz-force-xmodmap.patch>
> 
> _______________________________________________
> Xquartz-dev mailing list
> Xquartz-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/xquartz-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5820 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/xquartz-dev/attachments/20091103/5474e850/attachment.bin>


More information about the Xquartz-dev mailing list