Screen Resizing: workaround for layout changes not resizing properly

This commit is contained in:
Vitor Kiguchi 2020-12-11 23:11:24 -03:00
parent 6f209424ca
commit 07a7a86cf5
2 changed files with 14 additions and 3 deletions

View File

@ -1677,7 +1677,8 @@ void GMainWindow::ToggleWindowMode() {
} }
} }
void GMainWindow::ResizeScreen(const int scale) { void GMainWindow::ResizeScreen() {
const int scale = UISettings::values.fixed_screen_size;
if (!scale || !emulation_running) { if (!scale || !emulation_running) {
return; return;
} }
@ -1714,9 +1715,19 @@ void GMainWindow::ChangeScreenSize() {
new_scale = 4; new_scale = 4;
} }
const bool needs_workaround = UISettings::values.fixed_screen_size == 1 && new_scale == 1;
UISettings::values.fixed_screen_size = new_scale; UISettings::values.fixed_screen_size = new_scale;
ResizeScreen(new_scale); ResizeScreen();
if (needs_workaround) {
// Workaround for a bug when the layout is switched to one
// with a smaller minimum size, which would make the window
// not resize properly, when in 1x.
// TODO (vitor-k): repro and report to Qt and/or find a
// better workaround
QTimer::singleShot(100, this, &GMainWindow::ResizeScreen);
}
} }
void GMainWindow::ChangeScreenLayout() { void GMainWindow::ChangeScreenLayout() {

View File

@ -120,7 +120,7 @@ private:
void ConnectWidgetEvents(); void ConnectWidgetEvents();
void ConnectMenuEvents(); void ConnectMenuEvents();
void ResizeScreen(int scale); void ResizeScreen();
void UncheckWindowSize(); void UncheckWindowSize();
void PreventOSSleep(); void PreventOSSleep();