GNOME Bugzilla – Bug 107000
Add signals to GdkKeymap for monitoring caps_lock, etc.
Last modified: 2008-09-29 20:41:34 UTC
For a password entry, it's useful to be able to track whether caps lock is down... we should be able to allow this without cluttering the API with too much bloat.
Created attachment 59236 [details] [review] untested patch
Created attachment 59264 [details] [review] working patch This patch works for me. Note that - I haven't tested the group switch modifier - I have made no attempt to handle the non-XKB case - The API is currently restricted to Caps Lock, Num Lock and Group Switch. Do we need to support more of the excessive genericity of XKB ?
- Hmm, group_switch seems less useful to me than scroll_lock. (Not that scroll_lock is that useful...) - The three-outs interface makes me twitchy as inflexible. Not that we *really* are likely to want to change it in the future, but who knows... What if you just had: guint gdk_keymap_get_locked_keys(keymap) And left it fuzzy as to exactly what keys might be reported there? (You could even include the old state in the signal like GtkWidget::direction-changed, or do it like GdkWindowStateEvent; quite possibly both are just extra useless complexity.) - The XKB code looks plausible to me, without digging out the spec. - In terms of X-without-XKB and Windows, my suggested method would be 1. Query the state on focus in (this really wants gdkasync.c action, but for legacy systems, it's probably not worth it.) 2. Check the state on each received key press or release. I don't know how to get active notification on windows without adding a global hook on WM_KEYDOWN, which is almost certainly a bad idea. (You need a separate DLL that communicates with GTK+, unless you want to load the GTK+ DLL into every application on the system...) -
What does gdk_keymap_get_locked_keys(keymap) return, a single keyval ? Or is it rather gdk_keymap_get_locked_modifiers(keymap) and returns modifier masks ored together ? The problem with that is that we don't have a fixed modifier bit for num lock, group switch or scroll lock, I think.
For now I've decided to only add a simple getter for caps lock status, since that is what I need for capslock warning in password entries. 2008-09-29 Matthias Clasen <mclasen@redhat.com> Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc. * gdk/gdk.symbols: * gdk/gdkkeys.[ch]: Add a new GdkKeymap::state-changed signal, and a gdk_keymap_get_caps_lock_state function. * gdk/x11/gdkkeys-x11.c: Implement it here. For now, only emit state-changed when caps lock lockedness changes. * gdk/x11/gdkdisplay-x11.c: Also select for modifier lock status changes in the XkbSelectEventDetails call.