W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Mouse Lock

From: Klaas Heidstra <klaas1988@gmail.com>
Date: Wed, 24 Aug 2011 04:28:18 +0200
Message-ID: <CAHtyvgaQMRessKOczsi3=tVK=VRxjUoZNx0kqB9dUOVS-KcEbw@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: Vincent Scheib <scheib@google.com>, "Tab Atkins Jr." <jackalmage@gmail.com>, Jonas Sicking <jonas@sicking.cc>, robert@ocallahan.org, Brandon Andrews <warcraftthreeft@sbcglobal.net>, Olli@pettay.fi, Ryosuke Niwa <rniwa@webkit.org>, Adam Barth <w3c@adambarth.com>, "Gregg Tavares (wrk)" <gman@google.com>, Charles Pritchard <chuck@jumis.com>, Kenneth Russell <kbr@google.com>, public-webapps@w3.org
I agree with you that the deltas should be in a separate event. That would
also be the most logical because moving the cursor(corresponding to a
"mousemove" event) and physically moving your mouse are separate things. If
"mousemove" wasn't already used for cursor movement("mousemove" imo should
have been called "cursormove"or "pointermove"), that would be the most
appropriate name for this new mouse delta event. Unfortunately that isn't
the case so a different name has to be chosen. Maybe:
"mousepositionchanged"? This event should have the same security
restrictions as "mousemove".

Constraining the cursor to an element could work almost the same as the
proposed lockMouse method. The only difference is that the cursor isn't
locked to the center, but limited to the bounds of some element so you get
something like this:

x = document.getElementById("some_element");

x.clipCursor(

function() {

    x.freeCursor();

couldLock = true;

}

);

ClipCursor is the name Windows is using for this, but is could also be
called something like "wallCursor".

2011/8/13 Glenn Maynard <glenn@zewt.org>

> On Fri, Aug 12, 2011 at 7:50 PM, Vincent Scheib <scheib@google.com> wrote:
>
>> BTW, draft spec currently states, "When mouse lock is enabled clientX,
>> clientY, screenX, and screenY must hold constant values as if the mouse were
>> located at the center of the mouse lock target element...". I chose this to
>> pick something concrete, but not all zeros which may be used as magic values
>> in JS code, etc. I'm not strong in this opinion.
>
>
> Some things that come to mind:
>
> - Delta movement may be received separately from cursor movement.  For
> example, an implementation may use WM_MOUSEMOVE to generate mousemove
> events, and WM_INPUT to generate mouse delta events, as Klaas pointed out.
> These window messages aren't defined relative to each other; a WM_INPUT
> event may or may not be followed by a WM_MOUSEMOVE event.  A mouse may
> generate WM_INPUT events at 1kHz, but WM_MOUSEMOVE events may only be
> generated at 60 or 120Hz.
>
> This means that you'd either end up generating far more mousemove events,
> eg. three events with delta information followed by a single event with
> cursor information (possibly placing unwanted stress on unrelated mousemove
> event handlers--this is a particular problem with Klaas's model, see below);
> or discarding information, which also seems undesirable.  Using a separate
> event avoids this issue.
>
>
> - The deltas may not be comparable to corresponding cursor movement.  For
> example, mouse cursors often have acceleration and snap-to-axis filters
> applied.  I think these filters aren't applied to the data received by
> WM_INPUT.  Is this a good thing or not?
>
> It's probably a good thing for an FPS, to avoid snap-to-axis cursor filters
> from affecting the viewport.
>
> It's probably a bad thing for dragging Google Maps around.  Having the map
> drag at a different rate than the cursor normally moves may be strange.
> (Using deltas for dragging is useful: you can continually drag the map,
> without having to reposition the mouse cursor every time you reach the edge
> of the screen.)
>
>
> - If mousemove events when locked put clientX, etc. at some arbitrary
> position, are mouseover events generated, as if the cursor had actually
> moved there?  If deltas do end up packed into mousemove events, I'd suggest
> that these properties not change while locked: continue reporting the
> last-generated position, as if the unseen cursor is stationary while
> locked.  When the mouse is unlocked, the cursor is back where it was
> originally; no mouseover events are generated at all, as the cursor
> (distinct from the mouse) never moved.
>
>
> - Klaas suggests an entirely different approach.  Instead of having a
> separate delta mode, mouse deltas would always be available.  "Mouse lock"
> would be achieved by locking the mouse within a rectangle (a separate
> feature entirely from mouse deltas), and hiding the cursor with CSS.
> There's some appeal to having delta information always available, without
> forcing the cursor to be hidden and locked to use them.  It makes the
> dragging (Google Maps) use case simpler: no actual locking is needed, as you
> don't care if the mouse cursor stays within the window--so this use case
> wouldn't be burdened by any security mechanisms required by locking. The
> first two points above still apply here; using a separate mousedelta event
> would still make sense in this model.
>
> --
> Glenn Maynard
>
>
Received on Wednesday, 24 August 2011 02:28:55 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:47 GMT