Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. bool mouseLocked = false;
  2. // Tell the widget if mouse lock is on
  3. if (aEvent->widget) {
  4.   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
  5.   if (fm) {
  6.     nsCOMPtr<nsIDOMWindow> currentWindow;
  7.     fm->GetFocusedWindow(getter_AddRefs(currentWindow));
  8.     if (currentWindow) {
  9.       nsCOMPtr<nsIDOMNavigator> navigator;
  10.       currentWindow->GetNavigator(getter_AddRefs(navigator));
  11.       if (navigator) {
  12.         nsCOMPtr<nsIDOMMouseLockable> lockable;
  13.         navigator->GetPointer(getter_AddRefs(lockable));
  14.         if (lockable) {
  15.           lockable->Islocked(&mouseLocked);
  16.           aEvent->widget->mMouseLock = mouseLocked;
  17.         }
  18.       }
  19.     }
  20.   }
  21. }
  22.  
  23. // Remember the previous event's refPoint so we can calculate movement deltas.
  24. if (mouseLocked && aEvent->widget) {
  25.   nsIntRect bounds;
  26.   aEvent->widget->GetScreenBounds(bounds);
  27.   aEvent->lastRefPoint = nsIntPoint(bounds.width/2, bounds.height/2);
  28. } else {
  29.   aEvent->lastRefPoint = nsIntPoint(sLastRefPoint.x, sLastRefPoint.y);
  30. }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement