Re: [gtk-list] Re: what are equiv of Motif actions?
- From: Havoc Pennington <rhp zirx pair com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: what are equiv of Motif actions?
- Date: Sun, 6 Jun 1999 16:05:37 -0400 (EDT)
On Sun, 6 Jun 1999, Michael J. Hammel wrote:
>
> BTW, is there a way to determine what the MODx enums map to on a keyboard?
>
Gtk itself assumes Alt is on MOD1, but this isn't really right I'm told.
Code from AbiWord:
#include <gdk/gdkx.h>
#include <X11/keysym.h>
static GdkModifierType s_getAltMask(void)
{
//////////////////////////////////////////////////////////////////
// find out what modifier mask XL_Alt_{L,R} are bound to.
//////////////////////////////////////////////////////////////////
int alt_mask = 0;
Display * display = GDK_DISPLAY();
KeyCode kcAltL = XKeysymToKeycode(display,XK_Alt_L);
KeyCode kcAltR = XKeysymToKeycode(display,XK_Alt_R);
XModifierKeymap * pModMap = XGetModifierMapping(display);
int mkpm = pModMap->max_keypermod;
int k,m;
int mAltL=-1;
int mAltR=-1;
for (m=0; m<8; m++)
{
for (k=0; k<mkpm; k++)
{
KeyCode code = pModMap->modifiermap[m*mkpm + k];
if (kcAltL && (code == kcAltL))
mAltL = m;
if (kcAltR && (code == kcAltR))
mAltR = m;
}
}
switch (mAltL)
{
default: //
Shoul
d not happen...
case -1: //
Alt_L
is not a modifier key ??
case 0: //
Alt_L
is mapped to SHIFT ??
case 1: //
Alt_L
is mapped to (Caps)LOCK ??
case 2: //
Alt_L
is mapped to CONTROL ??
break; //
... i
gnore this key.
case 3: alt_mask |= GDK_MOD1_MASK; break;
case 4: alt_mask |= GDK_MOD2_MASK; break;
case 5: alt_mask |= GDK_MOD3_MASK; break;
case 6: alt_mask |= GDK_MOD4_MASK; break;
case 7: alt_mask |= GDK_MOD5_MASK; break;
}
switch (mAltR)
{
default: //
Shoul
d not happen...
case -1: //
Alt_R
is not a modifier key ??
case 0: //
Alt_R
is mapped to SHIFT ??
case 1: //
Alt_R
is mapped to (Caps)LOCK ??
case 2: //
Alt_R is mapped to CONTROL ??
break; //
... i
gnore this key.
case 3: alt_mask |= GDK_MOD1_MASK; break;
case 4: alt_mask |= GDK_MOD2_MASK; break;
case 5: alt_mask |= GDK_MOD3_MASK; break;
case 6: alt_mask |= GDK_MOD4_MASK; break;
case 7: alt_mask |= GDK_MOD5_MASK; break;
}
XFreeModifiermap(pModMap);
if (!alt_mask) // if
nothing se
t, fall back to MOD1
alt_mask = GDK_MOD1_MASK;
UT_DEBUGMSG(("Keycodes for alt [l 0x%x][r 0x%x] using modifiers
[%d %d]
yields [0x%x]\n",kcAltL,kcAltR,mAltL-2,mAltR-2,alt_mask));
return (GdkModifierType)alt_mask;
}
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]