mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 951021 Android widget should set modifier state at dispatching events derived from WidgetInputEvent r=nchen
This commit is contained in:
parent
156c631057
commit
f31dddba06
@ -667,12 +667,8 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
|
||||
return event;
|
||||
}
|
||||
|
||||
event.modifiers = 0;
|
||||
event.modifiers = DOMModifiers();
|
||||
event.time = Time();
|
||||
event.InitBasicModifiers(IsCtrlPressed(),
|
||||
IsAltPressed(),
|
||||
IsShiftPressed(),
|
||||
IsMetaPressed());
|
||||
|
||||
const nsIntPoint& offset = widget->WidgetToScreenOffset();
|
||||
event.touches.SetCapacity(endIndex - startIndex);
|
||||
@ -733,18 +729,7 @@ AndroidGeckoEvent::MakeMultiTouchInput(nsIWidget* widget)
|
||||
}
|
||||
|
||||
MultiTouchInput event(type, Time(), 0);
|
||||
if (IsCtrlPressed()) {
|
||||
event.modifiers |= MODIFIER_CONTROL;
|
||||
}
|
||||
if (IsAltPressed()) {
|
||||
event.modifiers |= MODIFIER_ALT;
|
||||
}
|
||||
if (IsShiftPressed()) {
|
||||
event.modifiers |= MODIFIER_SHIFT;
|
||||
}
|
||||
if (IsMetaPressed()) {
|
||||
event.modifiers |= MODIFIER_META;
|
||||
}
|
||||
event.modifiers = DOMModifiers();
|
||||
|
||||
if (type < 0) {
|
||||
// An event we don't know about
|
||||
@ -802,7 +787,7 @@ AndroidGeckoEvent::MakeMouseEvent(nsIWidget* widget)
|
||||
if (msg != NS_MOUSE_MOVE) {
|
||||
event.clickCount = 1;
|
||||
}
|
||||
event.modifiers = 0;
|
||||
event.modifiers = DOMModifiers();
|
||||
event.time = Time();
|
||||
|
||||
// We are dispatching this event directly into Gecko (as opposed to going
|
||||
@ -816,6 +801,37 @@ AndroidGeckoEvent::MakeMouseEvent(nsIWidget* widget)
|
||||
return event;
|
||||
}
|
||||
|
||||
Modifiers
|
||||
AndroidGeckoEvent::DOMModifiers() const
|
||||
{
|
||||
Modifiers result = 0;
|
||||
if (mMetaState & AMETA_ALT_MASK) {
|
||||
result |= MODIFIER_ALT;
|
||||
}
|
||||
if (mMetaState & AMETA_SHIFT_MASK) {
|
||||
result |= MODIFIER_SHIFT;
|
||||
}
|
||||
if (mMetaState & AMETA_CTRL_MASK) {
|
||||
result |= MODIFIER_CONTROL;
|
||||
}
|
||||
if (mMetaState & AMETA_META_MASK) {
|
||||
result |= MODIFIER_META;
|
||||
}
|
||||
if (mMetaState & AMETA_FUNCTION_ON) {
|
||||
result |= MODIFIER_FN;
|
||||
}
|
||||
if (mMetaState & AMETA_CAPS_LOCK_ON) {
|
||||
result |= MODIFIER_CAPSLOCK;
|
||||
}
|
||||
if (mMetaState & AMETA_NUM_LOCK_ON) {
|
||||
result |= MODIFIER_NUMLOCK;
|
||||
}
|
||||
if (mMetaState & AMETA_SCROLL_LOCK_ON) {
|
||||
result |= MODIFIER_SCROLLLOCK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
||||
{
|
||||
|
@ -342,12 +342,16 @@ enum {
|
||||
AKEYCODE_KANA = 218,
|
||||
AKEYCODE_ASSIST = 219,
|
||||
|
||||
AMETA_FUNCTION_ON = 0x00000008,
|
||||
AMETA_CTRL_ON = 0x00001000,
|
||||
AMETA_CTRL_LEFT_ON = 0x00002000,
|
||||
AMETA_CTRL_RIGHT_ON = 0x00004000,
|
||||
AMETA_META_ON = 0x00010000,
|
||||
AMETA_META_LEFT_ON = 0x00020000,
|
||||
AMETA_META_RIGHT_ON = 0x00040000,
|
||||
AMETA_CAPS_LOCK_ON = 0x00100000,
|
||||
AMETA_NUM_LOCK_ON = 0x00200000,
|
||||
AMETA_SCROLL_LOCK_ON = 0x00400000,
|
||||
|
||||
AMETA_ALT_MASK = AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON | AMETA_ALT_ON,
|
||||
AMETA_CTRL_MASK = AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON | AMETA_CTRL_ON,
|
||||
@ -504,6 +508,7 @@ public:
|
||||
int KeyCode() { return mKeyCode; }
|
||||
int MetaState() { return mMetaState; }
|
||||
uint32_t DomKeyLocation() { return mDomKeyLocation; }
|
||||
Modifiers DOMModifiers() const;
|
||||
bool IsAltPressed() const { return (mMetaState & AMETA_ALT_MASK) != 0; }
|
||||
bool IsShiftPressed() const { return (mMetaState & AMETA_SHIFT_MASK) != 0; }
|
||||
bool IsCtrlPressed() const { return (mMetaState & AMETA_CTRL_MASK) != 0; }
|
||||
|
@ -1263,7 +1263,7 @@ nsWindow::DispatchMotionEvent(WidgetInputEvent &event, AndroidGeckoEvent *ae,
|
||||
{
|
||||
nsIntPoint offset = WidgetToScreenOffset();
|
||||
|
||||
event.modifiers = 0;
|
||||
event.modifiers = ae->DOMModifiers();
|
||||
event.time = ae->Time();
|
||||
|
||||
// XXX possibly bound the range of event.refPoint here.
|
||||
@ -1609,16 +1609,19 @@ nsWindow::InitKeyEvent(WidgetKeyboardEvent& event, AndroidGeckoEvent& key,
|
||||
event.pluginEvent = pluginEvent;
|
||||
}
|
||||
|
||||
if (event.message != NS_KEY_PRESS ||
|
||||
!key.UnicodeChar() || !key.BaseUnicodeChar() ||
|
||||
key.UnicodeChar() == key.BaseUnicodeChar()) {
|
||||
event.modifiers = key.DOMModifiers();
|
||||
if (gMenu) {
|
||||
event.modifiers |= MODIFIER_CONTROL;
|
||||
}
|
||||
// For keypress, if the unicode char already has modifiers applied, we
|
||||
// don't specify extra modifiers. If UnicodeChar() != BaseUnicodeChar()
|
||||
// it means UnicodeChar() already has modifiers applied.
|
||||
event.InitBasicModifiers(gMenu || key.IsCtrlPressed(),
|
||||
key.IsAltPressed(),
|
||||
key.IsShiftPressed(),
|
||||
key.IsMetaPressed());
|
||||
// Note that on Android 4.x, Alt modifier isn't set when the key input
|
||||
// causes text input even while right Alt key is pressed. However, this
|
||||
// is necessary for Android 2.3 compatibility.
|
||||
if (event.message == NS_KEY_PRESS &&
|
||||
key.UnicodeChar() && key.UnicodeChar() != key.BaseUnicodeChar()) {
|
||||
event.modifiers &= ~(MODIFIER_ALT | MODIFIER_CONTROL | MODIFIER_META);
|
||||
}
|
||||
|
||||
event.mIsRepeat =
|
||||
|
Loading…
Reference in New Issue
Block a user