- Timestamp:
- May 17, 2007 3:34:02 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 21279
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r2354 r2700 49 49 class QMenuData; 50 50 51 /** Auto-resize event. 52 * Useful for posting into events queue to be processed just after all 53 * QEvent::Resize & QEvent::WindowStateChange events currently posted. 54 * This is necessary due to these two events - QEvent::Resize & 55 * QEvent::WindowStateChange are processed in different sequence 56 * under Win32 and X11. */ 57 class AutoResizeEvent : public QEvent 58 { 59 public: 60 AutoResizeEvent () : 61 QEvent ((QEvent::Type) VBoxDefs::AutoResizeEventType) {} 62 }; 63 51 64 class VBoxConsoleView : public QScrollView 52 65 { … … 96 109 void mouseStateChanged (int state); 97 110 void machineStateChanged (CEnums::MachineState state); 111 void additionsStateChanged (const QString &, bool); 98 112 99 113 protected: … … 169 183 static void dimImage (QImage &img); 170 184 185 void performAutoResize(); 186 171 187 private slots: 172 188 173 189 void doResizeHint(); 174 void normalizeGeo() { normalizeGeometry (); }190 void normalizeGeo() { normalizeGeometry (true); } 175 191 176 192 private: -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r2495 r2700 160 160 void updateMouseState (int state); 161 161 162 void updateAdditionsState (const QString&, bool); 163 162 164 void tryClose(); 163 165 … … 246 248 247 249 CSession csession; 250 251 bool mIsAutoresizeEnabled; 248 252 249 253 // widgets -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r1889 r2700 128 128 MousePointerChangeEventType, 129 129 MachineStateChangeEventType, 130 AdditionsStateChangeEventType, 131 AutoResizeEventType, 130 132 MachineDataChangeEventType, 131 133 MachineRegisteredEventType, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r2540 r2700 225 225 }; 226 226 227 /** Guest Additions property changes. */ 228 class GuestAdditionsEvent : public QEvent 229 { 230 public: 231 GuestAdditionsEvent (const QString &aOsTypeId, 232 const QString &aAddVersion, 233 bool aAddActive) : 234 QEvent ((QEvent::Type) VBoxDefs::AdditionsStateChangeEventType), 235 mOsTypeId (aOsTypeId), mAddVersion (aAddVersion), mAddActive (aAddActive) {} 236 const QString &osTypeId() const { return mOsTypeId; } 237 const QString &additionVersion() const { return mAddVersion; } 238 bool additionActive() const { return mAddActive; } 239 private: 240 QString mOsTypeId; 241 QString mAddVersion; 242 bool mAddActive; 243 }; 244 227 245 /** Menu activation event */ 228 246 class ActivateMenuEvent : public QEvent … … 352 370 guest.GetAdditionsVersion().latin1(), 353 371 guest.GetAdditionsActive())); 354 /** @todo */ 372 QApplication::postEvent (mView, 373 new GuestAdditionsEvent ( 374 guest.GetOSTypeId(), 375 guest.GetAdditionsVersion(), 376 guest.GetAdditionsActive())); 355 377 return S_OK; 356 378 } … … 811 833 case VBoxDefs::ResizeEventType: 812 834 { 835 bool old_ignore_mainwnd_resize = ignore_mainwnd_resize; 813 836 ignore_mainwnd_resize = true; 814 837 … … 842 865 * full screen */ 843 866 if (!mainwnd->isTrueFullscreen() && 844 !topLevelWidget()->isMaximized() && 845 !resize_hint_timer->isActive()) 867 !topLevelWidget()->isMaximized()) 846 868 normalizeGeometry (true /* adjustPosition */); 847 869 … … 849 871 cconsole.GetDisplay().ResizeCompleted(); 850 872 851 ignore_mainwnd_resize = false;873 ignore_mainwnd_resize = old_ignore_mainwnd_resize; 852 874 853 875 return true; … … 912 934 onStateChange (me->machineState()); 913 935 emit machineStateChanged (me->machineState()); 936 return true; 937 } 938 939 case VBoxDefs::AdditionsStateChangeEventType: 940 { 941 GuestAdditionsEvent *ge = (GuestAdditionsEvent *) e; 942 LogFlowFunc (("AdditionsStateChangeEventType\n")); 943 emit additionsStateChanged (ge->additionVersion(), ge->additionActive()); 914 944 return true; 915 945 } … … 1004 1034 } 1005 1035 1036 case VBoxDefs::AutoResizeEventType: 1037 { 1038 performAutoResize(); 1039 return true; 1040 } 1041 1006 1042 default: 1007 1043 break; … … 1105 1141 if (autoresize_guest) 1106 1142 resize_hint_timer->start (300, TRUE); 1143 /* During window maximization WindowStateChange event is 1144 * processed before Resize event, so the ignore_mainwnd_resize 1145 * variable should be set to true here in case of mainwnd is 1146 * maximized or in fullscreen state. */ 1147 if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen()) 1148 ignore_mainwnd_resize = true; 1107 1149 } 1108 1150 break; … … 1110 1152 case QEvent::WindowStateChange: 1111 1153 { 1112 if (!mainwnd->isMinimized()) 1113 { 1114 if (!mainwnd->isMaximized()) 1115 { 1116 /* The guest screen size (and therefore the contents 1117 * size) could have been changed while we were maximized 1118 * or minimized, so normalize the main window size 1119 * unless we're in true fullscreen mode. Calling 1120 * normalizeGeometry() directly from here doesn't work 1121 * for some reason, so use a single shot timer. */ 1122 if (!mainwnd->isTrueFullscreen()) 1123 QTimer::singleShot (0, this, SLOT (normalizeGeo())); 1124 } 1125 } 1154 /* The guest screen size (and therefore the contents size) 1155 * could have been changed while we were maximized or minimized, 1156 * so posting event for auto-resize and normalization. */ 1157 if (!mainwnd->isMinimized() && 1158 !mainwnd->isMaximized() && 1159 !mainwnd->isTrueFullscreen()) 1160 QApplication::postEvent (this, new AutoResizeEvent ()); 1126 1161 } 1127 1162 … … 1483 1518 m_darwinKeyModifiers = newMask; 1484 1519 1485 /* Always return true here because we'll otherwise getting a Qt event 1520 /* Always return true here because we'll otherwise getting a Qt event 1486 1521 we don't want and that will only cause the Pause warning to pop up. */ 1487 1522 ret = true; … … 1671 1706 1672 1707 1708 } 1709 1710 void VBoxConsoleView::performAutoResize() 1711 { 1712 if (autoresize_guest) 1713 { 1714 doResizeHint(); 1715 QTimer::singleShot (200, this, SLOT (normalizeGeo())); 1716 } 1717 else 1718 { 1719 normalizeGeo(); 1720 } 1721 ignore_mainwnd_resize = false; 1673 1722 } 1674 1723 … … 2452 2501 // Note, that it's just a guess that sending RESEND will give the desired 2453 2502 // effect :), but at least it works with NT and W2k guests. 2454 /** @todo This seems to causes linux guests (in console mode) to cough a bit. 2503 /** @todo This seems to causes linux guests (in console mode) to cough a bit. 2455 2504 * We need to check if this is the cause of #1944 and/or #1949. --bird */ 2456 2505 codes [0] = 0xFE; … … 2477 2526 m_darwinKeyModifiers &= alphaLock | kEventKeyModifierNumLockMask 2478 2527 | (release_hostkey ? 0 : ::DarwinKeyCodeToDarwinModifierMask (gs.hostKey())); 2479 #endif 2528 #endif 2480 2529 2481 2530 emitKeyboardStateChanged (); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r2586 r2700 57 57 #include <qtimer.h> 58 58 59 #include <VBox/VBoxGuest.h> 60 #define VBOX_GUEST_ADDITIONS_VERSION_OK(additionsVersion) \ 61 (RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) && \ 62 RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION)) 63 59 64 #if defined(Q_WS_X11) 60 65 #include <X11/Xlib.h> … … 214 219 , dbgMenu (NULL) 215 220 #endif 221 , mIsAutoresizeEnabled (false) 216 222 , console (0) 217 223 , mUsbLedTip (0) … … 268 274 VBoxGlobal::iconSet ("auto_resize_on_16px.png", "auto_resize_on_disabled_16px.png")); 269 275 vmAutoresizeGuestAction->setToggleAction (true); 276 vmAutoresizeGuestAction->setEnabled (false); 270 277 271 278 vmAdjustWindowAction = new QAction (this, "vmAdjustWindowAction"); … … 722 729 str = cmachine.GetExtraData (GUI_AutoresizeGuest); 723 730 if (str != "off") 724 vmAutoresizeGuestAction->setOn (true);731 mIsAutoresizeEnabled = true; 725 732 726 733 str = cmachine.GetExtraData (GUI_LastWindowPosition); … … 825 832 connect (console, SIGNAL (machineStateChanged (CEnums::MachineState)), 826 833 this, SLOT (updateMachineState (CEnums::MachineState))); 834 connect (console, SIGNAL (additionsStateChanged (const QString&, bool)), 835 this, SLOT (updateAdditionsState (const QString &, bool))); 827 836 828 837 #ifdef Q_WS_MAC … … 1782 1791 if (was_max) 1783 1792 setWindowState (windowState() | WindowMaximized); 1793 QApplication::postEvent (console, new AutoResizeEvent()); 1784 1794 } 1785 1795 … … 2493 2503 } 2494 2504 2505 2506 void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion, bool aActive) 2507 { 2508 /* mIsAutoresizeEnabled flag stores the auto-resize status loaded from the 2509 * settings and used for the activation of the autoresize feature 2510 * if the additions state told us here it is activated. */ 2511 vmAutoresizeGuestAction->setEnabled (aActive); 2512 vmAutoresizeGuestAction->setOn (aActive && mIsAutoresizeEnabled); 2513 2514 /* Checking for the Guest Additions version to warn user about possible 2515 * compatibility issues in case of installed version is outdated. */ 2516 uint version = aVersion.toUInt(); 2517 bool isVersionOk = VBOX_GUEST_ADDITIONS_VERSION_OK (version); 2518 if (!isVersionOk) 2519 vboxProblem().message (this, VBoxProblemReporter::Warning, 2520 tr ("<p>Current Guest Additions version is outdated. Please install " 2521 "the latest version to avoid compatibility issues.</p>")); 2522 } 2523 2495 2524 /** 2496 2525 * Helper to safely close the main console window.
Note:
See TracChangeset
for help on using the changeset viewer.