- Timestamp:
- Dec 5, 2007 9:41:22 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26551
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r5803 r5973 75 75 void normalizeGeometry (bool adjustPosition = false); 76 76 77 CConsole &console() { return cconsole; }77 CConsole &console() { return mConsole; } 78 78 79 79 bool pause (bool on); … … 135 135 }; 136 136 137 void focusEvent (bool aHasFocus );137 void focusEvent (bool aHasFocus, bool aReleaseHostKey = true); 138 138 bool keyEvent (int aKey, uint8_t aScan, int aFlags, 139 139 wchar_t *aUniKey = NULL); … … 172 172 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock); 173 173 174 void releaseAllPressedKeys (bool aReleaseHost key = true);174 void releaseAllPressedKeys (bool aReleaseHostKey = true); 175 175 void saveKeyStates(); 176 176 void sendChangedKeyStates(); … … 192 192 void maybeRestrictMinimumSize(); 193 193 194 VBoxConsoleWnd *m ainwnd;195 196 CConsole cconsole;194 VBoxConsoleWnd *mMainWnd; 195 196 CConsole mConsole; 197 197 198 198 const VBoxGlobalSettings &gs; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r5826 r5973 596 596 QWidget *parent, const char *name, WFlags f) 597 597 : QScrollView (parent, name, f | WStaticContents | WNoAutoErase) 598 , m ainwnd (mainWnd)599 , cconsole (console)598 , mMainWnd (mainWnd) 599 , mConsole (console) 600 600 , gs (vboxGlobal().settings()) 601 601 , attached (false) … … 626 626 #endif 627 627 { 628 Assert (! cconsole.isNull() &&629 ! cconsole.GetDisplay().isNull() &&630 ! cconsole.GetKeyboard().isNull() &&631 ! cconsole.GetMouse().isNull());628 Assert (!mConsole.isNull() && 629 !mConsole.GetDisplay().isNull() && 630 !mConsole.GetKeyboard().isNull() && 631 !mConsole.GetMouse().isNull()); 632 632 633 633 /* enable MouseMove events */ … … 641 641 642 642 /* to fix some focus issues */ 643 m ainwnd->menuBar()->installEventFilter (this);643 mMainWnd->menuBar()->installEventFilter (this); 644 644 645 645 /* we want to be notified on some parent's events */ 646 m ainwnd->installEventFilter (this);646 mMainWnd->installEventFilter (this); 647 647 648 648 #ifdef Q_WS_X11 … … 663 663 /* setup rendering */ 664 664 665 CDisplay display = cconsole.GetDisplay();665 CDisplay display = mConsole.GetDisplay(); 666 666 Assert (!display.isNull()); 667 667 … … 727 727 /* setup the callback */ 728 728 mCallback = CConsoleCallback (new VBoxConsoleCallback (this)); 729 cconsole.RegisterCallback (mCallback);730 AssertWrapperOk ( cconsole);729 mConsole.RegisterCallback (mCallback); 730 AssertWrapperOk (mConsole); 731 731 732 732 viewport()->setEraseColor (black); … … 767 767 { 768 768 /* detach our framebuffer from Display */ 769 CDisplay display = cconsole.GetDisplay();769 CDisplay display = mConsole.GetDisplay(); 770 770 Assert (!display.isNull()); 771 771 display.SetupInternalFramebuffer (0); … … 774 774 } 775 775 776 cconsole.UnregisterCallback (mCallback);776 mConsole.UnregisterCallback (mCallback); 777 777 } 778 778 … … 786 786 if (mode == VBoxDefs::TimerMode) 787 787 { 788 CDisplay display = cconsole.GetDisplay();788 CDisplay display = mConsole.GetDisplay(); 789 789 return QSize (display.GetWidth() + frameWidth() * 2, 790 790 display.GetHeight() + frameWidth() * 2); … … 847 847 /* Make no normalizeGeometry in case we are in manual resize 848 848 * mode or main window is maximized */ 849 if (m ainwnd->isMaximized() || mainwnd->isFullScreen())849 if (mMainWnd->isMaximized() || mMainWnd->isFullScreen()) 850 850 return; 851 851 … … 896 896 897 897 if (on) 898 cconsole.Pause();898 mConsole.Pause(); 899 899 else 900 cconsole.Resume();901 902 bool ok = cconsole.isOk();900 mConsole.Resume(); 901 902 bool ok = mConsole.isOk(); 903 903 if (!ok) 904 904 { 905 905 if (on) 906 vboxProblem().cannotPauseMachine ( cconsole);906 vboxProblem().cannotPauseMachine (mConsole); 907 907 else 908 vboxProblem().cannotResumeMachine ( cconsole);908 vboxProblem().cannotResumeMachine (mConsole); 909 909 } 910 910 … … 1000 1000 if (isRunning()) 1001 1001 focusEvent (false); 1002 else 1003 { 1004 /* release the host key even when paused */ 1005 mIsHostkeyPressed = false; 1006 emitKeyboardStateChanged(); 1007 } 1002 1008 break; 1003 1009 } … … 1042 1048 1043 1049 /* report to the VM thread that we finished resizing */ 1044 cconsole.GetDisplay().ResizeCompleted (0);1050 mConsole.GetDisplay().ResizeCompleted (0); 1045 1051 1046 1052 mIgnoreMainwndResize = oldIgnoreMainwndResize; … … 1050 1056 1051 1057 /* update geometry after entering fullscreen | seamless */ 1052 if (m ainwnd->isTrueFullscreen() || mainwnd->isTrueSeamless())1058 if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless()) 1053 1059 updateGeometry(); 1054 1060 … … 1064 1070 re->y() - contentsY(), 1065 1071 re->width(), re->height(), false); 1066 /* cconsole.GetDisplay().UpdateCompleted(); - the event was acked already */1072 /* mConsole.GetDisplay().UpdateCompleted(); - the event was acked already */ 1067 1073 return true; 1068 1074 } … … 1072 1078 { 1073 1079 VBoxSetRegionEvent *sre = (VBoxSetRegionEvent*) e; 1074 if (m ainwnd->isTrueSeamless() &&1080 if (mMainWnd->isTrueSeamless() && 1075 1081 sre->region() != mLastVisibleRegion) 1076 1082 { 1077 1083 mLastVisibleRegion = sre->region(); 1078 m ainwnd->setMask (sre->region());1084 mMainWnd->setMask (sre->region()); 1079 1085 } 1080 1086 else if (!mLastVisibleRegion.isNull() && 1081 !m ainwnd->isTrueSeamless())1087 !mMainWnd->isTrueSeamless()) 1082 1088 mLastVisibleRegion = QRegion(); 1083 1089 return true; … … 1104 1110 if (mouse_absolute) 1105 1111 { 1106 CMouse mouse = cconsole.GetMouse();1112 CMouse mouse = mConsole.GetMouse(); 1107 1113 mouse.PutMouseEventAbsolute (-1, -1, 0, 0); 1108 1114 captureMouse (false, false); … … 1114 1120 } 1115 1121 if (me->needsHostCursor()) 1116 m ainwnd->setMouseIntegrationLocked (false);1122 mMainWnd->setMouseIntegrationLocked (false); 1117 1123 return true; 1118 1124 } … … 1177 1183 */ 1178 1184 QWidgetList *list = QApplication::topLevelWidgets (); 1179 bool destroyed = list->find (m ainwnd) < 0;1185 bool destroyed = list->find (mMainWnd) < 0; 1180 1186 delete list; 1181 if (!destroyed && m ainwnd->statusBar())1182 m ainwnd->statusBar()->clear();1187 if (!destroyed && mMainWnd->statusBar()) 1188 mMainWnd->statusBar()->clear(); 1183 1189 1184 1190 return true; … … 1209 1215 if (ue->attached()) 1210 1216 vboxProblem().cannotAttachUSBDevice ( 1211 cconsole,1217 mConsole, 1212 1218 vboxGlobal().details (ue->device()), ue->error()); 1213 1219 else 1214 1220 vboxProblem().cannotDetachUSBDevice ( 1215 cconsole,1221 mConsole, 1216 1222 vboxGlobal().details (ue->device()), ue->error()); 1217 1223 } … … 1231 1237 { 1232 1238 RuntimeErrorEvent *ee = (RuntimeErrorEvent *) e; 1233 vboxProblem().showRuntimeError ( cconsole, ee->fatal(),1239 vboxProblem().showRuntimeError (mConsole, ee->fatal(), 1234 1240 ee->errorID(), ee->message()); 1235 1241 return true; … … 1262 1268 Assert (0); 1263 1269 1264 CKeyboard keyboard = cconsole.GetKeyboard();1270 CKeyboard keyboard = mConsole.GetKeyboard(); 1265 1271 Assert (!keyboard.isNull()); 1266 1272 keyboard.PutScancodes (combo, 6); … … 1269 1275 { 1270 1276 /* activate the main menu */ 1271 if (m ainwnd->isTrueSeamless() || mainwnd->isTrueFullscreen())1272 m ainwnd->popupMainMenu (mouse_captured);1277 if (mMainWnd->isTrueSeamless() || mMainWnd->isTrueFullscreen()) 1278 mMainWnd->popupMainMenu (mouse_captured); 1273 1279 else 1274 m ainwnd->menuBar()->setFocus();1280 mMainWnd->menuBar()->setFocus(); 1275 1281 } 1276 1282 else … … 1279 1285 * (as in case of non-alphanumeric keys) */ 1280 1286 processHotKey (QKeySequence (ke->key()), 1281 m ainwnd->menuBar());1287 mMainWnd->menuBar()); 1282 1288 } 1283 1289 } … … 1359 1365 } 1360 1366 } 1361 else if (watched == m ainwnd)1367 else if (watched == mMainWnd) 1362 1368 { 1363 1369 switch (e->type()) … … 1422 1428 } 1423 1429 } 1424 else if (watched == m ainwnd->menuBar())1430 else if (watched == mMainWnd->menuBar()) 1425 1431 { 1426 1432 /* … … 1442 1448 QKeyEvent *ke = (QKeyEvent *) e; 1443 1449 if (ke->key() == Key_Escape && !(ke->state() & KeyButtonMask)) 1444 if (m ainwnd->menuBar()->hasFocus())1450 if (mMainWnd->menuBar()->hasFocus()) 1445 1451 setFocus(); 1446 1452 break; … … 1469 1475 sprintf (buf, "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X", 1470 1476 event.vkCode, event.scanCode, event.flags, event.dwExtraInfo); 1471 m ainwnd->statusBar()->message (buf);1477 mMainWnd->statusBar()->message (buf); 1472 1478 #endif 1473 1479 … … 1541 1547 ((msg->lParam >> 30) & 0x1), 1542 1548 ((msg->lParam >> 31) & 0x1)); 1543 m ainwnd->statusBar()->message (buf);1549 mMainWnd->statusBar()->message (buf); 1544 1550 LogFlow (("%s\n", buf)); 1545 1551 #endif … … 1643 1649 CHAR4FROMMP (aMsg->mp1), SHORT1FROMMP (aMsg->mp2), 1644 1650 SHORT2FROMMP (aMsg->mp2)); 1645 m ainwnd->statusBar()->message (buf);1651 mMainWnd->statusBar()->message (buf); 1646 1652 LogFlow (("%s\n", buf)); 1647 1653 } … … 1752 1758 event->type == XKeyPress ? 1 : 0, event->xkey.keycode, 1753 1759 event->xkey.state, wineKeyboardInfo.dwFlags, wineKeyboardInfo.wScan); 1754 m ainwnd->statusBar()->message (buf);1760 mMainWnd->statusBar()->message (buf); 1755 1761 LogFlow (("### %s\n", buf)); 1756 1762 #endif … … 1949 1955 * input in situations similar to gaining or losing focus. 1950 1956 * 1951 * @param aHasFocus True if the window got focus and false otherwise. 1957 * @param aHasFocus true if the window got focus and false otherwise. 1958 * @param aReleaseHostKey true to release the host key (used only when 1959 * @a aHasFocus is false. 1952 1960 */ 1953 void VBoxConsoleView::focusEvent (bool aHasFocus) 1961 void VBoxConsoleView::focusEvent (bool aHasFocus, 1962 bool aReleaseHostKey /* = true */) 1954 1963 { 1955 1964 if (aHasFocus) … … 1980 1989 captureMouse (false); 1981 1990 captureKbd (false, false); 1982 releaseAllPressedKeys ( !aHasFocus);1991 releaseAllPressedKeys (aReleaseHostKey); 1983 1992 } 1984 1993 } … … 2073 2082 { 2074 2083 QSize newSize = QSize(); 2075 if (m ainwnd->isTrueFullscreen() || mainwnd->isTrueSeamless())2084 if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless()) 2076 2085 { 2077 2086 mNormalSize = frameSize(); … … 2103 2112 sprintf (buf, "aKey=%08X aScan=%02X aFlags=%08X", 2104 2113 aKey, aScan, aFlags); 2105 m ainwnd->statusBar()->message (buf);2114 mMainWnd->statusBar()->message (buf); 2106 2115 } 2107 2116 #endif … … 2301 2310 processed = processHotKey (QKeySequence (UNICODE_ACCEL + 2302 2311 QChar (ch).upper().unicode()), 2303 m ainwnd->menuBar());2312 mMainWnd->menuBar()); 2304 2313 } 2305 2314 delete[] list; … … 2321 2330 processed = processHotKey (QKeySequence (UNICODE_ACCEL + 2322 2331 c.upper().unicode()), 2323 m ainwnd->menuBar());2332 mMainWnd->menuBar()); 2324 2333 } 2325 2334 } … … 2328 2337 processed = processHotKey (QKeySequence (UNICODE_ACCEL + 2329 2338 QChar (aUniKey [0]).upper().unicode()), 2330 m ainwnd->menuBar());2339 mMainWnd->menuBar()); 2331 2340 2332 2341 /* Don't consider the hot key as pressed since the guest never saw … … 2349 2358 } 2350 2359 2351 CKeyboard keyboard = cconsole.GetKeyboard();2360 CKeyboard keyboard = mConsole.GetKeyboard(); 2352 2361 Assert (!keyboard.isNull()); 2353 2362 … … 2363 2372 for (uint i = 0; i < count; ++ i) 2364 2373 sprintf (buf + strlen (buf), "%02X ", codes [i]); 2365 m ainwnd->statusBar()->message (buf);2374 mMainWnd->statusBar()->message (buf); 2366 2375 LogFlow (("%s\n", buf)); 2367 2376 } … … 2391 2400 aType, aPos.x(), aPos.y(), aButton, aState, aStateAfter, 2392 2401 aWheelDelta, aWheelDir); 2393 m ainwnd->statusBar()->message (buf);2402 mMainWnd->statusBar()->message (buf); 2394 2403 #else 2395 2404 Q_UNUSED (aButton); … … 2421 2430 #endif 2422 2431 2423 CMouse mouse = cconsole.GetMouse();2432 CMouse mouse = mConsole.GetMouse(); 2424 2433 mouse.PutMouseEvent (aGlobalPos.x() - last_pos.x(), 2425 2434 aGlobalPos.y() - last_pos.y(), … … 2522 2531 DarwinCursorSet (&mDarwinCursor); 2523 2532 #endif 2524 if (m ainwnd->isTrueFullscreen())2533 if (mMainWnd->isTrueFullscreen()) 2525 2534 { 2526 2535 if (mode != VBoxDefs::SDLMode) … … 2571 2580 else if (cpnt.y() >= ch) cpnt.setY (ch - 1); 2572 2581 2573 CMouse mouse = cconsole.GetMouse();2582 CMouse mouse = mConsole.GetMouse(); 2574 2583 mouse.PutMouseEventAbsolute (cpnt.x() + 1, cpnt.y() + 1, 2575 2584 wheel, state); … … 2628 2637 */ 2629 2638 QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), 32, 0); 2630 CDisplay dsp = cconsole.GetDisplay();2639 CDisplay dsp = mConsole.GetDisplay(); 2631 2640 dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height()); 2632 2641 /* … … 2649 2658 /* reuse the focus event handler to uncapture everything */ 2650 2659 if (hasFocus()) 2651 focusEvent (false );2660 focusEvent (false /* aHasFocus*/, false /* aReleaseHostKey */); 2652 2661 break; 2653 2662 } … … 2664 2673 * the viewport through IFramebuffer::NotifyUpdate) 2665 2674 */ 2666 CDisplay dsp = cconsole.GetDisplay();2675 CDisplay dsp = mConsole.GetDisplay(); 2667 2676 dsp.InvalidateAndUpdate(); 2668 2677 } … … 2670 2679 /* reuse the focus event handler to capture input */ 2671 2680 if (hasFocus()) 2672 focusEvent (true );2681 focusEvent (true /* aHasFocus */); 2673 2682 break; 2674 2683 } … … 2683 2692 { 2684 2693 #if defined (VBOX_GUI_USE_REFRESH_TIMER) 2685 if ( mode == VBoxDefs::TimerMode ) { 2686 FRAMEBUF_DEBUG_START( xxx ); 2694 if (mode == VBoxDefs::TimerMode) 2695 { 2696 FRAMEBUF_DEBUG_START (xxx); 2687 2697 QSize last_sz = pm.size(); 2688 bool rc = display_to_pixmap( cconsole, pm ); 2689 if ( rc ) { 2690 if ( pm.size() != last_sz ) { 2698 bool rc = display_to_pixmap (mConsole, pm); 2699 if (rc) 2700 { 2701 if (pm.size() != last_sz) 2702 { 2691 2703 int pw = pm.width(), ph = pm.height(); 2692 resizeContents ( pw, ph);2704 resizeContents (pw, ph); 2693 2705 updateGeometry(); 2694 setMaximumSize ( sizeHint());2695 / / let our toplevel widget calculate its sizeHint properly2696 QApplication::sendPostedEvents ( 0, QEvent::LayoutHint);2706 setMaximumSize (sizeHint()); 2707 /* let our toplevel widget calculate its sizeHint properly */ 2708 QApplication::sendPostedEvents (0, QEvent::LayoutHint); 2697 2709 normalizeGeometry(); 2698 } else { 2699 // the alternative is to update, so we will be repainted 2700 // on the next event loop iteration. currently disabled. 2701 //updateContents(); 2702 repaintContents( false ); 2703 } 2704 } 2705 if ( rc ) 2706 FRAMEBUF_DEBUG_STOP( xxx, pm.width(), pm.height() ); 2710 } 2711 else 2712 { 2713 /* the alternative is to update, so we will be repainted 2714 * on the next event loop iteration. currently disabled. 2715 * updateContents(); */ 2716 repaintContents (false); 2717 } 2718 } 2719 if (rc) 2720 FRAMEBUF_DEBUG_STOP (xxx, pm.width(), pm.height()); 2707 2721 } 2708 2722 else 2709 2723 #endif 2710 repaintContents ( false);2724 repaintContents (false); 2711 2725 } 2712 2726 … … 2850 2864 #endif 2851 2865 /* release mouse buttons */ 2852 CMouse mouse = cconsole.GetMouse();2866 CMouse mouse = mConsole.GetMouse(); 2853 2867 mouse.PutMouseEvent (0, 0, 0, 0); 2854 2868 } … … 2915 2929 } 2916 2930 2917 void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostkey) 2931 /** 2932 * Send the KEY BREAK code to the VM for all currently pressed keys. 2933 * 2934 * @param aReleaseHostKey @c true to set the host key state to unpressed. 2935 */ 2936 void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostKey) 2918 2937 { 2919 2938 AssertMsg (attached, ("Console must be attached")); 2920 2939 2921 CKeyboard keyboard = cconsole.GetKeyboard();2940 CKeyboard keyboard = mConsole.GetKeyboard(); 2922 2941 bool fSentRESEND = false; 2923 2942 2924 / /send a dummy scan code (RESEND) to prevent the guest OS from recognizing2925 //a single key click (for ex., Alt) and performing an unwanted action2926 //(for ex., activating the menu) when we release all pressed keys below.2927 //Note, that it's just a guess that sending RESEND will give the desired2928 // effect :), but at least it works with NT and W2k guests.2929 2930 // @TODOSending 0xFE is responsible for the warning2943 /* send a dummy scan code (RESEND) to prevent the guest OS from recognizing 2944 * a single key click (for ex., Alt) and performing an unwanted action 2945 * (for ex., activating the menu) when we release all pressed keys below. 2946 * Note, that it's just a guess that sending RESEND will give the desired 2947 * effect :), but at least it works with NT and W2k guests. */ 2948 2949 /// @todo Sending 0xFE is responsible for the warning 2931 2950 // 2932 2951 // ``atkbd.c: Spurious NAK on isa0060/serio0. Some program might … … 2936 2955 // send this command unless we really have to release any key modifier. 2937 2956 // --frank 2957 2938 2958 for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); i++) 2939 2959 { … … 2962 2982 } 2963 2983 2964 if (aReleaseHost key)2984 if (aReleaseHostKey) 2965 2985 mIsHostkeyPressed = false; 2966 2986 … … 2986 3006 2987 3007 LONG codes [2]; 2988 CKeyboard keyboard = cconsole.GetKeyboard();3008 CKeyboard keyboard = mConsole.GetKeyboard(); 2989 3009 for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); ++ i) 2990 3010 { … … 3326 3346 * We assume here that the centralWidget() contains this view only 3327 3347 * and gives it all available space. */ 3328 QSize sz (aToSize.isValid() ? aToSize : m ainwnd->centralWidget()->size());3348 QSize sz (aToSize.isValid() ? aToSize : mMainWnd->centralWidget()->size()); 3329 3349 if (!aToSize.isValid()) 3330 3350 sz -= QSize (frameWidth() * 2, frameWidth() * 2); 3331 3351 LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height())); 3332 3352 3333 cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);3353 mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0); 3334 3354 } 3335 3355 }
Note:
See TracChangeset
for help on using the changeset viewer.