Getting the current state of the lock keys



Hi everyone.

I’d like to get the current state of the various “lock” keys on the
keyboard.  Is that possible with GTK+/GDK?  I want to do this without
inspecting a key event, because the lock state might change while the
program’s window does not have the focus.

The gdk_display_get_pointer() function looks like the right way to go,
as it will give me a GdkModifierType bitfield.  GDK_LOCK_MASK seems to
be caps lock, but the other lock keys seem to be buried within the
GDK_MODn_MASK bits.  The documentation tells me:

  GDK_MOD1_MASK   the fourth modifier key (it depends on the
                  modifier mapping of the X server which key is
		  interpreted as this modifier, but normally it is the
		  Alt key).
  GDK_MOD2_MASK   the fifth modifier key (it depends on the modifier
                  mapping of the X server which key is interpreted as
		  this modifier).
  …

How can I determine which of these modifier keys the various other locks
(num, scroll, kana, …) have been assigned to, so that I know which bit
to check?  It must be possible to query the X server for this
information, since running 'xmodmap' can tell me that information, but I
want to get this information from GTK+/GDK.  What if my program isn’t
running under X?  Is there some default mapping of lock keys to bits
used?

Thanks,

Cameron

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam jabber org  ▪  ICQ 26955922  ▪  MSN cam mcc id au



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]