Last night when chasing another problem, valgrind memcheck reported a
problem in check_modifiers() in XGServerEvent.m. I think the reported
problem is non-existent, but it got me thinking about this code.
// checks whether a GNUstep modifier (key_sym) is pressed when we're
only able
// to check whether X keycodes are pressed in xEvent->xkeymap;
static int check_modifier (XEvent *xEvent, KeySym key_sym,
XModifierKeymap *modmap)
{
char *key_vector;
int by,bi;
// implementation fails if key_sym is only accessible by a multi-key
// combination, however this is not expected for GNUstep modifier keys;
// to fix implementation, would need to first determine modifier
state by
// a first-pass scann of the full key vector, then use the state in
place
// of "0" below in XKeycodeToKeysym
key_vector = xEvent->xkeymap.key_vector;
for (by=0; by<32; by++) {
for (bi=0; bi<8; bi++) {
if ((key_vector[by] & (1 << bi)) &&
(XKeycodeToKeysym(xEvent->xkeymap.display,by*8+bi,0)==key_sym))
return 1;
}
}
return 0;
}
Why don't we just convert the handed in key_sym into a keycode with
XKeysymToKeycode and check the map just for that single key?
But then I am not sure what this function is used for at all. It gets
called when a KeymapNotify event happens. There we still get a modifier
map, which we no longer use anywhere.
This whole event is normally send just after a FocusIn and EnterNotify
event and the later at least already has the modifiers in the status
field. Wouldn't it be better to register all the special GNUstep
modifier keys as X modifiers and rely on X to handle them correctly. But
as said, I really don't understand this area.
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev