Hi,
Let me at least answer one of your questions before these get lost in the discussion.
Am 03.12.2015 um 23:03 schrieb Hans-Peter Diettrich:
Q: Is kbswitch notified of focus changes, and if so: how?
As you have already found out, kbswitch has been implemented as a system-wide keyboard layout switcher and not a per-application one. Therefore, it doesn't care about focus at all.
A proper per-application keyboard layout switcher as part of the Language Bar should also be implemented as a shell extension instead of a tray icon to be as flexible as the Windows original. To get notified of focus changes, an application should probably hook the EVENT_SYSTEM_FOREGROUND event using the SetWinEventHook API. The rest can be done using calls to GetForegroundWindow, GetWindowThreadProcessId and GetKeyboardLayout as you already suggested.
Unfortunately, I lack deeper experience with keyboard layout internals, so this is all I can tell you for now. You may find someone in #reactos or #reactos-dev on IRC with more expertise on this.
Cheers,
Colin