Permalink
Browse files

Qt: Toggle fullscreen like on all other platforms.

  • Loading branch information...
unknownbrackets committed Jun 9, 2018
1 parent 82b6cda commit a448ef536b49c251f8d60cd1a30ec0c0f926c543
Showing with 38 additions and 44 deletions.
  1. +1 −6 Qt/QtMain.cpp
  2. +2 −1 Qt/QtMain.h
  3. +28 −30 Qt/mainwindow.cpp
  4. +2 −1 Qt/mainwindow.h
  5. +4 −2 UI/NativeApp.cpp
  6. +0 −3 Windows/main.cpp
  7. +1 −1 ext/native/base/NativeApp.h
View
@@ -528,12 +528,7 @@ int main(int argc, char *argv[])
savegame_dir += "/";
external_dir += "/";
bool fullscreenCLI=false;
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i],"--fullscreen"))
fullscreenCLI=true;
}
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), external_dir.c_str(), nullptr, fullscreenCLI);
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), external_dir.c_str(), nullptr);
// TODO: Support other backends than GL, like Vulkan, in the Qt backend.
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
View
@@ -110,6 +110,8 @@ class MainUI : public QGLWidget
explicit MainUI(QWidget *parent = 0);
~MainUI();
void resizeGL(int w, int h);
public slots:
QString InputBoxGetQString(QString title, QString defaultValue);
@@ -123,7 +125,6 @@ public slots:
bool event(QEvent *e);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void updateAccelerometer();
View
@@ -36,10 +36,7 @@ MainWindow::MainWindow(QWidget *parent, bool fullscreen) :
createMenus();
updateMenus();
SetWindowScale(-1);
if(fullscreen)
fullscrAct();
SetFullScreen(fullscreen);
QObject::connect(emugl, SIGNAL(doubleClick()), this, SLOT(fullscrAct()));
QObject::connect(emugl, SIGNAL(newFrame()), this, SLOT(newFrame()));
@@ -99,9 +96,6 @@ void MainWindow::updateMenus()
foreach(QAction * action, displayLayoutGroup->actions()) {
if (g_Config.iSmallDisplayZoomType == action->data().toInt()) {
NativeMessageReceived("gpu_resized", "");
action->setChecked(true);
break;
}
@@ -135,8 +129,8 @@ void MainWindow::updateMenus()
void MainWindow::bootDone()
{
if(g_Config.bFullScreen != isFullScreen())
fullscrAct();
if (g_Config.bFullScreen != isFullScreen())
SetFullScreen(g_Config.bFullScreen);
if (nextState == CORE_RUNNING)
runAct();
@@ -300,40 +294,43 @@ void MainWindow::raiseTopMost()
{
setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
raise();
activateWindow();
activateWindow();
}
void MainWindow::fullscrAct()
{
if(isFullScreen()) {
g_Config.bFullScreen = false;
menuBar()->show();
updateMenus();
showNormal();
SetWindowScale(-1);
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
}
else {
g_Config.bFullScreen = true;
void MainWindow::SetFullScreen(bool fullscreen) {
if (fullscreen) {
menuBar()->hide();
emugl->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
emugl->resizeGL(emugl->size().width(), emugl->size().height());
// TODO: Won't showFullScreen do this for us?
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
showFullScreen();
NativeMessageReceived("gpu_resized", "");
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && !g_Config.bShowTouchControls)
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
} else {
menuBar()->show();
updateMenus();
showNormal();
SetWindowScale(-1);
InitPadLayout(dp_xres, dp_yres);
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
}
}
void MainWindow::fullscrAct()
{
// Toggle the current state.
g_Config.bFullScreen = !isFullScreen();
SetFullScreen(g_Config.bFullScreen);
QTimer::singleShot(1000, this, SLOT(raiseTopMost()));
}
@@ -396,6 +393,7 @@ void MainWindow::SetWindowScale(int zoom) {
g_Config.iWindowHeight = height;
emugl->setFixedSize(g_Config.iWindowWidth, g_Config.iWindowHeight);
emugl->resizeGL(g_Config.iWindowWidth, g_Config.iWindowHeight);
setFixedSize(sizeHint());
}
View
@@ -30,7 +30,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0, bool fullscreen=false);
explicit MainWindow(QWidget *parent = nullptr, bool fullscreen = false);
~MainWindow() { };
CoreState GetNextState() { return nextState; }
@@ -144,6 +144,7 @@ private slots:
void bootDone();
void SetWindowScale(int zoom);
void SetGameTitle(QString text);
void SetFullScreen(bool fullscreen);
void loadLanguage(const QString &language, bool retranslate);
void createMenus();
View
@@ -345,7 +345,7 @@ void CreateDirectoriesAndroid() {
File::CreateEmptyFile(g_Config.memStickDirectory + "PSP/SAVEDATA/.nomedia");
}
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs) {
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir) {
net::Init(); // This needs to happen before we load the config. So on Windows we also run it in Main. It's fine to call multiple times.
InitFastMath(cpu_info.bNEON);
@@ -474,6 +474,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
#endif
if (!strncmp(argv[i], "--pause-menu-exit", strlen("--pause-menu-exit")))
g_Config.bPauseMenuExitsEmulator = true;
if (!strcmp(argv[i], "--fullscreen"))
g_Config.bFullScreen = true;
break;
}
} else {
@@ -615,7 +617,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
isOuya = KeyMap::IsOuya(sysName);
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
MainWindow* mainWindow = new MainWindow(0,fs);
MainWindow *mainWindow = new MainWindow(nullptr, g_Config.bFullScreen);
mainWindow->show();
if (host == nullptr) {
host = new QtHost(mainWindow);
View
@@ -458,9 +458,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
break;
}
if (wideArgs[i] == L"--fullscreen")
g_Config.bFullScreen = true;
if (wideArgs[i] == L"--windowed")
g_Config.bFullScreen = false;
@@ -45,7 +45,7 @@ bool NativeIsAtTopLevel();
// The very first function to be called after NativeGetAppInfo. Even NativeMix is not called
// before this, although it may be called at any point in time afterwards (on any thread!)
// This functions must NOT call OpenGL. Main thread.
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs=false);
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir);
// Runs after NativeInit() at some point. May (and probably should) call OpenGL.
// Should not initialize anything screen-size-dependent - do that in NativeResized.

0 comments on commit a448ef5

Please sign in to comment.