Bug 630811 part.5 Support new modifiers on all events derived from nsInputEvent on GTK r=karlt

This commit is contained in:
Masayuki Nakano 2012-04-25 12:00:02 +09:00
parent 0efb0397d8
commit 9de2f09ddc

View File

@ -551,22 +551,48 @@ KeymapWrapper::InitInputEvent(nsInputEvent& aInputEvent,
{
KeymapWrapper* keymapWrapper = GetInstance();
aInputEvent.isShift =
keymapWrapper->AreModifiersActive(SHIFT, aModifierState);
aInputEvent.isControl =
keymapWrapper->AreModifiersActive(CTRL, aModifierState);
aInputEvent.isAlt =
keymapWrapper->AreModifiersActive(ALT, aModifierState);
// XXX DOM Meta key should be TRUE only on Mac. We need to discuss this
// issue later.
aInputEvent.isMeta = false;
aInputEvent.modifiers = 0;
// DOM Meta key should be TRUE only on Mac. We need to discuss this
// issue later.
if (keymapWrapper->AreModifiersActive(SHIFT, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_SHIFT;
}
if (keymapWrapper->AreModifiersActive(CTRL, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_CONTROL;
}
if (keymapWrapper->AreModifiersActive(ALT, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_ALT;
}
if (keymapWrapper->AreModifiersActive(SUPER, aModifierState) ||
keymapWrapper->AreModifiersActive(HYPER, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_WIN;
}
if (keymapWrapper->AreModifiersActive(ALTGR, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_ALTGRAPH;
}
if (keymapWrapper->AreModifiersActive(CAPS_LOCK, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_CAPSLOCK;
}
if (keymapWrapper->AreModifiersActive(NUM_LOCK, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_NUMLOCK;
}
if (keymapWrapper->AreModifiersActive(SCROLL_LOCK, aModifierState)) {
aInputEvent.modifiers |= MODIFIER_SCROLL;
}
PR_LOG(gKeymapWrapperLog, PR_LOG_DEBUG,
("KeymapWrapper(%p): InitInputEvent, aModifierState=0x%08X, "
"aInputEvent={ isShift=%s, isControl=%s, isAlt=%s, isMeta=%s }",
keymapWrapper, aModifierState,
GetBoolName(aInputEvent.isShift), GetBoolName(aInputEvent.isControl),
GetBoolName(aInputEvent.isAlt), GetBoolName(aInputEvent.isMeta)));
"aInputEvent.modifiers=0x%04X (Shift: %s, Control: %s, Alt: %s, "
"Win: %s, AltGr: %s, CapsLock: %s, NumLock: %s, ScrollLock: %s)",
keymapWrapper, aModifierState, aInputEvent.modifiers,
GetBoolName(aInputEvent.modifiers & MODIFIER_SHIFT),
GetBoolName(aInputEvent.modifiers & MODIFIER_CONTROL),
GetBoolName(aInputEvent.modifiers & MODIFIER_ALT),
GetBoolName(aInputEvent.modifiers & MODIFIER_WIN),
GetBoolName(aInputEvent.modifiers & MODIFIER_ALTGRAPH),
GetBoolName(aInputEvent.modifiers & MODIFIER_CAPSLOCK),
GetBoolName(aInputEvent.modifiers & MODIFIER_NUMLOCK),
GetBoolName(aInputEvent.modifiers & MODIFIER_SCROLL)));
switch(aInputEvent.eventStructType) {
case NS_MOUSE_EVENT:
@ -580,47 +606,6 @@ KeymapWrapper::InitInputEvent(nsInputEvent& aInputEvent,
}
nsMouseEvent_base& mouseEvent = static_cast<nsMouseEvent_base&>(aInputEvent);
mouseEvent.modifiers = 0;
if (aInputEvent.isShift) {
mouseEvent.modifiers |= MODIFIER_SHIFT;
}
if (aInputEvent.isControl) {
mouseEvent.modifiers |= MODIFIER_CONTROL;
}
if (aInputEvent.isAlt) {
mouseEvent.modifiers |= MODIFIER_ALT;
}
if (keymapWrapper->AreModifiersActive(SUPER, aModifierState) ||
keymapWrapper->AreModifiersActive(HYPER, aModifierState)) {
mouseEvent.modifiers |= MODIFIER_WIN;
}
if (keymapWrapper->AreModifiersActive(ALTGR, aModifierState)) {
mouseEvent.modifiers |= MODIFIER_ALTGRAPH;
}
if (keymapWrapper->AreModifiersActive(CAPS_LOCK, aModifierState)) {
mouseEvent.modifiers |= MODIFIER_CAPSLOCK;
}
if (keymapWrapper->AreModifiersActive(NUM_LOCK, aModifierState)) {
mouseEvent.modifiers |= MODIFIER_NUMLOCK;
}
if (keymapWrapper->AreModifiersActive(SCROLL_LOCK, aModifierState)) {
mouseEvent.modifiers |= MODIFIER_SCROLL;
}
PR_LOG(gKeymapWrapperLog, PR_LOG_DEBUG,
("KeymapWrapper(%p): InitInputEvent, aInputEvent has modifiers, "
"aInputEvent.modifiers=0x%04X (Shift: %s, Control: %s, Alt: %s, "
"Win: %s, AltGr: %s, CapsLock: %s, NumLock: %s, ScrollLock: %s)",
keymapWrapper, mouseEvent.modifiers,
GetBoolName(mouseEvent.modifiers & MODIFIER_SHIFT),
GetBoolName(mouseEvent.modifiers & MODIFIER_CONTROL),
GetBoolName(mouseEvent.modifiers & MODIFIER_ALT),
GetBoolName(mouseEvent.modifiers & MODIFIER_WIN),
GetBoolName(mouseEvent.modifiers & MODIFIER_ALTGRAPH),
GetBoolName(mouseEvent.modifiers & MODIFIER_CAPSLOCK),
GetBoolName(mouseEvent.modifiers & MODIFIER_NUMLOCK),
GetBoolName(mouseEvent.modifiers & MODIFIER_SCROLL)));
mouseEvent.buttons = 0;
if (aModifierState & GDK_BUTTON1_MASK) {
mouseEvent.buttons |= nsMouseEvent::eLeftButtonFlag;
@ -797,8 +782,8 @@ KeymapWrapper::InitKeyEvent(nsKeyEvent& aKeyEvent,
((aKeyEvent.message == NS_KEY_DOWN) ? "NS_KEY_DOWN" :
(aKeyEvent.message == NS_KEY_PRESS) ? "NS_KEY_PRESS" :
"NS_KEY_UP"),
GetBoolName(aKeyEvent.isShift), GetBoolName(aKeyEvent.isControl),
GetBoolName(aKeyEvent.isAlt), GetBoolName(aKeyEvent.isMeta)));
GetBoolName(aKeyEvent.IsShift()), GetBoolName(aKeyEvent.IsControl()),
GetBoolName(aKeyEvent.IsAlt()), GetBoolName(aKeyEvent.IsMeta())));
if (aKeyEvent.message == NS_KEY_PRESS) {
keymapWrapper->InitKeypressEvent(aKeyEvent, aGdkKeyEvent);
@ -917,7 +902,7 @@ KeymapWrapper::InitKeypressEvent(nsKeyEvent& aKeyEvent,
// If Ctrl or Alt or Meta is pressed, we need to append the key details
// for handling shortcut key. Otherwise, we have no additional work.
if (!aKeyEvent.isControl && !aKeyEvent.isAlt && !aKeyEvent.isMeta) {
if (!aKeyEvent.IsControl() && !aKeyEvent.IsAlt() && !aKeyEvent.IsMeta()) {
PR_LOG(gKeymapWrapperLog, PR_LOG_ALWAYS,
("KeymapWrapper(%p): InitKeypressEvent, "
"keyCode=0x%02X, charCode=0x%08X",
@ -1008,8 +993,8 @@ KeymapWrapper::InitKeypressEvent(nsKeyEvent& aKeyEvent,
nsAlternativeCharCode altLatinCharCodes(0, 0);
PRUint32 unmodifiedCh =
aKeyEvent.isShift ? altCharCodes.mShiftedCharCode :
altCharCodes.mUnshiftedCharCode;
aKeyEvent.IsShift() ? altCharCodes.mShiftedCharCode :
altCharCodes.mUnshiftedCharCode;
// unshifted charcode of found keyboard layout.
PRUint32 ch = GetCharCodeFor(aGdkKeyEvent, baseState, minGroup);
@ -1029,9 +1014,9 @@ KeymapWrapper::InitKeypressEvent(nsKeyEvent& aKeyEvent,
// replace the charCode to Latin char if Alt and Meta keys are not
// pressed. (Alt should be sent the localized char for accesskey
// like handling of Web Applications.)
ch = aKeyEvent.isShift ? altLatinCharCodes.mShiftedCharCode :
altLatinCharCodes.mUnshiftedCharCode;
if (ch && !(aKeyEvent.isAlt || aKeyEvent.isMeta) &&
ch = aKeyEvent.IsShift() ? altLatinCharCodes.mShiftedCharCode :
altLatinCharCodes.mUnshiftedCharCode;
if (ch && !(aKeyEvent.IsAlt() || aKeyEvent.IsMeta()) &&
aKeyEvent.charCode == unmodifiedCh) {
aKeyEvent.charCode = ch;
}