Fix window coordinate saving and loading
This commit is contained in:
@@ -938,12 +938,12 @@ load_monitor(int monitor_index)
|
|||||||
|
|
||||||
if (monitor_index == 0) {
|
if (monitor_index == 0) {
|
||||||
/* Migrate configs */
|
/* Migrate configs */
|
||||||
ptr = config_get_string("General", "window_coordinates", "0, 0, 0, 0");
|
ptr = config_get_string("General", "window_coordinates", NULL);
|
||||||
|
|
||||||
config_delete_var("General", "window_coordinates");
|
config_delete_var("General", "window_coordinates");
|
||||||
}
|
}
|
||||||
if (!ptr) ptr = config_get_string(monitor_config_name, "window_coordinates", "0, 0, 0, 0");
|
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
||||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
if (!ptr) ptr = config_get_string(monitor_config_name, "window_coordinates", "0, 0, 0, 0");
|
||||||
if (window_remember || (vid_resize & 2)) sscanf(ptr, "%i, %i, %i, %i",
|
if (window_remember || (vid_resize & 2)) sscanf(ptr, "%i, %i, %i, %i",
|
||||||
&monitor_settings[monitor_index].mon_window_x, &monitor_settings[monitor_index].mon_window_y,
|
&monitor_settings[monitor_index].mon_window_x, &monitor_settings[monitor_index].mon_window_y,
|
||||||
&monitor_settings[monitor_index].mon_window_w, &monitor_settings[monitor_index].mon_window_h);
|
&monitor_settings[monitor_index].mon_window_w, &monitor_settings[monitor_index].mon_window_h);
|
||||||
|
@@ -32,6 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
void HardwareRenderer::resizeGL(int w, int h)
|
void HardwareRenderer::resizeGL(int w, int h)
|
||||||
{
|
{
|
||||||
|
m_context->makeCurrent(this);
|
||||||
glViewport(0, 0, qRound(w * devicePixelRatio()), qRound(h * devicePixelRatio()));
|
glViewport(0, 0, qRound(w * devicePixelRatio()), qRound(h * devicePixelRatio()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -298,12 +298,17 @@ int main(int argc, char* argv[]) {
|
|||||||
plat_resize_monitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
|
plat_resize_monitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_quit) {
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
resizeTimer.start();
|
resizeTimer.start();
|
||||||
|
|
||||||
auto ret = app.exec();
|
auto ret = app.exec();
|
||||||
cpu_thread_run = 0;
|
cpu_thread_run = 0;
|
||||||
main_thread->join();
|
main_thread->join();
|
||||||
|
pc_close(nullptr);
|
||||||
|
|
||||||
socket.close();
|
socket.close();
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -550,18 +550,26 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||||||
window_x = this->geometry().x();
|
window_x = this->geometry().x();
|
||||||
window_y = this->geometry().y();
|
window_y = this->geometry().y();
|
||||||
}
|
}
|
||||||
|
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||||
|
if (renderers[i]) {
|
||||||
|
monitor_settings[i].mon_window_w = renderers[i]->geometry().width();
|
||||||
|
monitor_settings[i].mon_window_h = renderers[i]->geometry().height();
|
||||||
|
if (!QApplication::platformName().contains("wayland")) continue;
|
||||||
|
monitor_settings[i].mon_window_x = renderers[i]->geometry().x();
|
||||||
|
monitor_settings[i].mon_window_y = renderers[i]->geometry().y();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qt_nvr_save();
|
|
||||||
config_save();
|
|
||||||
|
|
||||||
if (ui->stackedWidget->mouse_exit_func)
|
if (ui->stackedWidget->mouse_exit_func)
|
||||||
ui->stackedWidget->mouse_exit_func();
|
ui->stackedWidget->mouse_exit_func();
|
||||||
|
|
||||||
ui->stackedWidget->switchRenderer(RendererStack::Renderer::Software);
|
ui->stackedWidget->switchRenderer(RendererStack::Renderer::Software);
|
||||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
|
||||||
if (renderers[i]) renderers[i]->close();
|
qt_nvr_save();
|
||||||
}
|
config_save();
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
cpu_thread_run = 0;
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,16 +585,17 @@ void MainWindow::initRendererMonitorSlot(int monitor_index)
|
|||||||
});
|
});
|
||||||
secondaryRenderer->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
secondaryRenderer->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
secondaryRenderer->setWindowTitle(QObject::tr("86Box Monitor #") + QString::number(monitor_index + 1));
|
secondaryRenderer->setWindowTitle(QObject::tr("86Box Monitor #") + QString::number(monitor_index + 1));
|
||||||
if (window_remember) {
|
|
||||||
secondaryRenderer->setGeometry(monitor_settings[monitor_index].mon_window_x,
|
|
||||||
monitor_settings[monitor_index].mon_window_y,
|
|
||||||
monitor_settings[monitor_index].mon_window_w,
|
|
||||||
monitor_settings[monitor_index].mon_window_h);
|
|
||||||
}
|
|
||||||
if (vid_resize == 2) {
|
if (vid_resize == 2) {
|
||||||
secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y);
|
secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y);
|
||||||
}
|
}
|
||||||
secondaryRenderer->show();
|
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->switchRenderer((RendererStack::Renderer)vid_api);
|
||||||
secondaryRenderer->setWindowIcon(this->windowIcon());
|
secondaryRenderer->setWindowIcon(this->windowIcon());
|
||||||
}
|
}
|
||||||
@@ -614,6 +623,7 @@ void MainWindow::showEvent(QShowEvent *event) {
|
|||||||
if (shownonce) return;
|
if (shownonce) return;
|
||||||
shownonce = true;
|
shownonce = true;
|
||||||
if (window_remember && !QApplication::platformName().contains("wayland")) {
|
if (window_remember && !QApplication::platformName().contains("wayland")) {
|
||||||
|
fprintf(stderr, "Geom: %i, %i, %i, %i\n", window_x, window_y, window_w, window_h);
|
||||||
setGeometry(window_x, window_y, window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
|
setGeometry(window_x, window_y, window_w, window_h + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
|
||||||
}
|
}
|
||||||
if (vid_resize == 2) {
|
if (vid_resize == 2) {
|
||||||
@@ -625,13 +635,6 @@ void MainWindow::showEvent(QShowEvent *event) {
|
|||||||
monitors[0].mon_scrnsz_x = fixed_size_x;
|
monitors[0].mon_scrnsz_x = fixed_size_x;
|
||||||
monitors[0].mon_scrnsz_y = fixed_size_y;
|
monitors[0].mon_scrnsz_y = fixed_size_y;
|
||||||
}
|
}
|
||||||
else 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionKeyboard_requires_capture_triggered() {
|
void MainWindow::on_actionKeyboard_requires_capture_triggered() {
|
||||||
@@ -1603,7 +1606,6 @@ void MainWindow::on_actionResizable_window_triggered(bool checked) {
|
|||||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||||
if (monitors[i].target_buffer) {
|
if (monitors[i].target_buffer) {
|
||||||
renderers[i]->setWindowFlag(Qt::WindowMaximizeButtonHint);
|
renderers[i]->setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||||
renderers[i]->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, false);
|
|
||||||
renderers[i]->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
renderers[i]->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1613,8 +1615,7 @@ void MainWindow::on_actionResizable_window_triggered(bool checked) {
|
|||||||
setWindowFlag(Qt::MSWindowsFixedSizeDialogHint);
|
setWindowFlag(Qt::MSWindowsFixedSizeDialogHint);
|
||||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||||
if (monitors[i].target_buffer) {
|
if (monitors[i].target_buffer) {
|
||||||
renderers[i]->setWindowFlag(Qt::WindowMaximizeButtonHint);
|
renderers[i]->setWindowFlag(Qt::WindowMaximizeButtonHint, false);
|
||||||
renderers[i]->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, false);
|
|
||||||
emit resizeContentsMonitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
|
emit resizeContentsMonitor(monitors[i].mon_scrnsz_x, monitors[i].mon_scrnsz_y, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1851,6 +1852,14 @@ void MainWindow::on_actionRemember_size_and_position_triggered()
|
|||||||
window_x = geometry().x();
|
window_x = geometry().x();
|
||||||
window_y = geometry().y();
|
window_y = geometry().y();
|
||||||
}
|
}
|
||||||
|
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||||
|
if (window_remember && renderers[i]) {
|
||||||
|
monitor_settings[i].mon_window_w = renderers[i]->geometry().width();
|
||||||
|
monitor_settings[i].mon_window_h = renderers[i]->geometry().height();
|
||||||
|
monitor_settings[i].mon_window_x = renderers[i]->geometry().x();
|
||||||
|
monitor_settings[i].mon_window_y = renderers[i]->geometry().y();
|
||||||
|
}
|
||||||
|
}
|
||||||
ui->actionRemember_size_and_position->setChecked(window_remember);
|
ui->actionRemember_size_and_position->setChecked(window_remember);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user