Changeset 6184 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 25, 2007 5:42:01 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26954
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r5999 r6184 81 81 void setMouseIntegrationEnabled (bool enabled); 82 82 83 bool isMouseAbsolute() const { return m ouse_absolute; }83 bool isMouseAbsolute() const { return mMouseAbsolute; } 84 84 85 85 void setAutoresizeGuest (bool on); … … 146 146 { 147 147 emit keyboardStateChanged ( 148 ( kbd_captured ? KeyboardCaptured : 0) |148 (mKbdCaptured ? KeyboardCaptured : 0) | 149 149 (mIsHostkeyPressed ? HostKeyPressed : 0)); 150 150 } 151 151 152 152 void emitMouseStateChanged() { 153 emit mouseStateChanged ((m ouse_captured ? MouseCaptured : 0) |154 (m ouse_absolute ? MouseAbsolute : 0) |155 (!m ouse_integration ? MouseAbsoluteDisabled : 0));153 emit mouseStateChanged ((mMouseCaptured ? MouseCaptured : 0) | 154 (mMouseAbsolute ? MouseAbsolute : 0) | 155 (!mMouseIntegration ? MouseAbsoluteDisabled : 0)); 156 156 } 157 157 … … 166 166 #endif 167 167 168 void captureKbd (bool capture, bool emit_signal = true);169 void captureMouse (bool capture, bool emit_signal = true);168 void captureKbd (bool aCapture, bool aEmitSignal = true); 169 void captureMouse (bool aCapture, bool aEmitSignal = true); 170 170 171 171 bool processHotKey (const QKeySequence &key, QMenuData *data); … … 179 179 void setPointerShape (MousePointerChangeEvent *me); 180 180 181 bool isPaused() { return last_state == CEnums::Paused; }182 bool isRunning() { return last_state == CEnums::Running; }181 bool isPaused() { return mLastState == CEnums::Paused; } 182 bool isRunning() { return mLastState == CEnums::Running; } 183 183 184 184 static void dimImage (QImage &img); … … 198 198 const VBoxGlobalSettings &gs; 199 199 200 CEnums::MachineState last_state;201 202 bool attached : 1;203 bool kbd_captured : 1;204 bool m ouse_captured : 1;205 bool m ouse_absolute : 1;206 bool m ouse_integration : 1;207 QPoint last_pos;208 QPoint captured_pos;200 CEnums::MachineState mLastState; 201 202 bool mAttached : 1; 203 bool mKbdCaptured : 1; 204 bool mMouseCaptured : 1; 205 bool mMouseAbsolute : 1; 206 bool mMouseIntegration : 1; 207 QPoint mLastPos; 208 QPoint mCapturedPos; 209 209 210 210 bool mDisableAutoCapture : 1; … … 217 217 bool mIsHostkeyAlone : 1; 218 218 219 /** kbd_captured value during the the last host key press or release */219 /** mKbdCaptured value during the the last host key press or release */ 220 220 bool hostkey_in_capture : 1; 221 221 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r6059 r6184 137 137 else if (EventClass == kEventClassCommand) 138 138 { 139 if (view-> kbd_captured)139 if (view->mKbdCaptured) 140 140 return 0; 141 141 } … … 599 599 , mConsole (console) 600 600 , gs (vboxGlobal().settings()) 601 , attached (false)602 , kbd_captured (false)603 , m ouse_captured (false)604 , m ouse_absolute (false)605 , m ouse_integration (true)601 , mAttached (false) 602 , mKbdCaptured (false) 603 , mMouseCaptured (false) 604 , mMouseAbsolute (false) 605 , mMouseIntegration (true) 606 606 , mDisableAutoCapture (false) 607 607 , mIsHostkeyPressed (false) … … 814 814 void VBoxConsoleView::attach() 815 815 { 816 if (! attached)817 { 818 attached = true;816 if (!mAttached) 817 { 818 mAttached = true; 819 819 } 820 820 } … … 833 833 void VBoxConsoleView::detach() 834 834 { 835 if ( attached)835 if (mAttached) 836 836 { 837 837 /* reuse the focus event handler to uncapture everything */ 838 838 focusEvent (false); 839 attached = false;839 mAttached = false; 840 840 } 841 841 } … … 922 922 void VBoxConsoleView::setMouseIntegrationEnabled (bool enabled) 923 923 { 924 if (m ouse_integration == enabled)924 if (mMouseIntegration == enabled) 925 925 return; 926 926 927 if (m ouse_absolute)927 if (mMouseAbsolute) 928 928 captureMouse (!enabled, false); 929 929 … … 945 945 viewport()->setCursor (QCursor (BlankCursor)); 946 946 947 m ouse_integration = enabled;947 mMouseIntegration = enabled; 948 948 949 949 emitMouseStateChanged(); … … 991 991 bool VBoxConsoleView::event (QEvent *e) 992 992 { 993 if ( attached)993 if (mAttached) 994 994 { 995 995 switch (e->type()) … … 1037 1037 * So it is necessary to perform updateMouseClipping() for 1038 1038 * the guest resize event if the mouse cursor was captured. */ 1039 if (m ouse_captured)1039 if (mMouseCaptured) 1040 1040 updateMouseClipping(); 1041 1041 … … 1101 1101 * supported (change mouse shape type event may arrive after 1102 1102 * mouse capability change that disables integration */ 1103 if (m ouse_absolute)1103 if (mMouseAbsolute) 1104 1104 setPointerShape (me); 1105 1105 return true; … … 1108 1108 { 1109 1109 MouseCapabilityEvent *me = (MouseCapabilityEvent *) e; 1110 if (m ouse_absolute != me->supportsAbsolute())1110 if (mMouseAbsolute != me->supportsAbsolute()) 1111 1111 { 1112 m ouse_absolute = me->supportsAbsolute();1112 mMouseAbsolute = me->supportsAbsolute(); 1113 1113 /* correct the mouse capture state and reset the cursor 1114 1114 * to the default shape if necessary */ 1115 if (m ouse_absolute)1115 if (mMouseAbsolute) 1116 1116 { 1117 1117 CMouse mouse = mConsole.GetMouse(); … … 1122 1122 viewport()->unsetCursor(); 1123 1123 emitMouseStateChanged(); 1124 vboxProblem().remindAboutMouseIntegration (m ouse_absolute);1124 vboxProblem().remindAboutMouseIntegration (mMouseAbsolute); 1125 1125 } 1126 1126 if (me->needsHostCursor()) … … 1281 1281 /* activate the main menu */ 1282 1282 if (mMainWnd->isTrueSeamless() || mMainWnd->isTrueFullscreen()) 1283 mMainWnd->popupMainMenu (m ouse_captured);1283 mMainWnd->popupMainMenu (mMouseCaptured); 1284 1284 else 1285 1285 mMainWnd->menuBar()->setFocus(); … … 1336 1336 bool VBoxConsoleView::eventFilter (QObject *watched, QEvent *e) 1337 1337 { 1338 if ( attached && watched == viewport())1338 if (mAttached && watched == viewport()) 1339 1339 { 1340 1340 switch (e->type()) … … 1363 1363 case QEvent::Resize: 1364 1364 { 1365 if (m ouse_captured)1365 if (mMouseCaptured) 1366 1366 updateMouseClipping(); 1367 1367 } … … 1475 1475 { 1476 1476 #if 0 1477 LogFlow (("### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X ( kbd_captured=%d)\n",1478 event.vkCode, event.scanCode, event.flags, event.dwExtraInfo, kbd_captured));1477 LogFlow (("### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X (mKbdCaptured=%d)\n", 1478 event.vkCode, event.scanCode, event.flags, event.dwExtraInfo, mKbdCaptured)); 1479 1479 char buf [256]; 1480 1480 sprintf (buf, "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X", … … 1491 1491 return true; 1492 1492 1493 if (! kbd_captured)1493 if (!mKbdCaptured) 1494 1494 return false; 1495 1495 … … 1531 1531 bool VBoxConsoleView::winEvent (MSG *msg) 1532 1532 { 1533 if (! attached || ! (1533 if (!mAttached || ! ( 1534 1534 msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN || 1535 1535 msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP … … 1611 1611 1612 1612 bool result = keyEvent (vkey, scan, flags); 1613 if (!result && kbd_captured)1613 if (!result && mKbdCaptured) 1614 1614 { 1615 1615 /* keyEvent() returned that it didn't process the message, but since the … … 1640 1640 bool VBoxConsoleView::pmEvent (QMSG *aMsg) 1641 1641 { 1642 if (! attached || aMsg->msg != WM_CHAR)1642 if (!mAttached || aMsg->msg != WM_CHAR) 1643 1643 return false; 1644 1644 … … 1714 1714 1715 1715 bool result = keyEvent (vkey, scan, flags); 1716 if (!result && kbd_captured)1716 if (!result && mKbdCaptured) 1717 1717 { 1718 1718 /* keyEvent() returned that it didn't process the message, but since the … … 1745 1745 case XKeyPress: 1746 1746 case XKeyRelease: 1747 if ( attached)1747 if (mAttached) 1748 1748 break; 1749 1749 /* else fall through */ … … 1982 1982 // released after we got focus, and grab the mouse only after then. 1983 1983 // btw, the similar would be good the for keyboard auto-capture, too. 1984 // if (!(m ouse_absolute && mouse_integration))1984 // if (!(mMouseAbsolute && mMouseIntegration)) 1985 1985 // captureMouse (true); 1986 1986 } … … 2102 2102 * Called on every key press and release (while in focus). 2103 2103 * 2104 * @ key virtual scan code (virtual key on Win32 and KeySym on X11)2105 * @ scan hardware scan code2106 * @ flags flags, a combination of Key* constants2107 * @ aUniKeyUnicode translation of the key. Optional.2104 * @param aKey virtual scan code (virtual key on Win32 and KeySym on X11) 2105 * @param aScan hardware scan code 2106 * @param aFlags flags, a combination of Key* constants 2107 * @param aUniKey Unicode translation of the key. Optional. 2108 2108 * 2109 2109 * @return true to consume the event and false to pass it to Qt … … 2167 2167 * to synchronize the state. */ 2168 2168 fixModifierState (codes, &count); 2169 } 2170 2171 /* Check if it's C-A-D */ 2172 if (aScan == 0x53 /* Del */ && 2173 ((mPressedKeys [0x38] & IsKeyPressed) /* Alt */ || 2174 (mPressedKeys [0x38] & IsExtKeyPressed)) && 2175 ((mPressedKeys [0x1d] & IsKeyPressed) /* Ctrl */ || 2176 (mPressedKeys [0x1d] & IsExtKeyPressed))) 2177 { 2178 /* Use the C-A-D combination as a last resort to get the 2179 * keyboard and mouse back to the host when the user forgets 2180 * the Host Key. Note that it's always possible to send C-A-D 2181 * to the guest using the Host+Del combination. BTW, it would 2182 * be preferrable to completely ignore C-A-D in guests, but 2183 * that's not possible because we cannot predict what other 2184 * keys will be pressed next when one of C, A, D is held. */ 2185 2186 if (isRunning() && mKbdCaptured) 2187 { 2188 captureKbd (false); 2189 if (!(mMouseAbsolute && mMouseIntegration)) 2190 captureMouse (false); 2191 } 2192 2193 return true; 2169 2194 } 2170 2195 … … 2193 2218 } 2194 2219 2195 if ( kbd_captured)2220 if (mKbdCaptured) 2196 2221 mPressedKeys [aScan] |= IsKbdCaptured; 2197 2222 else … … 2202 2227 { 2203 2228 /* currently this is used in winLowKeyboardEvent() only */ 2204 hostkey_in_capture = kbd_captured;2229 hostkey_in_capture = mKbdCaptured; 2205 2230 } 2206 2231 … … 2250 2275 if (isRunning()) 2251 2276 { 2252 bool captured = kbd_captured;2277 bool captured = mKbdCaptured; 2253 2278 bool ok = true; 2254 2279 if (!captured) … … 2272 2297 { 2273 2298 captureKbd (!captured, false); 2274 if (!(m ouse_absolute && mouse_integration))2275 captureMouse ( kbd_captured);2299 if (!(mMouseAbsolute && mMouseIntegration)) 2300 captureMouse (mKbdCaptured); 2276 2301 } 2277 2302 } … … 2428 2453 } 2429 2454 2430 if (m ouse_captured)2455 if (mMouseCaptured) 2431 2456 { 2432 2457 #ifdef Q_WS_WIN32 … … 2436 2461 2437 2462 CMouse mouse = mConsole.GetMouse(); 2438 mouse.PutMouseEvent (aGlobalPos.x() - last_pos.x(),2439 aGlobalPos.y() - last_pos.y(),2463 mouse.PutMouseEvent (aGlobalPos.x() - mLastPos.x(), 2464 aGlobalPos.y() - mLastPos.y(), 2440 2465 wheel, state); 2441 2466 … … 2469 2494 2470 2495 if (rect.contains (aGlobalPos, true)) 2471 last_pos = aGlobalPos;2496 mLastPos = aGlobalPos; 2472 2497 else 2473 2498 { 2474 last_pos = rect.center();2475 QCursor::setPos ( last_pos);2499 mLastPos = rect.center(); 2500 QCursor::setPos (mLastPos); 2476 2501 } 2477 2502 … … 2496 2521 if (p != aPos) 2497 2522 { 2498 last_pos = viewport()->mapToGlobal (p);2499 QCursor::setPos ( last_pos);2523 mLastPos = viewport()->mapToGlobal (p); 2524 QCursor::setPos (mLastPos); 2500 2525 } 2501 2526 else 2502 2527 { 2503 last_pos = aGlobalPos;2528 mLastPos = aGlobalPos; 2504 2529 } 2505 2530 #else … … 2518 2543 if (p != aGlobalPos) 2519 2544 { 2520 last_pos = p;2521 QCursor::setPos ( last_pos);2545 mLastPos = p; 2546 QCursor::setPos (mLastPos); 2522 2547 } 2523 2548 else 2524 2549 { 2525 last_pos = aGlobalPos;2550 mLastPos = aGlobalPos; 2526 2551 } 2527 2552 #endif … … 2529 2554 return true; /* stop further event handling */ 2530 2555 } 2531 else /* !m ouse_captured */2556 else /* !mMouseCaptured */ 2532 2557 { 2533 2558 #ifdef Q_WS_MAC … … 2560 2585 } 2561 2586 2562 if (m ouse_absolute && mouse_integration)2587 if (mMouseAbsolute && mMouseIntegration) 2563 2588 { 2564 2589 int cw = contentsWidth(), ch = contentsHeight(); … … 2668 2693 case CEnums::Running: 2669 2694 { 2670 if ( last_state == CEnums::Paused)2695 if (mLastState == CEnums::Paused) 2671 2696 { 2672 2697 if (mode != VBoxDefs::TimerMode && mFrameBuf) … … 2691 2716 } 2692 2717 2693 last_state = state;2718 mLastState = state; 2694 2719 } 2695 2720 … … 2779 2804 * system (including most system combinations like Alt-Tab). 2780 2805 * 2781 * @ capture true to capture, false to uncapture2782 * @ emit_signal whether to emit keyboardStateChanged() or not2806 * @param aCapture true to capture, false to uncapture. 2807 * @param aEmitSignal Whether to emit keyboardStateChanged() or not. 2783 2808 */ 2784 void VBoxConsoleView::captureKbd (bool capture, bool emit_signal)2785 { 2786 AssertMsg ( attached, ("Console must be attached"));2787 2788 if ( kbd_captured == capture)2809 void VBoxConsoleView::captureKbd (bool aCapture, bool aEmitSignal /* = true */) 2810 { 2811 AssertMsg (mAttached, ("Console must be attached")); 2812 2813 if (mKbdCaptured == aCapture) 2789 2814 return; 2790 2815 … … 2799 2824 /**/ 2800 2825 #elif defined (Q_WS_X11) 2801 if ( capture)2826 if (aCapture) 2802 2827 XGrabKey (x11Display(), AnyKey, AnyModifier, 2803 2828 topLevelWidget()->winId(), False, … … 2807 2832 topLevelWidget()->winId()); 2808 2833 #elif defined (Q_WS_MAC) 2809 if ( capture)2834 if (aCapture) 2810 2835 { 2811 2836 ::DarwinDisableGlobalHotKeys (true); … … 2818 2843 } 2819 2844 #else 2820 if ( capture)2845 if (aCapture) 2821 2846 grabKeyboard(); 2822 2847 else … … 2824 2849 #endif 2825 2850 2826 kbd_captured = capture;2827 2828 if ( emit_signal)2851 mKbdCaptured = aCapture; 2852 2853 if (aEmitSignal) 2829 2854 emitKeyboardStateChanged (); 2830 2855 } … … 2834 2859 * unavailable to the host applications. 2835 2860 * 2836 * @capture true to capture, false to uncapture 2861 * @param aCapture true to capture, false to uncapture. 2862 * @param aEmitSignal Whether to emit mouseStateChanged() or not. 2837 2863 */ 2838 void VBoxConsoleView::captureMouse (bool capture, bool emit_signal)2839 { 2840 AssertMsg ( attached, ("Console must be attached"));2841 2842 if (m ouse_captured == capture)2864 void VBoxConsoleView::captureMouse (bool aCapture, bool aEmitSignal /* = true */) 2865 { 2866 AssertMsg (mAttached, ("Console must be attached")); 2867 2868 if (mMouseCaptured == aCapture) 2843 2869 return; 2844 2870 2845 if ( capture)2871 if (aCapture) 2846 2872 { 2847 2873 /* memorize the host position where the cursor was captured */ 2848 captured_pos = QCursor::pos();2874 mCapturedPos = QCursor::pos(); 2849 2875 #ifdef Q_WS_WIN32 2850 2876 viewport()->setCursor (QCursor (BlankCursor)); 2851 2877 /* move the mouse to the center of the visible area */ 2852 2878 QCursor::setPos (mapToGlobal (visibleRect().center())); 2853 last_pos = QCursor::pos();2879 mLastPos = QCursor::pos(); 2854 2880 #elif defined (Q_WS_MAC) 2855 2881 /* move the mouse to the center of the visible area */ 2856 last_pos = mapToGlobal (visibleRect().center());2857 QCursor::setPos ( last_pos);2882 mLastPos = mapToGlobal (visibleRect().center()); 2883 QCursor::setPos (mLastPos); 2858 2884 /* grab all mouse events. */ 2859 2885 viewport()->grabMouse(); 2860 2886 #else 2861 2887 viewport()->grabMouse(); 2862 last_pos = QCursor::pos();2888 mLastPos = QCursor::pos(); 2863 2889 #endif 2864 2890 } … … 2873 2899 } 2874 2900 2875 m ouse_captured = capture;2901 mMouseCaptured = aCapture; 2876 2902 2877 2903 updateMouseClipping(); 2878 2904 2879 if ( emit_signal)2905 if (aEmitSignal) 2880 2906 emitMouseStateChanged (); 2881 2907 } … … 2941 2967 void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostKey) 2942 2968 { 2943 AssertMsg ( attached, ("Console must be attached"));2969 AssertMsg (mAttached, ("Console must be attached")); 2944 2970 2945 2971 CKeyboard keyboard = mConsole.GetKeyboard(); … … 3008 3034 void VBoxConsoleView::sendChangedKeyStates() 3009 3035 { 3010 AssertMsg ( attached, ("Console must be attached"));3036 AssertMsg (mAttached, ("Console must be attached")); 3011 3037 3012 3038 LONG codes [2]; … … 3036 3062 void VBoxConsoleView::updateMouseClipping() 3037 3063 { 3038 AssertMsg (attached, ("Console must be attached")); 3039 3040 if ( mouse_captured ) { 3041 viewport()->setCursor( QCursor( BlankCursor ) ); 3064 AssertMsg (mAttached, ("Console must be attached")); 3065 3066 if (mMouseCaptured) 3067 { 3068 viewport()->setCursor (QCursor (BlankCursor)); 3042 3069 #ifdef Q_WS_WIN32 3043 3070 QRect r = viewport()->rect(); 3044 r.moveTopLeft ( viewport()->mapToGlobal( QPoint( 0, 0 ) ));3071 r.moveTopLeft (viewport()->mapToGlobal (QPoint (0, 0))); 3045 3072 RECT rect = { r.left(), r.top(), r.right() + 1, r.bottom() + 1 }; 3046 ::ClipCursor( &rect ); 3047 #endif 3048 } else { 3073 ::ClipCursor (&rect); 3074 #endif 3075 } 3076 else 3077 { 3049 3078 #ifdef Q_WS_WIN32 3050 ::ClipCursor ( NULL);3079 ::ClipCursor (NULL); 3051 3080 #endif 3052 3081 /* return the cursor to where it was when we captured it and show it */ 3053 QCursor::setPos ( captured_pos);3082 QCursor::setPos (mCapturedPos); 3054 3083 viewport()->unsetCursor(); 3055 3084 }
Note:
See TracChangeset
for help on using the changeset viewer.