Closed Bug 957490 Opened 10 years ago Closed 10 years ago

MouseEvent.buttons property has incorrect value in WinRT/Metro

Categories

(Core Graveyard :: Widget: WinRT, defect)

All
Windows 8.1
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla29

People

(Reporter: mbrubeck, Assigned: mbrubeck)

References

Details

Attachments

(3 files, 1 obsolete file)

Attached file test case
The "buttons" property of the "mousedown" event is not initialized correctly in Metro Firefox.  You can see this in the attached test case.  When you press a mouse button, it should display 1 for the left mouse button, 2 for the right button, 4 for the middle button, or a sum if you press multiple buttons.  But on Metro it always displays zero, or only the previous button(s) if you press multiple buttons.
Attached patch patch (obsolete) — Splinter Review
ModifierKeyState::InitMouseEvent is supposed to set the "buttons" property, but it uses ::GetKeyState which does not seem to be return up-to-date data in immersive mode.  With this patch we call equivalent WinRT APIs instead when running in Metro mode.
Assignee: nobody → mbrubeck
Status: NEW → ASSIGNED
Attachment #8356978 - Flags: review?(jmathies)
Comment on attachment 8356978 [details] [diff] [review]
patch

>+    props->get_IsRightButtonPressed(&buttonPressed);
>+    if (buttonPressed)
>+      buttons |= WidgetMouseEvent::eRightButtonFlag;
>+
>+    props->get_IsRightButtonPressed(&buttonPressed);
>+    if (buttonPressed)
>+      buttons |= WidgetMouseEvent::eRightButtonFlag;

Duplicated the code for right button :-)

And you should use {} for even if the content of a block is only one line.
https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style#Control_Structures
Attached patch patch v2Splinter Review
Fixed the problems pointed out by Masayuki above.  Thanks!
Attachment #8356978 - Attachment is obsolete: true
Attachment #8356978 - Flags: review?(jmathies)
Attachment #8357006 - Flags: review?(jmathies)
Attachment #8357006 - Flags: review?(jmathies) → review+
Attached patch automated testSplinter Review
This is a simple mochitest for this bug plus bug 945438.
Attachment #8357308 - Flags: review?(jmathies)
Comment on attachment 8357308 [details] [diff] [review]
automated test

Review of attachment 8357308 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/metro/base/tests/mochitest/browser_mouse_events.js
@@ +6,5 @@
> +const leftButtonFlag = 1;
> +const rightButtonFlag = 2;
> +
> +gTests.push({
> +  desc: "native long tap works",

Oops, copy/paste leftovers.  Updated the description locally.
Attachment #8357308 - Flags: review?(jmathies) → review+
Folded the two patches together and landed on fx-team:
https://hg.mozilla.org/integration/fx-team/rev/d3ab07b86509
Flags: in-testsuite+
Depends on: 945438
https://hg.mozilla.org/mozilla-central/rev/d3ab07b86509
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: