Bug 708936 Dispatch defaultPrevented Alt keyup event if VK_MENU is received with WM_KEYUP instead of WM_SYSKEYUP r=jimm+smaug

This commit is contained in:
Masayuki Nakano 2013-02-12 10:03:00 +09:00
parent 0e302a5094
commit 97bae25640
3 changed files with 9 additions and 37 deletions

View File

@ -41,7 +41,6 @@ static UINT sWM_MSIME_MOUSE = 0; // mouse message for MSIME 98/2000
#define IMEMOUSE_WUP 0x10 // wheel up
#define IMEMOUSE_WDOWN 0x20 // wheel down
bool nsIMM32Handler::sIsStatusChanged = false;
bool nsIMM32Handler::sIsIME = true;
bool nsIMM32Handler::sIsIMEOpening = false;
@ -704,29 +703,6 @@ nsIMM32Handler::OnIMENotify(nsWindow* aWindow,
}
#endif // PR_LOGGING
if (::GetKeyState(NS_VK_ALT) >= 0) {
return false;
}
// XXXmnakano Following code was added by bug 28852 (Key combo to trun ON/OFF
// Japanese IME incorrectly activates "File" menu). If one or more keypress
// events come between Alt keydown event and Alt keyup event, XUL menubar
// isn't activated by the Alt keyup event. Therefore, this code sends dummy
// keypress event to Gecko. But this is ugly, and this fires incorrect DOM
// keypress event. So, we should find another way for the bug.
// add hacky code here
mozilla::widget::ModifierKeyState modKeyState(false, false, true);
mozilla::widget::NativeKey nativeKey; // Dummy is okay for this usage.
nsKeyEvent keyEvent(true, NS_KEY_PRESS, aWindow);
keyEvent.keyCode = 192;
aWindow->InitKeyEvent(keyEvent, nativeKey, modKeyState);
aWindow->DispatchKeyEvent(keyEvent, nullptr);
sIsStatusChanged = sIsStatusChanged || (wParam == IMN_SETOPENSTATUS);
PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
("IMM32: OnIMENotify, sIsStatusChanged=%s\n",
sIsStatusChanged ? "TRUE" : "FALSE"));
// not implement yet
return false;
}

View File

@ -82,12 +82,9 @@ public:
{
return IsComposing() && IsComposingWindow(aWindow);
}
static bool IsStatusChanged() { return sIsStatusChanged; }
static bool IsDoingKakuteiUndo(HWND aWnd);
static void NotifyEndStatusChange() { sIsStatusChanged = false; }
static bool CanOptimizeKeyAndIMEMessages(MSG *aNextKeyOrIMEMessage);
#ifdef DEBUG
@ -292,7 +289,6 @@ protected:
bool mIsComposingOnPlugin;
bool mNativeCaretIsCreated;
static bool sIsStatusChanged;
static bool sIsIME;
static bool sIsIMEOpening;

View File

@ -5707,12 +5707,7 @@ LRESULT nsWindow::ProcessKeyUpMessage(const MSG &aMsg, bool *aEventDispatched)
return FALSE;
}
if (!nsIMM32Handler::IsComposingOn(this) &&
(aMsg.message != WM_KEYUP || aMsg.wParam != VK_MENU)) {
// Ignore VK_MENU if it's not a system key release, so that the menu bar does not trigger
// This helps avoid triggering the menu bar for ALT key accelerators used in
// assistive technologies such as Window-Eyes and ZoomText, and when using Alt+Tab
// to switch back to Mozilla in Windows 95 and Windows 98
if (!nsIMM32Handler::IsComposingOn(this)) {
return OnKeyUp(aMsg, modKeyState, aEventDispatched);
}
@ -5751,9 +5746,7 @@ LRESULT nsWindow::ProcessKeyDownMessage(const MSG &aMsg,
return FALSE;
LRESULT result = 0;
if (modKeyState.IsAlt() && nsIMM32Handler::IsStatusChanged()) {
nsIMM32Handler::NotifyEndStatusChange();
} else if (!nsIMM32Handler::IsComposingOn(this)) {
if (!nsIMM32Handler::IsComposingOn(this)) {
result = OnKeyDown(aMsg, modKeyState, aEventDispatched, nullptr);
// OnKeyDown cleaned up the redirected message information itself, so,
// we should do nothing.
@ -6863,6 +6856,13 @@ LRESULT nsWindow::OnKeyUp(const MSG &aMsg,
NativeKey nativeKey(gKbdLayout, this, aMsg);
keyupEvent.keyCode = nativeKey.GetDOMKeyCode();
InitKeyEvent(keyupEvent, nativeKey, aModKeyState);
// Set defaultPrevented of the key event if the VK_MENU is not a system key
// release, so that the menu bar does not trigger. This helps avoid
// triggering the menu bar for ALT key accelerators used in assistive
// technologies such as Window-Eyes and ZoomText or for switching open state
// of IME.
keyupEvent.mFlags.mDefaultPrevented =
(aMsg.wParam == VK_MENU && aMsg.message != WM_SYSKEYUP);
return DispatchKeyEvent(keyupEvent, &aMsg);
}