void Utility::resizeMainWindow() { unsigned region = config().video.context->region; unsigned multiplier = config().video.context->multiplier; unsigned width = 256 * multiplier; unsigned height = (region == 0 ? 224 : 239) * multiplier; if(config().video.context->correctAspectRatio) { if(region == 0) { width = (double)width * config().video.ntscAspectRatio + 0.5; //NTSC adjust } else { width = (double)width * config().video.palAspectRatio + 0.5; //PAL adjust } } if(config().video.isFullscreen == false) { //get effective desktop work area region (ignore Windows taskbar, OS X dock, etc.) QRect deskRect = QApplication::desktop()->availableGeometry(mainWindow); //ensure window size will not be larger than viewable desktop area constrainSize(height, width, deskRect.height()); //- frameHeight); constrainSize(width, height, deskRect.width()); //- frameWidth ); mainWindow->canvas->setFixedSize(width, height); mainWindow->show(); } else { for(unsigned i = 0; i < 2; i++) { unsigned iWidth = width, iHeight = height; constrainSize(iHeight, iWidth, mainWindow->canvasContainer->size().height()); constrainSize(iWidth, iHeight, mainWindow->canvasContainer->size().width()); //center canvas onscreen; ensure it is not larger than viewable area mainWindow->canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mainWindow->canvas->setFixedSize(iWidth, iHeight); mainWindow->canvas->setMinimumSize(0, 0); usleep(2000); QApplication::processEvents(); } } //workaround for Qt/Xlib bug: //if window resize occurs with cursor over it, Qt shows Qt::Size*DiagCursor; //so force it to show Qt::ArrowCursor, as expected mainWindow->setCursor(Qt::ArrowCursor); mainWindow->canvasContainer->setCursor(Qt::ArrowCursor); mainWindow->canvas->setCursor(Qt::ArrowCursor); //workaround for DirectSound(?) bug: //window resizing sometimes breaks audio sync, this call re-initializes it updateAvSync(); }
void Utility::resizeMainWindow() { for(unsigned i = 0; i < 8; i++) { unsigned multiplier = config.video.context->multiplier; unsigned width = 256 * config.video.context->multiplier; unsigned height = (config.video.context->region == 0 ? 224 : 239) * config.video.context->multiplier; if(config.video.context->correctAspectRatio) { if(config.video.context->region == 0) { width = (double)width * config.video.ntscAspectRatio + 0.5; //NTSC adjust } else { width = (double)width * config.video.palAspectRatio + 0.5; //PAL adjust } } if(config.video.isFullscreen == false) { //get effective desktop work area region (ignore Windows taskbar, OS X dock, etc.) QRect deskRect = QApplication::desktop()->availableGeometry(mainWindow->window); if(mainWindow->window->isVisible() == false) { #if defined(PLATFORM_X) mainWindow->window->showMinimized(); #elif defined(PLATFORM_OSX) mainWindow->window->showNormal(); #elif defined(PLATFORM_WIN) mainWindow->window->move(std::numeric_limits<signed>::max(), std::numeric_limits<signed>::max()); mainWindow->window->showNormal(); #endif } //calculate frame geometry (window border + menubar + statusbar) unsigned frameWidth = mainWindow->window->frameSize().width() - mainWindow->canvasContainer->size().width(); unsigned frameHeight = mainWindow->window->frameSize().height() - mainWindow->canvasContainer->size().height(); //ensure window size will not be larger than viewable desktop area constrainSize(height, width, deskRect.height() - frameHeight); constrainSize(width, height, deskRect.width() - frameWidth ); //resize window such that it is as small as possible to hold canvas of size (width, height) mainWindow->canvas->setFixedSize(width, height); mainWindow->window->resize(0, 0); //center window onscreen mainWindow->window->move( deskRect.center().x() - (mainWindow->window->frameSize().width() / 2), deskRect.center().y() - (mainWindow->window->frameSize().height() / 2) ); } else { constrainSize(height, width, mainWindow->canvasContainer->size().height()); constrainSize(width, height, mainWindow->canvasContainer->size().width()); //center canvas onscreen; ensure it is not larger than viewable area mainWindow->canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mainWindow->canvas->setFixedSize(width, height); mainWindow->canvas->setMinimumSize(0, 0); } application.processEvents(); usleep(2000); } //workaround for Qt/Xlib bug: //if window resize occurs with cursor over it, Qt shows Qt::Size*DiagCursor; //so force it to show Qt::ArrowCursor, as expected mainWindow->window->setCursor(Qt::ArrowCursor); mainWindow->canvasContainer->setCursor(Qt::ArrowCursor); mainWindow->canvas->setCursor(Qt::ArrowCursor); //workaround for DirectSound(?) bug: //window resizing sometimes breaks audio sync, this call re-initializes it updateAvSync(); }
void Utility::toggleSynchronizeAudio() { mainWindow->settings_emulationSpeed_syncAudio->toggleChecked(); config().audio.synchronize = mainWindow->settings_emulationSpeed_syncAudio->isChecked(); updateAvSync(); }