diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 507d0865a0fc..90052ed43335 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1069,6 +1069,9 @@ pref("advanced.system.supportDDEExec", true); // Use CP932 compatible map for JIS X 0208 pref("intl.jis0208.map", "CP932"); +// Switch the keyboard layout per window +pref("intl.keyboard.per_window_layout", false); + # WINNT #endif diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 50bef70cf56a..504b7668cd39 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -854,6 +854,7 @@ nsWindow::nsWindow() : nsBaseWidget() mNativeDragTarget = nsnull; mIsTopWidgetWindow = PR_FALSE; + mLastKeyboardLayout = 0; sInstanceCount++; @@ -866,6 +867,7 @@ nsWindow::nsWindow() : nsBaseWidget() HKL nsWindow::gKeyboardLayout = 0; UINT nsWindow::gCurrentKeyboardCP = 0; +PRBool nsWindow::gSwitchKeyboardLayout = PR_FALSE; //------------------------------------------------------------------------- // @@ -1577,6 +1579,11 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent, &trimOnMinimize)) && !trimOnMinimize) gTrimOnMinimize = 0; + + PRBool switchKeyboardLayout; + if (NS_SUCCEEDED(prefBranch->GetBoolPref("intl.keyboard.per_window_layout", + &switchKeyboardLayout))) + gSwitchKeyboardLayout = switchKeyboardLayout; } } } @@ -4184,6 +4191,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT if (WA_INACTIVE == fActive) { gJustGotDeactivate = PR_TRUE; + if (mIsTopWidgetWindow) + mLastKeyboardLayout = gKeyboardLayout; } else { gJustGotActivate = PR_TRUE; nsMouseEvent event(NS_MOUSE_ACTIVATE, this); @@ -4198,6 +4207,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue = MA_ACTIVATE; else *aRetValue = MA_NOACTIVATE; + + if (gSwitchKeyboardLayout && mLastKeyboardLayout) + ActivateKeyboardLayout(mLastKeyboardLayout, 0); } } break; diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index ac81afed3b28..87b1092de3a2 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -568,6 +568,9 @@ protected: static UINT gCurrentKeyboardCP; static HKL gKeyboardLayout; + static PRBool gSwitchKeyboardLayout; + + HKL mLastKeyboardLayout; // Drag & Drop nsNativeDragTarget * mNativeDragTarget;