Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool mouseLocked = false;
- // Tell the widget if mouse lock is on
- if (aEvent->widget) {
- nsIFocusManager* fm = nsFocusManager::GetFocusManager();
- if (fm) {
- nsCOMPtr<nsIDOMWindow> currentWindow;
- fm->GetFocusedWindow(getter_AddRefs(currentWindow));
- if (currentWindow) {
- nsCOMPtr<nsIDOMNavigator> navigator;
- currentWindow->GetNavigator(getter_AddRefs(navigator));
- if (navigator) {
- nsCOMPtr<nsIDOMMouseLockable> lockable;
- navigator->GetPointer(getter_AddRefs(lockable));
- if (lockable) {
- lockable->Islocked(&mouseLocked);
- aEvent->widget->mMouseLock = mouseLocked;
- }
- }
- }
- }
- }
- // Remember the previous event's refPoint so we can calculate movement deltas.
- if (mouseLocked && aEvent->widget) {
- nsIntRect bounds;
- aEvent->widget->GetScreenBounds(bounds);
- aEvent->lastRefPoint = nsIntPoint(bounds.width/2, bounds.height/2);
- } else {
- aEvent->lastRefPoint = nsIntPoint(sLastRefPoint.x, sLastRefPoint.y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement