Author: tretiakov
Date: Wed Feb 14 16:00:38 2007
New Revision: 25798
URL:
http://svn.reactos.org/svn/reactos?rev=25798&view=rev
Log:
Post WM_INPUTLANGCHANGE to thread's focus windows when keyboard layout is changed.
Modified:
trunk/reactos/base/applications/testsets/user32/kbdlayout/kbdlayout.c
trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c
Modified: trunk/reactos/base/applications/testsets/user32/kbdlayout/kbdlayout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/user32/kbdlayout/kbdlayout.c (original)
+++ trunk/reactos/base/applications/testsets/user32/kbdlayout/kbdlayout.c Wed Feb 14
16:00:38 2007
@@ -240,7 +240,10 @@
SubclassWnd(GetDlgItem(hDlg, IDC_EDIT2), L"Edit2");
SubclassWnd(GetDlgItem(hDlg, IDC_KLID), L"Klid");
SubclassWnd(GetDlgItem(hDlg, IDC_HANDLE), L"Handle");
- SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"Button");
+ SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"CancelB");
+ SubclassWnd(GetDlgItem(hDlg, IDC_ACTIVATE), L"ActivateB");
+ SubclassWnd(GetDlgItem(hDlg, IDC_REFRESH), L"RefreshB");
+ SubclassWnd(GetDlgItem(hDlg, IDC_UNLOAD), L"UnloadB");
CheckRadioButton(hDlg, IDC_FROMLIST, IDC_FROMEDIT, IDC_FROMLIST);
SetWindowText(GetDlgItem(hDlg, IDC_KLID), L"00000419");
@@ -262,10 +265,12 @@
{
if((hKl = GetActivateHandle(hDlg)) != INVALID_HANDLE_VALUE)
{
- if(!ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg)))
+ if(!(hKl = ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg))))
FormatBox(hDlg, MB_ICONERROR, L"Error",
L"ActivateKeyboardLayout() failed. %d", GetLastError());
else UpdateData(hDlg);
+ //FormatBox(hDlg, 0, L"Activated", L"Prev - %x, err - %d.",
hKl,
+ // GetLastError());
}
else MessageBox(hDlg, L"No item selected", L"Error",
MB_ICONERROR);
break;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c Wed Feb 14 16:00:38 2007
@@ -321,12 +321,22 @@
static PKBL UserActivateKbl(PW32THREAD Thread, PKBL pKbl)
{
PKBL Prev;
+ MSG Msg;
Prev = Thread->KeyboardLayout;
Prev->RefCount--;
Thread->KeyboardLayout = pKbl;
pKbl->RefCount++;
+ // Post WM_INPUTLANGCHANGE to thread's focus window
+
+ Msg.hwnd = Thread->MessageQueue->FocusWindow;
+ Msg.message = WM_INPUTLANGCHANGE;
+ Msg.wParam = 0; // Charset. FIXME: what is this?
+ Msg.lParam = (LPARAM)pKbl->hkl; // klid
+
+ MsqPostMessage(Thread->MessageQueue, &Msg, FALSE, QS_POSTMESSAGE);
+
return Prev;
}
@@ -419,9 +429,9 @@
_SEH_TRY
{
- ProbeForWrite(lpszName, 9*sizeof(WCHAR), 1);
+ ProbeForWrite(lpszName, KL_NAMELENGTH*sizeof(WCHAR), 1);
pKbl = PsGetCurrentThreadWin32Thread()->KeyboardLayout;
- RtlCopyMemory(lpszName, pKbl->Name, 9*sizeof(WCHAR));
+ RtlCopyMemory(lpszName, pKbl->Name, KL_NAMELENGTH*sizeof(WCHAR));
ret = TRUE;
}
_SEH_HANDLE
@@ -488,17 +498,27 @@
{
PKBL pKbl;
HKL Ret = NULL;
+ PW32THREAD pWThread;
UserEnterExclusive();
pKbl = UserHklToKbl(hKl);
+ //FIXME: Respect flags!
+
if(pKbl)
{
- pKbl = UserActivateKbl(PsGetCurrentThreadWin32Thread(), pKbl);
- Ret = pKbl->hkl;
-
- //FIXME: Respect flags!
+ pWThread = PsGetCurrentThreadWin32Thread();
+
+ if(pWThread->KeyboardLayout->hkl == hKl)
+ {
+ Ret = hKl;
+ }
+ else
+ {
+ pKbl = UserActivateKbl(pWThread, pKbl);
+ Ret = pKbl->hkl;
+ }
}
UserLeave();