qt: Implement per-monitor resizing

This commit is contained in:
Cacodemon345
2022-07-04 17:54:38 +06:00
parent 7ab71cafd3
commit e8ffc699ba
9 changed files with 51 additions and 18 deletions

View File

@@ -122,14 +122,6 @@ main_thread_fn()
/* Just so we dont overload the host OS. */
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
/* If needed, handle a screen resize. */
if (!atomic_flag_test_and_set(&doresize) && !video_fullscreen && !is_quit) {
if (vid_resize & 2)
plat_resize_monitor(fixed_size_x, fixed_size_y, 0);
else
plat_resize_monitor(scrnsz_x, scrnsz_y, 0);
}
}
is_quit = 1;
@@ -292,6 +284,22 @@ 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 (!atomic_flag_test_and_set(&doresize_monitors[i]) && !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);
}
}
});
resizeTimer.start();
auto ret = app.exec();
cpu_thread_run = 0;
main_thread->join();