Merge pull request #2451 from Cacodemon345/multimonitor-take2-ui

qt: Fix performance regression
This commit is contained in:
Miran Grča
2022-07-12 14:31:20 +02:00
committed by GitHub
10 changed files with 48 additions and 110 deletions

View File

@@ -125,6 +125,7 @@ main_thread_fn()
}
is_quit = 1;
QTimer::singleShot(0, QApplication::instance(), [] () { QApplication::instance()->quit(); });
}
static std::thread* main_thread;
@@ -284,28 +285,6 @@ int main(int argc, char* argv[]) {
main_thread = new std::thread(main_thread_fn);
});
QTimer resizeTimer;
resizeTimer.setInterval(0);
resizeTimer.callOnTimeout([]()
{
/* If needed, handle a screen resize. */
for (int i = 0; i < MONITORS_NUM; i++) {
if (!monitors[i].target_buffer) continue;
if (atomic_load(&doresize_monitors[i]) == 1 && !video_fullscreen && !is_quit) {
if (vid_resize & 2)
plat_resize_monitor(fixed_size_x, fixed_size_y, i);
else
plat_resize_monitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
atomic_store(&doresize_monitors[i], 0);
}
}
if (is_quit) {
QApplication::quit();
}
});
resizeTimer.start();
auto ret = app.exec();
cpu_thread_run = 0;
main_thread->join();

View File

@@ -40,6 +40,7 @@ extern "C" {
#include <86box/plat.h>
#include <86box/ui.h>
#include <86box/discord.h>
#include <86box/device.h>
#include <86box/video.h>
#include <86box/machine.h>
#include <86box/vid_ega.h>
@@ -228,6 +229,7 @@ MainWindow::MainWindow(QWidget *parent) :
});
connect(this, &MainWindow::resizeContents, this, [this](int w, int h) {
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) {
w = (w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.));
@@ -629,7 +631,6 @@ MainWindow::~MainWindow() {
void MainWindow::showEvent(QShowEvent *event) {
if (shownonce) return;
shownonce = true;
if (window_remember) resize(window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
if (window_remember && !QApplication::platformName().contains("wayland")) {
setGeometry(window_x, window_y, window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
}
@@ -644,10 +645,8 @@ void MainWindow::showEvent(QShowEvent *event) {
}
if (window_remember && vid_resize == 1) {
ui->stackedWidget->setFixedSize(window_w, window_h);
adjustSize();
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
monitors[0].mon_scrnsz_x = window_w;
monitors[0].mon_scrnsz_y = window_h;
QApplication::processEvents();
this->adjustSize();
}
}

View File

@@ -33,6 +33,7 @@ extern "C" {
#include <86box/timer.h>
#include <86box/plat.h>
#include <86box/cassette.h>
#include <86box/machine.h>
#include <86box/cartridge.h>
#include <86box/fdd.h>
#include <86box/fdd_86f.h>

View File

@@ -32,6 +32,7 @@ static QString sb_text, sb_buguitext, sb_mt32lcdtext;
extern "C" {
#include "86box/86box.h"
#include <86box/plat.h>
#include <86box/ui.h>
#include <86box/mouse.h>
@@ -64,6 +65,18 @@ void mouse_poll() {
main_window->pollMouse();
}
extern "C" int vid_resize;
void plat_resize_request(int w, int h, int monitor_index)
{
if (video_fullscreen || is_quit) return;
if (vid_resize & 2) {
plat_resize_monitor(fixed_size_x, fixed_size_y, monitor_index);
}
else {
plat_resize_monitor(w, h, monitor_index);
}
}
void plat_resize_monitor(int w, int h, int monitor_index) {
if (monitor_index >= 1) main_window->resizeContentsMonitor(w, h, monitor_index);
else main_window->resizeContents(w, h);