Closed Bug 795832 Opened 13 years ago Closed 12 years ago

Implement synthesized input events in metro widget

Categories

(Core :: Widget: Win32, defect)

x86_64
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jimm, Assigned: TimAbraldes)

Details

(Whiteboard: [metro-mvp][completed-elm][leave open])

Attachments

(3 files, 3 obsolete files)

Assignee: nobody → tabraldes
How goes this work Tim?
Whiteboard: metro-mvp
Attached patch Patch (obsolete) — Splinter Review
This patch implements synthesized mouse, keyboard, and scroll events. I've tested this patch by modifying browser.js to call `nsIDOMWindowUtils.sendNativeMouseEvent`, `nsIDOMWindowUtils.sendNativeKeyEvent`, and `nsIDOMWindowUtils.sendNativeMouseScrollEvent`. Those functions in turn call the ones implemented in this patch.
Attachment #677477 - Flags: review?(jmathies)
Comment on attachment 677477 [details] [diff] [review] Patch Review of attachment 677477 [details] [diff] [review]: ----------------------------------------------------------------- ::: widget/windows/winrt/MetroWidget.cpp @@ +376,5 @@ > +{ > + Log(L"ENTERED SynthesizeNativeKeyEvent\n"); > + > + // Source: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271%28v=vs.85%29.aspx > + NS_ENSURE_ARG_RANGE(aNativeKeyCode, 1, 254); nit - add a comment explaining these constants rather than a link (or have both). @@ +539,5 @@ > + // inputs[len-1]: modifier key (e.g. shift, ctrl, etc) up > + uint32_t const len = keySequence.Length() * 2 + 1; > + INPUT* inputs = new INPUT[len]; > + memset(inputs, 0, len * sizeof(INPUT)); > + for (uint32_t i = 0; i < keySequence.Length(); ++i) { You seem to be reusing this block of code in each call, can we split this out into a utility function along with it's comment block? @@ +559,5 @@ > + // processed by the time we leave this function, so we have to manually > + // pump them here. > + Log(L" Waiting for input messages to clear\n"); > + MSG msg; > + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE | PM_QS_INPUT)) { ditto with this block. I'm a little concerned about using this since we won't be going through the winrt dispatcher, but I think we can leave it be and address later if any problems crop up.
Attachment #677477 - Flags: review?(jmathies) → review+
Attached patch patch (obsolete) — Splinter Review
(In reply to Jim Mathies [:jimm] from comment #3) > Comment on attachment 677477 [details] [diff] [review] > Patch > > Review of attachment 677477 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: widget/windows/winrt/MetroWidget.cpp > @@ +376,5 @@ > > +{ > > + Log(L"ENTERED SynthesizeNativeKeyEvent\n"); > > + > > + // Source: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271%28v=vs.85%29.aspx > > + NS_ENSURE_ARG_RANGE(aNativeKeyCode, 1, 254); > > nit - add a comment explaining these constants rather than a link (or have > both). Added a comment. > @@ +539,5 @@ > > + // inputs[len-1]: modifier key (e.g. shift, ctrl, etc) up > > + uint32_t const len = keySequence.Length() * 2 + 1; > > + INPUT* inputs = new INPUT[len]; > > + memset(inputs, 0, len * sizeof(INPUT)); > > + for (uint32_t i = 0; i < keySequence.Length(); ++i) { > > You seem to be reusing this block of code in each call, can we split this > out into a utility function along with it's comment block? Pulled this out into a separate function. > @@ +559,5 @@ > > + // processed by the time we leave this function, so we have to manually > > + // pump them here. > > + Log(L" Waiting for input messages to clear\n"); > > + MSG msg; > > + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE | PM_QS_INPUT)) { > > ditto with this block. Pulled this out into the new function. > I'm a little concerned about using this since we won't be going through the > winrt dispatcher, but I think we can leave it be and address later if any > problems crop up. Agreed; let's see if any problems come up once we start using this functionality in our tests.
Attachment #677477 - Attachment is obsolete: true
Attachment #678444 - Flags: review+
This is the patch that I used during testing. At various points I had it use additional synthesized input events (right-click to bring up the url bar, left click to click in the url bar, etc). An issue I've discovered is that synthesizing "ctrl+f" and "ctrl+l" do not have their intended effects. The keys are definitely being pressed, but for a reason I haven't yet been able to track down, synthesizing "ctrl+l" does not cause focus to be set in the URL bar, and synthesizing "ctrl+f" does not cause "find in page" to appear. Everything else I've tested does work: Synthesizing right-clicks to make the context menu and tab bar appear Synthesizing left clicks in the URL bar to focus it Synthesizing key presses, including capital letters by passing `nsIWidget::SHIFT_L` and `nsIWidget::SHIFT_R` as flags Closing the browser by synthesizing "alt+f4" Scrolling a page with synthesized scroll events
Attached patch patchSplinter Review
I updated the patch to remove the use of `::SetCursor` and instead move the mouse to the desired location with additional inputs to `::SendInput`. Also updated some logging.
Attachment #678444 - Attachment is obsolete: true
Attachment #678514 - Flags: review+
Status: NEW → ASSIGNED
Whiteboard: metro-mvp → [metro-mvp][completed-elm]
Lets get the nsWindowDefs.h change over on mc. The top level widget changes have merged so this shows up in an mc-elm diff.
Attached patch nsWindowDefs.h patch for m-c (obsolete) — Splinter Review
I'm building this locally as a sanity check, and requesting review so that it lands with an r+ :)
Attachment #680690 - Flags: review?(jmathies)
Updating patch - a misc other change crept into the previous version
Attachment #680690 - Attachment is obsolete: true
Attachment #680690 - Flags: review?(jmathies)
Attachment #680691 - Flags: review?(jmathies)
Comment on attachment 680691 [details] [diff] [review] nsWindowDefs.h patch for m-c Looks ok to me.
Attachment #680691 - Flags: review?(jmathies) → review+
Whiteboard: [metro-mvp][completed-elm] → [metro-mvp][completed-elm][leave open]
Marking my [completed-elm] bugs as resolved
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
OS: Windows 8 Metro → Windows 8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: