Difference between revisions of "Implementing the Mouse Lock API in Firefox"

From CDOT Wiki
Jump to: navigation, search
(High-Level Mouse Lock Implementation Tasks)
(High-Level Mouse Lock Implementation Tasks)
Line 64: Line 64:
  
 
# No mouse cursor is displayed when the mouse is locked
 
# No mouse cursor is displayed when the mouse is locked
 +
## Completed
 
# MouseLockable DOM Implementation, navigator.pointer ([[Notes on MouseLock DOM Implementation Nov 13, 2011]])
 
# MouseLockable DOM Implementation, navigator.pointer ([[Notes on MouseLock DOM Implementation Nov 13, 2011]])
 
## [[void lock (in Element target, optional in VoidCallback successCallback, optional in VoidCallback failureCallback);]]
 
## [[void lock (in Element target, optional in VoidCallback successCallback, optional in VoidCallback failureCallback);]]
 +
### Callback implementation
 
## void unlock ();
 
## void unlock ();
 +
### Needs to reset the mouse position back to the original position
 
## bool islocked ();
 
## bool islocked ();
 +
### Completed
 
# Mouse Lock Platform Implementations
 
# Mouse Lock Platform Implementations
 
## Windows: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms648394%28v=vs.85%29.aspx SetCursorPos(x, y)]
 
## Windows: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms648394%28v=vs.85%29.aspx SetCursorPos(x, y)]
Line 74: Line 78:
 
## Mobile?
 
## Mobile?
 
# mouselocklost event DOM Implementation
 
# mouselocklost event DOM Implementation
 +
## Completed
 
# Extend MouseEvent DOM implementation with movementX, movementY
 
# Extend MouseEvent DOM implementation with movementX, movementY
 
## [[Stack Trace for nsDOMMouseEvent::nsDOMMouseEvent ctor]] (created on mouse move)
 
## [[Stack Trace for nsDOMMouseEvent::nsDOMMouseEvent ctor]] (created on mouse move)
 
## [[Stack Trace for nsDOMMouseEvent::GetScreenX]]
 
## [[Stack Trace for nsDOMMouseEvent::GetScreenX]]
 
## [[Where to store the state info (e.g., previous position) between mouse events?]]
 
## [[Where to store the state info (e.g., previous position) between mouse events?]]
 +
## Completed
 
# The browser must exit the mouse lock state if the user agent, window, or tab loses focus
 
# The browser must exit the mouse lock state if the user agent, window, or tab loses focus
 +
## Completed - Full screen is lost during the above action, losing full screen automatically triggers the mouselock's unlock()
 
# The ESC key should exit mouse lock
 
# The ESC key should exit mouse lock
 +
## Completed - Same as above
 
# Mouse lock should only work when in Full Screen Mode
 
# Mouse lock should only work when in Full Screen Mode
 +
## Completed
 
# [[Refactor nsIDOMNavigator changes for pointer attribute to be in separate interface]]
 
# [[Refactor nsIDOMNavigator changes for pointer attribute to be in separate interface]]
 
# Do we need to add a user pref to enable/disable mouse lock?
 
# Do we need to add a user pref to enable/disable mouse lock?
 
# Do we need to do conditional compilation for 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.
 
# 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.
 +
## Needs work - Feel free to work on this one!
 
# 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).
 
# 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).
 +
## Almost complete - Awaiting patch
 
# 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.
 
# 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.
 +
## Needs work - Feel free to work on this one!
 
# 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.
 
# 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.
 +
## Needs work - Feel free to work on this one!
 
# Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
 
# Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
 +
## Needs work - Feel free to work on this one!
 
# Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock
 
# Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock
 +
## Needs work - Feel free to work on this one!
 
# Tests, tests, tests.  We need tests for all aspects of the spec.  List tests we need below:
 
# Tests, tests, tests.  We need tests for all aspects of the spec.  List tests we need below:
## Check the mouse cursor during mouse lock and after mouse lock.
+
## Check the mouse cursor during mouse lock and after mouse lock. (Needs content scripts?)
 +
## Check that after unlock mouse is reset to original positions.
 +
## 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:
 +
### Pressing the ESC key
 +
### Switching focus to another window
 +
## Tests for mouselocklost event
 
## <test cases go here...>
 
## <test cases go here...>
 
# Create a tutorial on how to use Mouse Lock, with code examples
 
# Create a tutorial on how to use Mouse Lock, with code examples
 +
## Needs work - Feel free to work on this one!
  
 
==Resources==
 
==Resources==

Revision as of 21:57, 23 November 2011

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)
  • <your name here>

Communication

Development work will be done using a combination of the following:

Tasks

Getting Started

  1. Clone our repo and build a debug version locally
  2. Get a https://bugzilla.mozilla.org account and CC yourself on the bug.
  3. Set a Watch on this page and the Q/A page so you know when things change.
  4. 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.
  5. Blog about your work on this implementation
  6. 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.

  1. No mouse cursor is displayed when the mouse is locked
    1. Completed
  2. MouseLockable DOM Implementation, navigator.pointer (Notes on MouseLock DOM Implementation Nov 13, 2011)
    1. void lock (in Element target, optional in VoidCallback successCallback, optional in VoidCallback failureCallback);
      1. Callback implementation
    2. void unlock ();
      1. Needs to reset the mouse position back to the original position
    3. bool islocked ();
      1. Completed
  3. Mouse Lock Platform Implementations
    1. Windows: SetCursorPos(x, y)
    2. OS X CGWarpMouseCursorPosition(CGPointMake(x, y))
    3. Linux (GTK) gdk_display_warp_pointer (display, screen, x, y), add to http://mxr.mozilla.org/mozilla-central/source/widget/src/gtk2/nsWindow.cpp ???
    4. Mobile?
  4. mouselocklost event DOM Implementation
    1. Completed
  5. Extend MouseEvent DOM implementation with movementX, movementY
    1. Stack Trace for nsDOMMouseEvent::nsDOMMouseEvent ctor (created on mouse move)
    2. Stack Trace for nsDOMMouseEvent::GetScreenX
    3. Where to store the state info (e.g., previous position) between mouse events?
    4. Completed
  6. The browser must exit the mouse lock state if the user agent, window, or tab loses focus
    1. Completed - Full screen is lost during the above action, losing full screen automatically triggers the mouselock's unlock()
  7. The ESC key should exit mouse lock
    1. Completed - Same as above
  8. Mouse lock should only work when in Full Screen Mode
    1. Completed
  9. Refactor nsIDOMNavigator changes for pointer attribute to be in separate interface
  10. Do we need to add a user pref to enable/disable mouse lock?
  11. Do we need to do conditional compilation for mouse lock?
  12. 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.
    1. Needs work - Feel free to work on this one!
  13. 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).
    1. Almost complete - Awaiting patch
  14. 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.
    1. Needs work - Feel free to work on this one!
  15. 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.
    1. Needs work - Feel free to work on this one!
  16. Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
    1. Needs work - Feel free to work on this one!
  17. Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock
    1. Needs work - Feel free to work on this one!
  18. Tests, tests, tests. We need tests for all aspects of the spec. List tests we need below:
    1. Check the mouse cursor during mouse lock and after mouse lock. (Needs content scripts?)
    2. Check that after unlock mouse is reset to original positions.
    3. 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:
      1. Pressing the ESC key
      2. Switching focus to another window
    4. Tests for mouselocklost event
    5. <test cases go here...>
  19. Create a tutorial on how to use Mouse Lock, with code examples
    1. Needs work - Feel free to work on this one!

Resources