mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 957490 - Fix initialization of MouseEvent.buttons on Metro [r=jimm]
This commit is contained in:
parent
da33efdbfa
commit
e3aa02f5f6
51
browser/metro/base/tests/mochitest/browser_mouse_events.js
Normal file
51
browser/metro/base/tests/mochitest/browser_mouse_events.js
Normal file
@ -0,0 +1,51 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// from MouseEvents.h
|
||||
const leftButtonFlag = 1;
|
||||
const rightButtonFlag = 2;
|
||||
|
||||
gTests.push({
|
||||
desc: "Test native mouse events",
|
||||
run: function () {
|
||||
let tab = yield addTab("about:mozilla");
|
||||
|
||||
// Mousemove.
|
||||
let waitForMove = waitForEvent(document, "mousemove");
|
||||
synthesizeNativeMouseMove(tab.browser, 1, 1);
|
||||
synthesizeNativeMouseMove(tab.browser, 100, 100);
|
||||
let mousemove = yield waitForMove;
|
||||
is(mousemove.cancelable, false, "mousemove is not cancelable");
|
||||
is(mousemove.buttons, 0, "no buttons are down");
|
||||
|
||||
// Left button down.
|
||||
let waitForDown1 = waitForEvent(document, "mousedown");
|
||||
synthesizeNativeMouseLDown(tab.browser, 100, 100);
|
||||
let mousedown1 = yield waitForDown1;
|
||||
is(mousedown1.cancelable, true, "mousedown is cancelable");
|
||||
is(mousedown1.buttons, leftButtonFlag, "left button is down");
|
||||
|
||||
// Right button down.
|
||||
let waitForDown2 = waitForEvent(document, "mousedown");
|
||||
synthesizeNativeMouseRDown(tab.browser, 100, 100);
|
||||
let mousedown2 = yield waitForDown2;
|
||||
is(mousedown2.buttons, leftButtonFlag | rightButtonFlag, "both buttons are down");
|
||||
|
||||
// Left button up.
|
||||
let waitForUp1 = waitForEvent(document, "mouseup");
|
||||
synthesizeNativeMouseLUp(tab.browser, 100, 100);
|
||||
let mouseup1 = yield waitForUp1;
|
||||
is(mouseup1.buttons, rightButtonFlag, "right button is down");
|
||||
|
||||
// Right button up.
|
||||
let waitForUp2 = waitForEvent(document, "mouseup");
|
||||
synthesizeNativeMouseRUp(tab.browser, 100, 100);
|
||||
let mouseup2 = yield waitForUp2;
|
||||
is(mouseup2.buttons, 0, "no buttons are down");
|
||||
|
||||
Browser.closeTab(tab, { forceClose: true });
|
||||
}
|
||||
});
|
||||
|
||||
let test = runTests;
|
@ -32,6 +32,7 @@ support-files =
|
||||
res/blankpage2.html
|
||||
res/blankpage3.html
|
||||
|
||||
[browser_apzc_basic.js]
|
||||
[browser_bookmarks.js]
|
||||
[browser_canonizeURL.js]
|
||||
[browser_circular_progress_indicator.js]
|
||||
@ -45,6 +46,8 @@ support-files =
|
||||
[browser_history.js]
|
||||
[browser_inputsource.js]
|
||||
[browser_link_click.js]
|
||||
[browser_menu_hoverstate.js]
|
||||
[browser_mouse_events.js]
|
||||
[browser_onscreen_keyboard.js]
|
||||
[browser_prefs_ui.js]
|
||||
[browser_prompt.js]
|
||||
@ -58,8 +61,6 @@ support-files =
|
||||
[browser_urlbar.js]
|
||||
[browser_urlbar_highlightURLs.js]
|
||||
[browser_urlbar_trimURLs.js]
|
||||
[browser_apzc_basic.js]
|
||||
[browser_menu_hoverstate.js]
|
||||
|
||||
# These tests have known failures in debug builds
|
||||
[browser_selection_basic.js]
|
||||
|
@ -200,6 +200,11 @@ ModifierKeyState::InitMouseEvent(WidgetInputEvent& aMouseEvent) const
|
||||
aMouseEvent.eventStructType == NS_SIMPLE_GESTURE_EVENT,
|
||||
"called with non-mouse event");
|
||||
|
||||
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
|
||||
// Buttons for immersive mode are handled in MetroInput.
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetMouseEventBase& mouseEvent = *aMouseEvent.AsMouseEventBase();
|
||||
mouseEvent.buttons = 0;
|
||||
if (::GetKeyState(VK_LBUTTON) < 0) {
|
||||
|
@ -160,6 +160,37 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
int16_t
|
||||
ButtonsForPointerPoint(UI::Input::IPointerPoint* aPoint) {
|
||||
WRL::ComPtr<UI::Input::IPointerPointProperties> props;
|
||||
aPoint->get_Properties(props.GetAddressOf());
|
||||
|
||||
int16_t buttons = 0;
|
||||
boolean buttonPressed;
|
||||
|
||||
props->get_IsLeftButtonPressed(&buttonPressed);
|
||||
if (buttonPressed) {
|
||||
buttons |= WidgetMouseEvent::eLeftButtonFlag;
|
||||
}
|
||||
props->get_IsMiddleButtonPressed(&buttonPressed);
|
||||
if (buttonPressed) {
|
||||
buttons |= WidgetMouseEvent::eMiddleButtonFlag;
|
||||
}
|
||||
props->get_IsRightButtonPressed(&buttonPressed);
|
||||
if (buttonPressed) {
|
||||
buttons |= WidgetMouseEvent::eRightButtonFlag;
|
||||
}
|
||||
props->get_IsXButton1Pressed(&buttonPressed);
|
||||
if (buttonPressed) {
|
||||
buttons |= WidgetMouseEvent::e4thButtonFlag;
|
||||
}
|
||||
props->get_IsXButton2Pressed(&buttonPressed);
|
||||
if (buttonPressed) {
|
||||
buttons |= WidgetMouseEvent::e5thButtonFlag;
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for use with mTouches.Enumerate. It will
|
||||
* append each element it encounters to the {@link nsTArray}
|
||||
@ -749,6 +780,7 @@ MetroInput::InitGeckoMouseEventFromPointerPoint(
|
||||
aEvent->clickCount = 2;
|
||||
}
|
||||
aEvent->pressure = pressure;
|
||||
aEvent->buttons = ButtonsForPointerPoint(aPointerPoint);
|
||||
|
||||
MozInputSourceFromDeviceType(deviceType, aEvent->inputSource);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user