From c0c873151b6f1ca020e751b900349d7aeec48f9f Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 10 Jul 2022 11:41:02 +0600 Subject: [PATCH] qt: Add Show non-primary monitors option --- src/86box.c | 1 + src/config.c | 6 +++++ src/include/86box/machine.h | 1 + src/include/86box/video.h | 1 + src/qt/qt_mainwindow.cpp | 54 +++++++++++++++++++++++++++++++------ src/qt/qt_mainwindow.hpp | 3 +++ src/qt/qt_mainwindow.ui | 11 +++++++- src/qt/qt_rendererstack.cpp | 2 +- 8 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/86box.c b/src/86box.c index 08b4f57cc..a1d921e0e 100644 --- a/src/86box.c +++ b/src/86box.c @@ -163,6 +163,7 @@ int isamem_type[ISAMEM_MAX] = { 0,0,0,0 }; /* (C) enable ISA mem cards */ int isartc_type = 0; /* (C) enable ISA RTC card */ int gfxcard = 0; /* (C) graphics/video card */ int gfxcard_2 = 0; /* (C) graphics/video card */ +int show_second_monitors = 1; /* (C) show non-primary monitors */ int sound_is_float = 1; /* (C) sound uses FP values */ int GAMEBLASTER = 0; /* (C) sound option */ int GUS = 0; /* (C) sound option */ diff --git a/src/config.c b/src/config.c index 61fbec740..eea247e3f 100644 --- a/src/config.c +++ b/src/config.c @@ -926,6 +926,7 @@ load_video(void) voodoo_enabled = !!config_get_int(cat, "voodoo", 0); ibm8514_enabled = !!config_get_int(cat, "8514a", 0); xga_enabled = !!config_get_int(cat, "xga", 0); + show_second_monitors = !!config_get_int(cat, "show_second_monitors", 1); p = config_get_string(cat, "gfxcard_2", NULL); if (!p) p = "none"; gfxcard_2 = video_get_video_from_internal_name(p); @@ -2519,6 +2520,11 @@ save_video(void) else config_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard_2)); + if (show_second_monitors == 1) + config_delete_var(cat, "show_second_monitors"); + else + config_set_int(cat, "show_second_monitors", show_second_monitors); + delete_section_if_empty(cat); } diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index fae7fb587..3050fc2b6 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -779,6 +779,7 @@ extern int machine_ps2_model_55sx_init(const machine_t *); extern int machine_ps2_model_70_type3_init(const machine_t *); extern int machine_ps2_model_80_init(const machine_t *); extern int machine_ps2_model_80_axx_init(const machine_t *); +extern int machine_ps2_model_80_axx_cust_init(const machine_t *); /* m_tandy.c */ extern int tandy1k_eeprom_read(void); diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 5b9f9ab13..2847a7cb4 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -135,6 +135,7 @@ extern monitor_settings_t monitor_settings[MONITORS_NUM]; extern atomic_bool doresize_monitors[MONITORS_NUM]; extern int monitor_index_global; extern int gfxcard_2; +extern int show_second_monitors; typedef rgb_t PALETTE[256]; diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 11ad7ca61..aa0f874fd 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -62,6 +62,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -276,6 +277,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionHiDPI_scaling->setChecked(dpi_scale); ui->actionHide_status_bar->setChecked(hide_status_bar); ui->actionHide_tool_bar->setChecked(hide_tool_bar); + ui->actionShow_non_primary_monitors->setChecked(show_second_monitors); ui->actionUpdate_status_bar_icons->setChecked(update_icons); ui->actionEnable_Discord_integration->setChecked(enable_discord); @@ -589,15 +591,18 @@ void MainWindow::initRendererMonitorSlot(int monitor_index) if (vid_resize == 2) { secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y); } - secondaryRenderer->show(); - if (window_remember) { - secondaryRenderer->setGeometry(monitor_settings[monitor_index].mon_window_x < 120 ? 120 : monitor_settings[monitor_index].mon_window_x, - monitor_settings[monitor_index].mon_window_y < 120 ? 120 : monitor_settings[monitor_index].mon_window_y, - monitor_settings[monitor_index].mon_window_w > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_w, - monitor_settings[monitor_index].mon_window_h > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_h); - } - secondaryRenderer->switchRenderer((RendererStack::Renderer)vid_api); secondaryRenderer->setWindowIcon(this->windowIcon()); + if (show_second_monitors) { + secondaryRenderer->show(); + if (window_remember) { + secondaryRenderer->setGeometry(monitor_settings[monitor_index].mon_window_x < 120 ? 120 : monitor_settings[monitor_index].mon_window_x, + monitor_settings[monitor_index].mon_window_y < 120 ? 120 : monitor_settings[monitor_index].mon_window_y, + monitor_settings[monitor_index].mon_window_w > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_w, + monitor_settings[monitor_index].mon_window_h > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_h); + } + secondaryRenderer->switchRenderer((RendererStack::Renderer)vid_api); + } + } } @@ -2009,3 +2014,36 @@ void MainWindow::on_actionMCA_devices_triggered() dlg->exec(); } + +void MainWindow::on_actionShow_non_primary_monitors_triggered() +{ + show_second_monitors ^= 1; + + if (show_second_monitors) { + for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) { + auto& secondaryRenderer = renderers[monitor_index]; + if (!renderers[monitor_index]) continue; + secondaryRenderer->show(); + if (window_remember) { + secondaryRenderer->setGeometry(monitor_settings[monitor_index].mon_window_x < 120 ? 120 : monitor_settings[monitor_index].mon_window_x, + monitor_settings[monitor_index].mon_window_y < 120 ? 120 : monitor_settings[monitor_index].mon_window_y, + monitor_settings[monitor_index].mon_window_w > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_w, + monitor_settings[monitor_index].mon_window_h > 2048 ? 2048 : monitor_settings[monitor_index].mon_window_h); + } + secondaryRenderer->switchRenderer((RendererStack::Renderer)vid_api); + } + } else { + for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) { + auto& secondaryRenderer = renderers[monitor_index]; + if (!renderers[monitor_index]) continue; + secondaryRenderer->hide(); + if (window_remember && renderers[monitor_index]) { + monitor_settings[monitor_index].mon_window_w = renderers[monitor_index]->geometry().width(); + monitor_settings[monitor_index].mon_window_h = renderers[monitor_index]->geometry().height(); + monitor_settings[monitor_index].mon_window_x = renderers[monitor_index]->geometry().x(); + monitor_settings[monitor_index].mon_window_y = renderers[monitor_index]->geometry().y(); + } + } + } +} + diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 5279d8997..37468c413 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -123,6 +123,9 @@ protected: void closeEvent(QCloseEvent* event) override; void changeEvent(QEvent* event) override; +private slots: + void on_actionShow_non_primary_monitors_triggered(); + private: Ui::MainWindow *ui; std::unique_ptr status; diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 6d48cb596..f077f7e97 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -54,7 +54,7 @@ 0 0 724 - 21 + 23 @@ -161,6 +161,7 @@ + @@ -757,6 +758,14 @@ 5 + + + true + + + Show non-primary monitors + + diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 3082c8a73..ae451db6c 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -447,7 +447,7 @@ RendererStack::blitCommon(int x, int y, int w, int h) void RendererStack::closeEvent(QCloseEvent* event) { - if (cpu_thread_run == 0 || is_quit == 0) { event->accept(); return; } + if (cpu_thread_run == 0 || is_quit == 1) { event->accept(); return; } event->ignore(); main_window->close(); }