Bug 429180 [windows] Hotkeys/keyboard shortcuts (eg. Ctrl-C) broken in Russian locale after bug 359638 landed r=ere+karlt, sr=roc, a=beltzner

This commit is contained in:
masayuki@d-toybox.com 2008-04-18 07:36:05 -07:00
Родитель 404e11ff71
Коммит 84cc9c369a
2 изменённых файлов: 43 добавлений и 22 удалений

Просмотреть файл

@ -3041,10 +3041,8 @@ UINT nsWindow::MapFromNativeToDOM(UINT aNativeKeyCode)
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
PRUint32 aUnshiftedCharCode, const nsTArray<nsAlternativeCharCode>* aAlternativeCharCodes,
PRUint32 aShiftedCharCode, UINT aVirtualCharCode, LPARAM aKeyData, PRUint32 aFlags)
UINT aVirtualCharCode,
LPARAM aKeyData, PRUint32 aFlags)
{ {
nsKeyEvent event(PR_TRUE, aEventType, this); nsKeyEvent event(PR_TRUE, aEventType, this);
nsPoint point(0, 0); nsPoint point(0, 0);
@ -3053,10 +3051,8 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
event.flags |= aFlags; event.flags |= aFlags;
event.charCode = aCharCode; event.charCode = aCharCode;
if (aUnshiftedCharCode || aShiftedCharCode) { if (aAlternativeCharCodes)
nsAlternativeCharCode altCharCodes(aUnshiftedCharCode, aShiftedCharCode); event.alternativeCharCodes.AppendElements(*aAlternativeCharCodes);
event.alternativeCharCodes.AppendElement(altCharCodes);
}
event.keyCode = aVirtualCharCode; event.keyCode = aVirtualCharCode;
#ifdef KE_DEBUG #ifdef KE_DEBUG
@ -3108,7 +3104,6 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// //
@ -3140,7 +3135,7 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
//printf("In OnKeyDown virt: %d scan: %d\n", DOMKeyCode, aScanCode); //printf("In OnKeyDown virt: %d scan: %d\n", DOMKeyCode, aScanCode);
#endif #endif
BOOL noDefault = DispatchKeyEvent(NS_KEY_DOWN, 0, 0, 0, DOMKeyCode, aKeyData); BOOL noDefault = DispatchKeyEvent(NS_KEY_DOWN, 0, nsnull, DOMKeyCode, aKeyData);
// If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a keypress // If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a keypress
// for almost all keys // for almost all keys
@ -3244,6 +3239,8 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
PRUint16 uniChars[5]; PRUint16 uniChars[5];
PRUint16 shiftedChars[5] = {0, 0, 0, 0, 0}; PRUint16 shiftedChars[5] = {0, 0, 0, 0, 0};
PRUint16 unshiftedChars[5] = {0, 0, 0, 0, 0}; PRUint16 unshiftedChars[5] = {0, 0, 0, 0, 0};
PRUint16 shiftedLatinChar = 0;
PRUint16 unshiftedLatinChar = 0;
PRUint32 numOfUniChars = 0; PRUint32 numOfUniChars = 0;
PRUint32 numOfShiftedChars = 0; PRUint32 numOfShiftedChars = 0;
PRUint32 numOfUnshiftedChars = 0; PRUint32 numOfUnshiftedChars = 0;
@ -3282,6 +3279,18 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
numOfShiftedChars = numOfShiftedChars =
gKbdLayout.GetUniCharsWithShiftState(aVirtualKeyCode, eShift, gKbdLayout.GetUniCharsWithShiftState(aVirtualKeyCode, eShift,
shiftedChars, NS_ARRAY_LENGTH(shiftedChars)); shiftedChars, NS_ARRAY_LENGTH(shiftedChars));
// The current keyboard cannot input alphabets or numerics,
// we should append them for Shortcut/Access keys.
// E.g., for Cyrillic keyboard layout.
if (((NS_VK_0 <= DOMKeyCode && DOMKeyCode <= NS_VK_9) ||
(NS_VK_A <= DOMKeyCode && DOMKeyCode <= NS_VK_Z)) &&
unshiftedChars[0] != DOMKeyCode && shiftedChars[0] != DOMKeyCode) {
shiftedLatinChar = unshiftedLatinChar = DOMKeyCode;
if (NS_VK_A <= DOMKeyCode && DOMKeyCode <= NS_VK_Z)
unshiftedLatinChar += 0x20;
else
shiftedLatinChar = 0;
}
} }
} }
@ -3313,11 +3322,22 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
shiftedChar = shiftedChars[cnt - skipShiftedChars]; shiftedChar = shiftedChars[cnt - skipShiftedChars];
if (skipUnshiftedChars <= cnt) if (skipUnshiftedChars <= cnt)
unshiftedChar = unshiftedChars[cnt - skipUnshiftedChars]; unshiftedChar = unshiftedChars[cnt - skipUnshiftedChars];
DispatchKeyEvent(NS_KEY_PRESS, uniChar, unshiftedChar, nsAutoTArray<nsAlternativeCharCode, 5> altArray;
shiftedChar, keyCode, aKeyData, extraFlags);
if (shiftedChar || unshiftedChar) {
nsAlternativeCharCode chars(unshiftedChar, shiftedChar);
altArray.AppendElement(chars);
}
if (cnt == num - 1 && (unshiftedLatinChar || shiftedLatinChar)) {
nsAlternativeCharCode chars(unshiftedLatinChar, shiftedLatinChar);
altArray.AppendElement(chars);
}
DispatchKeyEvent(NS_KEY_PRESS, uniChar, &altArray,
keyCode, aKeyData, extraFlags);
} }
} else } else
DispatchKeyEvent(NS_KEY_PRESS, 0, 0, 0, DOMKeyCode, aKeyData, extraFlags); DispatchKeyEvent(NS_KEY_PRESS, 0, nsnull, DOMKeyCode, aKeyData, extraFlags);
return noDefault; return noDefault;
} }
@ -3334,7 +3354,7 @@ BOOL nsWindow::OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
#endif #endif
aVirtualKeyCode = sIMEIsComposing ? aVirtualKeyCode : MapFromNativeToDOM(aVirtualKeyCode); aVirtualKeyCode = sIMEIsComposing ? aVirtualKeyCode : MapFromNativeToDOM(aVirtualKeyCode);
BOOL result = DispatchKeyEvent(NS_KEY_UP, 0, 0, 0, aVirtualKeyCode, aKeyData); BOOL result = DispatchKeyEvent(NS_KEY_UP, 0, nsnull, aVirtualKeyCode, aKeyData);
return result; return result;
} }
@ -3411,7 +3431,7 @@ BOOL nsWindow::OnChar(UINT charCode, LPARAM keyData, PRUint32 aFlags)
uniChar = towlower(uniChar); uniChar = towlower(uniChar);
} }
PRBool result = DispatchKeyEvent(NS_KEY_PRESS, uniChar, 0, 0, PRBool result = DispatchKeyEvent(NS_KEY_PRESS, uniChar, nsnull,
charCode, 0, aFlags); charCode, 0, aFlags);
mIsAltDown = saveIsAltDown; mIsAltDown = saveIsAltDown;
mIsControlDown = saveIsControlDown; mIsControlDown = saveIsControlDown;
@ -6535,7 +6555,7 @@ BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState)
// We need to return TRUE here so that Windows doesn't // We need to return TRUE here so that Windows doesn't
// send two WM_CHAR msgs // send two WM_CHAR msgs
DispatchKeyEvent(NS_KEY_PRESS, uniChar, 0, 0, 0, 0); DispatchKeyEvent(NS_KEY_PRESS, uniChar, nsnull, 0, 0);
return PR_TRUE; return PR_TRUE;
} }
@ -6815,7 +6835,7 @@ BOOL nsWindow::OnIMENotify(WPARAM aIMN, LPARAM aData, LRESULT *oResult)
mIsControlDown = PR_FALSE; mIsControlDown = PR_FALSE;
mIsAltDown = PR_TRUE; mIsAltDown = PR_TRUE;
DispatchKeyEvent(NS_KEY_PRESS, 0, 0, 0, 192, 0); // XXX hack hack hack DispatchKeyEvent(NS_KEY_PRESS, 0, nsnull, 192, 0); // XXX hack hack hack
if (aIMN == IMN_SETOPENSTATUS) if (aIMN == IMN_SETOPENSTATUS)
sIMEIsStatusChanged = PR_TRUE; sIMEIsStatusChanged = PR_TRUE;
} }

Просмотреть файл

@ -56,6 +56,7 @@
#include "nsString.h" #include "nsString.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsTArray.h"
class nsNativeDragTarget; class nsNativeDragTarget;
class nsIRollupListener; class nsIRollupListener;
@ -65,6 +66,8 @@ class nsIFile;
class imgIContainer; class imgIContainer;
struct nsAlternativeCharCode;
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY
#include "OLEACC.H" #include "OLEACC.H"
#include "nsIAccessible.h" #include "nsIAccessible.h"
@ -332,11 +335,9 @@ protected:
nsRect& aResult); nsRect& aResult);
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
PRUint32 aUnshiftedCharCode, const nsTArray<nsAlternativeCharCode>* aAlternativeChars,
PRUint32 aShiftedCharCodes, UINT aVirtualCharCode, LPARAM aKeyCode,
UINT aVirtualCharCode, PRUint32 aFlags = 0);
LPARAM aKeyCode,
PRUint32 aFlags = 0);
virtual PRBool DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus); virtual PRBool DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus);
virtual PRBool OnScroll(UINT scrollCode, int cPos); virtual PRBool OnScroll(UINT scrollCode, int cPos);