- Timestamp:
- Mar 10, 2007 1:48:19 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19388
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r1391 r1392 1941 1941 wheel, state); 1942 1942 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 1943 1981 /* "jerk" the mouse by bringing it to the opposite side 1944 1982 * to simulate the endless moving */ … … 1989 2027 } 1990 2028 #endif 2029 #endif /* !Q_WS_MAC */ 1991 2030 return true; /* stop further event handling */ 1992 2031 } 1993 2032 else /* !mouse_captured */ 1994 2033 { 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 1995 2039 if (mainwnd->isTrueFullscreen()) 1996 2040 { … … 2281 2325 /* memorize the host position where the cursor was captured */ 2282 2326 captured_pos = QCursor::pos(); 2283 #ifndef Q_WS_WIN32 2284 viewport()->grabMouse(); 2285 #else 2327 #ifdef Q_WS_WIN32 2286 2328 viewport()->setCursor (QCursor (BlankCursor)); 2287 2329 /* move the mouse to the center of the visible area */ 2288 2330 QCursor::setPos (mapToGlobal (visibleRect().center())); 2289 #endif2290 2331 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 2291 2342 } 2292 2343 else
Note:
See TracChangeset
for help on using the changeset viewer.