Difference between revisions of "Implementing the Mouse Lock API in Firefox"
(→High-Level Mouse Lock Implementation Tasks) |
(→High-Level Mouse Lock Implementation Tasks) |
||
Line 100: | Line 100: | ||
# "User agents may prompt for confirmation before locking, this preference may be saved as a content setting" How to deal with this? What UI do we use? See also, "Repeated escapes of mouse lock can signal user agent to not re-lock the mouse without more specific user intent gesture, e.g. similar to how Chrome suppresses repeated alert() calls" | # "User agents may prompt for confirmation before locking, this preference may be saved as a content setting" How to deal with this? What UI do we use? See also, "Repeated escapes of mouse lock can signal user agent to not re-lock the mouse without more specific user intent gesture, e.g. similar to how Chrome suppresses repeated alert() calls" | ||
# Tests, tests, tests. We need tests for all aspects of the spec. The central repo with all the tests are located [https://github.com/rhung/mozilla-central/tree/mouselock-tests here]. List tests we need below: | # Tests, tests, tests. We need tests for all aspects of the spec. The central repo with all the tests are located [https://github.com/rhung/mozilla-central/tree/mouselock-tests here]. List tests we need below: | ||
− | ## "there is no limit to how far movement can go...not limited by screen boundaries" -- mouse lock should mean infinite movement in the X and Y axes...There will be no limit to movementX/Y values if the mouse is continuously moved in a single direction" | + | ## "there is no limit to how far movement can go...not limited by screen boundaries" -- mouse lock should mean infinite movement in the X and Y axes...There will be no limit to movementX/Y values if the mouse is continuously moved in a single direction" - '''hchun''' |
+ | ## "The concept of the mouse cursor will have been removed, and it will not move off the window or be clamped by a screen edge" - '''hchun''' | ||
## "no mouse cursor is displayed" -- mouse cursor should be hidden while locked - '''dvillase''' | ## "no mouse cursor is displayed" -- mouse cursor should be hidden while locked - '''dvillase''' | ||
## navigator.pointer (readonly) is a MouseLockable - <strong>abhatnagar</strong> | ## navigator.pointer (readonly) is a MouseLockable - <strong>abhatnagar</strong> | ||
Line 107: | Line 108: | ||
## lock(target) expects a DOM element, and takes two optional callbacks: successcallback, failurecallback. - <strong>JSilver999</strong> | ## lock(target) expects a DOM element, and takes two optional callbacks: successcallback, failurecallback. - <strong>JSilver999</strong> | ||
## lock() should return immediately and call callbacks when lock succeeds or fails - <strong>JSilver999</strong> | ## lock() should return immediately and call callbacks when lock succeeds or fails - <strong>JSilver999</strong> | ||
− | ## "Mouse lock must succeed only if the window is in focus" - | + | ## "Mouse lock must succeed only if the window is in focus" - '''johnno''' |
− | ## "Mouse lock must succeed only if...the user-agent is the active application of the operating system" | + | ## "Mouse lock must succeed only if...the user-agent is the active application of the operating system" - '''johnno''' |
− | ## "The target of lock need not be in focus" | + | ## "The target of lock need not be in focus" - '''johnno''' |
− | ## "Mouse lock must succeed only if the target is in the DOM tree" | + | ## "Mouse lock must succeed only if the target is in the DOM tree" - '''steven''' |
− | ## "If the target is removed from the DOM tree after mouse lock is entered then mouse lock will be lost." | + | ## "If the target is removed from the DOM tree after mouse lock is entered then mouse lock will be lost." - '''steven''' |
− | ## "If the mouse is already locked to the same element, a repeated call to lock will succeed and the successCallback called" | + | ## "If the mouse is already locked to the same element, a repeated call to lock will succeed and the successCallback called" - '''jboelen''' |
− | ## "If another element is locked [and lock() is called] a user agent must transfer the mouse lock to the new target and call the mouselocklost callback for the previous target" | + | ## "If another element is locked [and lock() is called] a user agent must transfer the mouse lock to the new target and call the mouselocklost callback for the previous target" - '''jboelen''' |
− | ## "The Mouse Lock API must provide a default system action to unlock the mouse" namely ESC. | + | ## "The Mouse Lock API must provide a default system action to unlock the mouse" namely ESC. - '''CloudScorpian''' |
− | ## "Once in the locked state the user agent must fire all relevant user generated MouseEvent events (for example: mousemove, mousedown, mouseup, click, wheel)[DOM-LEVEL-3-CORE] to the target of mouse lock, and not fire mouse events to other elements" | + | ## "Once in the locked state the user agent must fire all relevant user generated MouseEvent events (for example: mousemove, mousedown, mouseup, click, wheel)[DOM-LEVEL-3-CORE] to the target of mouse lock, and not fire mouse events to other elements" - '''rhung''' |
− | ## "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)" - rhung | + | ## "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)" - '''rhung''' |
− | ## "Movement and button presses of the mouse must not cause the window to lose focus" | + | ## "Movement and button presses of the mouse must not cause the window to lose focus" - '''asahota''' |
− | ## "Synthetic mouse events created by application script act the same regardless of lock state" | + | ## "Synthetic mouse events created by application script act the same regardless of lock state" - '''Tentacle''' |
− | ## "The unlock method cancels the mouse lock state" - | + | ## "The unlock method cancels the mouse lock state" - '''abhatnagar''' |
− | ## "[Upon unlock() t]he system mouse cursor must be displayed again and positioned at the same location that it was when mouse lock was entered (the same location that is reported in screenX/Y when the mouse is locked)" | + | ## "[Upon unlock() t]he system mouse cursor must be displayed again and positioned at the same location that it was when mouse lock was entered (the same location that is reported in screenX/Y when the mouse is locked)" - '''dvillase''' |
− | ## "When mouse lock is lost or disabled for any reason user agents must fire an event named mouselocklost with its bubble attribute set to true to the mouse lock target element" | + | ## "When mouse lock is lost or disabled for any reason user agents must fire an event named mouselocklost with its bubble attribute set to true to the mouse lock target element" - '''stsang''' |
− | ## MouseEvent must contain (readonly) movementX and movementY - | + | ## MouseEvent must contain (readonly) movementX and movementY - '''KeyR''' |
− | ## "The members movementX and movementY must provide the change in position of the mouse, as if the values of screenX/Y were stored between two subsequent mousemove events eNow and ePrevious and the difference taken movementX = eNow.screenX-ePrevious.screenX" | + | ## "The members movementX and movementY must provide the change in position of the mouse, as if the values of screenX/Y were stored between two subsequent mousemove events eNow and ePrevious and the difference taken movementX = eNow.screenX-ePrevious.screenX" - '''KeyR''' |
− | ## "movementX/Y must be valid regardless of mouse lock state" | + | ## "movementX/Y must be valid regardless of mouse lock state" - '''KeyR''' |
− | ## "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero" | + | ## "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero" - '''mousse1''' |
− | ## "When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered" | + | ## "When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered" - '''Jordan''' |
− | ## "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus" | + | ## "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus" - '''drigato''' |
− | |||
## Test to make sure that mouse lock only occurs when an element is in full screen mode (not F11 or done via the menus). This includes: | ## Test to make sure that mouse lock only occurs when an element is in full screen mode (not F11 or done via the menus). This includes: | ||
− | ### Switching focus to another window | + | ### Switching focus to another window - '''''' |
− | ## Tests for mouselocklost event | + | ## Tests for mouselocklost event - '''Roman''' |
# Create a tutorial on how to use Mouse Lock, with code examples | # Create a tutorial on how to use Mouse Lock, with code examples | ||
# Add demo pages to [http://humphd.github.com/mozilla-central/mouselock/index.html gh-pages branch] | # Add demo pages to [http://humphd.github.com/mozilla-central/mouselock/index.html gh-pages branch] |
Revision as of 13:04, 29 November 2011
Contents
Introduction
This is a working document for the implementation of the Mouse Lock API spec in Mozilla by students in David Humphrey's Mozilla Development class at Seneca College.
Please add, edit, correct, expand, etc. as necessary. This page should contain any links or other info we need.
Participants
While the project is primarily meant for students in DPS909/OSD600, feel free to join us if you want to work on things.
- David Humphrey (lead developer, professor, @humphd)
- Hasan Kamal-Al-Deen (tardy student, @NorthWind87)
- Matthew Schranz (Student, OSD600, @mjschranz)
- Yevgeniy Ivanchenko (Student, OSD600)
- Chris Gosselin (Student, OSD600)
- Anurag Bhatnagar (Student, DPS909, @anuragbh)
- Raymond Hung (Wannabe Developer, Student, @Raymond_Hung)
- Ausley Johnson(Student, OSD600)
- Jesse Silver (Student, OSD600)
- Ching Wei Tseng(Student, DPS909)
- Michelle Mendoza (Student, DPS909)
- Archana Sahota (Student, DPS909)
- Greg Krilov (Student, DPS909)
- Roman Hotin (Student, DPS909)
- Sergiu Ecob (Student, OSD600)
- Jordan Raffoul (Student)
- Hyungryul Chun (Student, DPS909)
- James Boelen (Masked Crusader, @jamesboelen)
- Jacky Siu (Student, OSD600)
- Abhishek Bhatnagar (Student, @abhishekToronto)
- Diogo Golovanevsky Monteiro (@diogogmt)
- Simon de Almeida(Student) (@simon661)
- Stanley Tsang (Student, DPS909)
- Denise Rigato (Student, DPS909)
- Qian (Ken) Xu (Student, DPS909)
- Moussa Tabcharani (Student, DPS909)
- Keyan Ren (Student, OSD600)
- Joseph Hughes (Student, OSD600)
Communication
Development work will be done using a combination of the following:
- In class discussions: 11:40-1:30 Tuesday and Thursday in TEL T2110
- IRC discussions: #seneca, #paladin
- Questions: ask and answer any questions here: Mouse Lock Implementation FAQ
- Blog Series: http://vocamus.net/dave/?cat=28
Tasks
Getting Started
- Clone our repo and build a debug version locally
- Get a https://bugzilla.mozilla.org account and CC yourself on the bug.
- Set a Watch on this page and the Q/A page so you know when things change.
- Break the spec down into an itemized list of things we need to do, tests we need to write, features we have to add, edge cases we have to worry about, demos we need to build, etc. Put the info into this page. We need to know everything we'll have to write and schedule when we'll do each bit.
- Blog about your work on this implementation
- Add questions/answers to Mouse Lock Implementation FAQ
High-Level Mouse Lock Implementation Tasks
This list is incomplete, and needs more detail added as the following bits are completed.
-
No mouse cursor is displayed when the mouse is locked- rhung -
MouseLockable DOM Implementation, navigator.pointer (Notes on MouseLock DOM Implementation Nov 13, 2011)- humph-
void lock (in Element target, optional in VoidCallback successCallback, optional in VoidCallback failureCallback);diogogmt, humph - void unlock ();
- Needs to reset the mouse position back to the original position
- bool islocked (); - humph
-
-
Mouse Lock Platform ImplementationsJSilver999, humph-
Windows: SetCursorPos(x, y) -
OS X CGWarpMouseCursorPosition(CGPointMake(x, y)) -
Linux (GTK) gdk_display_warp_pointer (display, screen, x, y), add to http://mxr.mozilla.org/mozilla-central/source/widget/src/gtk2/nsWindow.cpp ??? - Mobile?
-
- Investigate whether we can get movement information directly from OS - northWind
-
mouselocklost event DOM Implementation- diogogmt -
Extend MouseEvent DOM implementation with movementX, movementY- humph, JSilver999 -
The browser must exit the mouse lock state if the user agent, window, or tab loses focus- diogogmt -
Fixup NULLs being returned from lock() C++ implementation, should be NS*- Anachid - The ESC key should exit mouse lock - diogogmt
- Mouse lock should only work when in Full Screen Mode - diogogmt, rhung
- Suppress non-user generated events in mouse lock mode - rhung
-
Refactor nsIDOMNavigator changes for pointer attribute to be in separate interfacehumph - Do we need to add a user pref to enable/disable mouse lock?
- Do we need to do conditional compilation for mouse lock?
- When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered.
-
Freeze mouse pointer in centre of window when mouse lock is enabled (e.g., moving the mouse causes an event, but forces the mouse to go back to the original position).- JSilver999 - Proper IDL documentation for navigator.pointer (see example in https://mxr.mozilla.org/mozilla-central/source/dom/interfaces/html/nsIDOMHTMLElement.idl#103), MouseLockable and its methods, MouseLockLost event, etc.
- Write a JavaScript library to somehow combine element.mozRequestFullScreen() and navigator.pointer.lock(). It would be good to hide the complexities of doing fullscreen then locking in a single API call. - nm486
- Mouse lock specification fix requests
- Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
-
Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock- JSilver999 - "Once mouse lock is acquired, stop mouse events from being fired to other elements that are not locked (e.g., only fire to locked element)."
- "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus"
- "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)"
- "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero"
- "User agents may prompt for confirmation before locking, this preference may be saved as a content setting" How to deal with this? What UI do we use? See also, "Repeated escapes of mouse lock can signal user agent to not re-lock the mouse without more specific user intent gesture, e.g. similar to how Chrome suppresses repeated alert() calls"
- Tests, tests, tests. We need tests for all aspects of the spec. The central repo with all the tests are located here. List tests we need below:
- "there is no limit to how far movement can go...not limited by screen boundaries" -- mouse lock should mean infinite movement in the X and Y axes...There will be no limit to movementX/Y values if the mouse is continuously moved in a single direction" - hchun
- "The concept of the mouse cursor will have been removed, and it will not move off the window or be clamped by a screen edge" - hchun
- "no mouse cursor is displayed" -- mouse cursor should be hidden while locked - dvillase
- navigator.pointer (readonly) is a MouseLockable - abhatnagar
- MouseLockable has lock(), unlock(), islocked() - abhatnagar
- islocked() returns true if mouse is locked, false if not locked - JSilver999
- lock(target) expects a DOM element, and takes two optional callbacks: successcallback, failurecallback. - JSilver999
- lock() should return immediately and call callbacks when lock succeeds or fails - JSilver999
- "Mouse lock must succeed only if the window is in focus" - johnno
- "Mouse lock must succeed only if...the user-agent is the active application of the operating system" - johnno
- "The target of lock need not be in focus" - johnno
- "Mouse lock must succeed only if the target is in the DOM tree" - steven
- "If the target is removed from the DOM tree after mouse lock is entered then mouse lock will be lost." - steven
- "If the mouse is already locked to the same element, a repeated call to lock will succeed and the successCallback called" - jboelen
- "If another element is locked [and lock() is called] a user agent must transfer the mouse lock to the new target and call the mouselocklost callback for the previous target" - jboelen
- "The Mouse Lock API must provide a default system action to unlock the mouse" namely ESC. - CloudScorpian
- "Once in the locked state the user agent must fire all relevant user generated MouseEvent events (for example: mousemove, mousedown, mouseup, click, wheel)[DOM-LEVEL-3-CORE] to the target of mouse lock, and not fire mouse events to other elements" - rhung
- "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)" - rhung
- "Movement and button presses of the mouse must not cause the window to lose focus" - asahota
- "Synthetic mouse events created by application script act the same regardless of lock state" - Tentacle
- "The unlock method cancels the mouse lock state" - abhatnagar
- "[Upon unlock() t]he system mouse cursor must be displayed again and positioned at the same location that it was when mouse lock was entered (the same location that is reported in screenX/Y when the mouse is locked)" - dvillase
- "When mouse lock is lost or disabled for any reason user agents must fire an event named mouselocklost with its bubble attribute set to true to the mouse lock target element" - stsang
- MouseEvent must contain (readonly) movementX and movementY - KeyR
- "The members movementX and movementY must provide the change in position of the mouse, as if the values of screenX/Y were stored between two subsequent mousemove events eNow and ePrevious and the difference taken movementX = eNow.screenX-ePrevious.screenX" - KeyR
- "movementX/Y must be valid regardless of mouse lock state" - KeyR
- "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero" - mousse1
- "When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered" - Jordan
- "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus" - drigato
- Test to make sure that mouse lock only occurs when an element is in full screen mode (not F11 or done via the menus). This includes:
- Switching focus to another window - '
- Tests for mouselocklost event - Roman
- Create a tutorial on how to use Mouse Lock, with code examples
- Add demo pages to gh-pages branch
- User agents may prompt for confirmation before locking, this preference may be saved as a content setting (Mentioned in class by humphd, setting would be in about:config ) mjschranz
-
Figure out Mac Crash with Jesse's SynthesizeMouseMove changehumph
Resources
- Spec Document: http://dvcs.w3.org/hg/webevents/raw-file/default/mouse-lock.html
- Implementation Repo: https://github.com/humphd/mozilla-central on the mouselock branch.
- Mozilla Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=633602
- WebKit Bug: https://bugs.webkit.org/show_bug.cgi?id=68468
- Chromium Bug: http://code.google.com/p/chromium/issues/detail?id=72754
- Points of Interest: http://zenit.senecac.on.ca/wiki/index.php/Mouse_Lock_API_Points_of_Interest
- Mochitest: https://developer.mozilla.org/en/Mochitest
- Mozilla Cross Reference: http://mxr.mozilla.org/mozilla-central/