Changeset 7435 in vbox
- Timestamp:
- Mar 12, 2008 4:01:15 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 28873
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h
r7407 r7435 189 189 private: 190 190 191 void sendInitialSizeHint(void); 191 192 void maybeRestrictMinimumSize(); 192 193 … … 280 281 CGImageRef mVirtualBoxLogo; 281 282 #endif 283 QSize mLastSizeHint; 282 284 }; 283 285 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h
r7188 r7435 168 168 static const char* GUI_LastVMSelected; 169 169 static const char* GUI_InfoDlgState; 170 static const char* GUI_LastSizeHint; 170 171 }; 171 172 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r7407 r7435 2857 2857 } 2858 2858 } 2859 else if (mLastState == KMachineState_Starting) 2860 { 2861 /* Suggest an initial size. */ 2862 sendInitialSizeHint (); 2863 } 2859 2864 /* reuse the focus event handler to capture input */ 2860 2865 if (hasFocus()) 2861 2866 focusEvent (true /* aHasFocus */); 2862 2867 break; 2868 } 2869 case KMachineState_Stopping: 2870 { 2871 if (mLastSizeHint.isValid()) 2872 { 2873 CMachine cmachine = mConsole.GetMachine(); 2874 QString str = QString ("%1,%2") 2875 .arg (mLastSizeHint.width()) 2876 .arg (mLastSizeHint.height()); 2877 cmachine.SetExtraData (VBoxDefs::GUI_LastSizeHint, str); 2878 } 2863 2879 } 2864 2880 default: … … 3563 3579 3564 3580 mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0); 3565 } 3581 mLastSizeHint = sz; 3582 } 3583 } 3584 3585 3586 /** 3587 * We send an initial size hint to the VM on startup, so that it can choose 3588 * an initial size which is well-readable on the host screen. 3589 */ 3590 void VBoxConsoleView::sendInitialSizeHint(void) 3591 { 3592 CMachine cmachine = mConsole.GetMachine(); 3593 QString str = cmachine.GetExtraData (VBoxDefs::GUI_LastSizeHint); 3594 int w = 0, h = 0; 3595 bool ok = true; 3596 w = str.section (',', 0, 0).toInt (&ok); 3597 if (ok) 3598 h = str.section (',', 1, 1).toInt (&ok); 3599 QRect screen = QApplication::desktop()->screenGeometry (this); 3600 if (!ok || w > screen.width() || h > screen.height()) 3601 { 3602 enum { NUM_RES = 4 }; 3603 const int sizeList[NUM_RES][2] = 3604 { 3605 { 640, 480 }, 3606 { 800, 600 }, 3607 { 1024, 768 }, 3608 { 1280, 960 } 3609 }; 3610 unsigned i = 0; 3611 3612 /* Find a size that is smaller than three quarters of the reported 3613 screen geometry. */ 3614 while ( (i + 1 < NUM_RES) 3615 && (sizeList[i + 1][0] < screen.width() * 3 / 4) 3616 && (sizeList[i + 1][1] < screen.height() * 3 / 4)) 3617 ++i; 3618 w = sizeList[i][0]; 3619 h = sizeList[i][1]; 3620 } 3621 LogFlowFunc (("Will suggest %d x %d\n", w, h)); 3622 mConsole.GetDisplay().SetVideoModeHint (w, h, 0, 0); 3566 3623 } 3567 3624 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp
r7188 r7435 36 36 const char* VBoxDefs::GUI_LastVMSelected = "GUI/LastVMSelected"; 37 37 const char* VBoxDefs::GUI_InfoDlgState = "GUI/InfoDlgState"; 38 const char* VBoxDefs::GUI_LastSizeHint = "GUI/LastSizeHint";
Note:
See TracChangeset
for help on using the changeset viewer.