[AD] filtering out OS key handling

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


There needs to be a way to optionally filter out the OS handling of
keys in A5. For instance, in Windows in a windowed mode, the following
happens:

1) User presses ALT
2.A) KEY_DOWN is generated for ALT
2.B) Windows silently activates the menu. (Every window has a system menu)
3) User presses another key
4.A) Windows traps it. If it's a SPACE, then the system menu comes
down. If there is a menubar, and you press the associated shortcut
key, that menu drops.
4.B) Allegro misses it.

It's easy to fix in Windows by adding this to wnewwin.c:

if ((wParam & 0xfff0) == SC_KEYMENU) return 0;

Of course that would always disable the key driven menu, which isn't
guaranteed to be the correct behavior. (Although it most certainly is
the correct behavior if no visible menu is present.)

See <http://msdn.microsoft.com/en-us/library/ms646360%28VS.85%29.aspx>
for a variety of other potential conflicts.

What's the best way to provide an interface for this?  There is
al_set_new_display_flags(), but I don't think it really fits that as
these are things that can be enabled/disabled after the display window
is created.

Conceptually, one is usually trying to avoid interference with his own
keyboard handler. e.g., My goal is for the ALT key to be untouched by
Windows... I'm not against the enabling of a system menu, per se. But
to make things more complicated, I don't really want to prevent
ALT-TAB from working. So I'm not sure how to handle this without
exposing too much platform dependent checks.

al_inhibit_os_key(display, ALLEGRO_KEYMOD_ALT, true); // disables OS
processing of the alt key for that display

[PS: inhibit is a funny word, but it's already being used in reference
to the screensaver, so I use it here.]

In Windows, that would prevent the menu from being opened via the ALT
key, but I wouldn't want it to disable task switching (ALT-TAB). I
think that should be its own function:

al_inhibit_task_switching(display, true); // disables ALT-TAB in
Windows for that display

I don't want to submit any patches until I get some input, especially
regarding other platforms.

--
Matthew Leverton




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/