Eli Zaretskii wrote:
Watch out for the caveats of using low-level keyboard interfaces: what
the hook gets is the scan code of the key and various bit masks for ...
I took a look at the code in w32fns.c again. It looks to me everything
is in place to handle the <lwindow> key, except for that low level
keyboard hook. Everything the keyboard hook has to to is to avoid
sending anything to the system when <lwindow> is typed and Emacs wants it.
So if it works at all it should perhaps be very little trouble:
1) add the hook at thread startup
2) the hook prevents sending any VK_LWIN events further if Emacs wants
them, otherwise not.
3) remove the hook at thread termination.
Below is code for doing this. I have assumed that NILP and
Vw32_pass_lwindow_to_system are actually available in the input thread.
(Or did I read that wrong?)
But as I said I am not a guru on this, I just read the docs and the
code. Am I misunderstanding something here?
*** Adding the low level keyboard hook to the main thread at thread startup:
hLowKBhook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, NULL,
dwMainThreadId);
*** Removing the low level keyboard hook at the main thread tear down:
UnhookWindowsHookEx(hLowKBhook);
*** The hook procedure. This runs in the context of the thread.
LRESULT LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM lParam)
{
BOOL fHandled = FALSE;
if (nCode == HC_ACTION)
{
KBDLLHOOKSTRUCT *pkbdllhook = (KBDLLHOOKSTRUCT *)lParam;
switch (wParam)
{
case WM_KEYUP:
case WM_KEYDOWN: // This was not in the MS example, why??
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
switch (pkbdllhook->vkCode)
{
case VK_LWIN:
{
// the user pressed the <lwindow> key
if (!NILP (Vw32_pass_lwindow_to_system))
fHandled = TRUE;
break;
}
}
}
}
return (fHandled ? TRUE : CallNextHookEx(hhook, nCode, wParam, lParam));
}
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel