VirtualBox

Changeset 1392 in vbox for trunk


Ignore:
Timestamp:
Mar 10, 2007 1:48:19 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
19388
Message:

try prevent the mouse from escaping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r1391 r1392  
    19411941                             wheel, state);
    19421942
     1943#if defined (Q_WS_MAC)
     1944        /*
     1945         * Keep the mouse from leaving the widget.
     1946         *
     1947         * This is a bit tricky to get right because if it escapes we won't necessarily
     1948         * get mouse events any longer and can warp it back. So, we keep safety zone
     1949         * of up to 300 pixels around the borders of the widget to prevent this from
     1950         * happening. Also, the mouse is warped back to the center of the widget.
     1951         *
     1952         * (Note, aPos seems to be unreliable, it caused endless recursion here at one points...)
     1953         * (Note, synergy and other remote clients might not like this cursor warping.)
     1954         */
     1955        QRect rect = viewport()->visibleRect();
     1956        QPoint pw = viewport()->mapToGlobal (viewport()->pos());
     1957        rect.moveBy (pw.x(), pw.y());
     1958
     1959        QRect dpRect = QApplication::desktop()->screenGeometry (viewport());
     1960        if (rect.intersects (dpRect))
     1961            rect = rect.intersect (dpRect);
     1962
     1963        int wsafe = rect.width() / 6;
     1964        rect.setWidth (rect.width() - wsafe * 2);
     1965        rect.setLeft (rect.left() + wsafe);
     1966
     1967        int hsafe = rect.height() / 6;
     1968        rect.setWidth (rect.height() - hsafe * 2);
     1969        rect.setTop (rect.top() + hsafe);
     1970
     1971        if (rect.contains (aGlobalPos, true))
     1972            last_pos = aGlobalPos;
     1973        else
     1974        {
     1975            last_pos = rect.center();
     1976            QCursor::setPos (last_pos);
     1977        }
     1978
     1979#else /* !Q_WS_MAC */
     1980
    19431981        /* "jerk" the mouse by bringing it to the opposite side
    19441982         * to simulate the endless moving */
     
    19892027        }
    19902028#endif
     2029#endif /* !Q_WS_MAC */
    19912030        return true; /* stop further event handling */
    19922031    }
    19932032    else /* !mouse_captured */
    19942033    {
     2034#ifdef Q_WS_MAC
     2035        /* Update the mouse cursor; this is a bit excessive really... */
     2036        if (!DarwinCursorIsNull (&m_darwinCursor))
     2037            DarwinCursorSet (&m_darwinCursor);
     2038#endif
    19952039        if (mainwnd->isTrueFullscreen())
    19962040        {
     
    22812325        /* memorize the host position where the cursor was captured */
    22822326        captured_pos = QCursor::pos();
    2283 #ifndef Q_WS_WIN32
    2284         viewport()->grabMouse();
    2285 #else
     2327#ifdef Q_WS_WIN32
    22862328        viewport()->setCursor (QCursor (BlankCursor));
    22872329        /* move the mouse to the center of the visible area */
    22882330        QCursor::setPos (mapToGlobal (visibleRect().center()));
    2289 #endif
    22902331        last_pos = QCursor::pos();
     2332#elif defined (Q_WS_MAC)
     2333        /* move the mouse to the center of the visible area */
     2334        last_pos = mapToGlobal (visibleRect().center());
     2335        QCursor::setPos (last_pos);
     2336        /* grab all mouse events. */
     2337        viewport()->grabMouse();
     2338#else
     2339        viewport()->grabMouse();
     2340        last_pos = QCursor::pos();
     2341#endif
    22912342    }
    22922343    else
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette