From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Cc: emacs-devel@gnu.org
Subject: Re: w32-pass-lwindow-to-system does not work as expected
Date: Wed, 06 Jul 2005 00:43:12 +0200 [thread overview]
Message-ID: <42CB0D00.3030900@student.lu.se> (raw)
In-Reply-To: <uy88lndis.fsf@gnu.org>
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));
}
next prev parent reply other threads:[~2005-07-05 22:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-05 19:14 w32-pass-lwindow-to-system does not work as expected Lennart Borgman
2005-07-05 19:30 ` Juanma Barranquero
2005-07-05 19:42 ` Lennart Borgman
2005-07-05 19:53 ` Juanma Barranquero
2005-07-05 20:06 ` Lennart Borgman
2005-07-05 22:17 ` Juanma Barranquero
2005-07-05 22:24 ` Lennart Borgman
2005-07-05 21:04 ` Jason Rumney
2005-07-05 22:11 ` Juanma Barranquero
2005-07-05 19:36 ` Jason Rumney
2005-07-05 19:56 ` Lennart Borgman
2005-07-05 21:08 ` Jason Rumney
2005-07-05 21:22 ` Lennart Borgman
2005-07-05 21:34 ` Eli Zaretskii
2005-07-05 20:54 ` Lennart Borgman
2005-07-06 4:43 ` Eli Zaretskii
2005-07-06 6:54 ` Lennart Borgman
2005-07-06 18:51 ` Eli Zaretskii
2005-07-06 18:23 ` Lennart Borgman
2005-07-05 22:43 ` Lennart Borgman [this message]
2005-07-06 7:08 ` Jason Rumney
-- strict thread matches above, loose matches on Subject: below --
2005-07-06 8:36 LENNART BORGMAN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42CB0D00.3030900@student.lu.se \
--to=lennart.borgman.073@student.lu.se \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.