return to single-window fullscreening behavior

This commit is contained in:
David Griswold 2026-05-26 21:10:00 +03:00
parent 4567ab5fa9
commit 81a97a27f2
2 changed files with 28 additions and 39 deletions

View File

@ -552,11 +552,6 @@ void GMainWindow::InitializeWidgets() {
secondary_window->hide();
secondary_window->setParent(nullptr);
action_secondary_fullscreen = new QAction(secondary_window);
action_secondary_toggle_screen = new QAction(secondary_window);
action_secondary_swap_screen = new QAction(secondary_window);
action_secondary_rotate_screen = new QAction(secondary_window);
game_list = new GameList(*play_time_manager, this);
ui->horizontalLayout->addWidget(game_list);
@ -912,10 +907,15 @@ void GMainWindow::InitializeHotkeys() {
connect_shortcut(QStringLiteral("Toggle Screen Layout"), &GMainWindow::ToggleScreenLayout);
connect_shortcut(QStringLiteral("Exit Fullscreen"), [&] {
if (emulation_running) {
ui->action_Fullscreen->setChecked(false);
ToggleFullscreen();
if (secondary_window->isActiveWindow()) {
secondary_window->showNormal();
} else {
ui->action_Fullscreen->setChecked(false);
ToggleFullscreen();
}
}
});
connect_shortcut(QStringLiteral("Toggle Per-Application Speed"), [&] {
if (!hotkey_registry
.GetKeySequence(QStringLiteral("Main Window"), QStringLiteral("Toggle Turbo Mode"))
@ -966,16 +966,6 @@ void GMainWindow::InitializeHotkeys() {
UpdateStatusBar();
}
});
// Secondary Window QAction Hotkeys
const auto add_secondary_window_hotkey = [this](QAction* action, QKeySequence hotkey,
const char* slot) {
// This action will fire specifically when secondary_window is in focus
action->setShortcut(hotkey);
disconnect(action, SIGNAL(triggered()), this, slot);
connect(action, SIGNAL(triggered()), this, slot);
secondary_window->addAction(action);
};
}
void GMainWindow::SetDefaultUIGeometry() {
@ -2669,10 +2659,16 @@ void GMainWindow::ToggleFullscreen() {
if (!emulation_running) {
return;
}
if (ui->action_Fullscreen->isChecked()) {
ShowFullscreen();
if (secondary_window->isVisible() && secondary_window->isActiveWindow()) {
// undo the action and fullscreen secondary manually
ui->action_Fullscreen->toggle();
ToggleSecondaryFullscreen();
} else {
HideFullscreen();
if (ui->action_Fullscreen->isChecked()) {
ShowFullscreen();
} else {
HideFullscreen();
}
}
}
@ -2684,19 +2680,19 @@ void GMainWindow::ToggleSecondaryFullscreen() {
#ifdef NEEDS_ROUND_CORNERS_FIX
WindowCornerManager::instance().blockRoundedCorners(secondary_window, false);
#endif
secondary_window->restoreGeometry(UISettings::values.secondarywindow_geometry);
secondary_window->showNormal();
} else {
#ifdef NEEDS_ROUND_CORNERS_FIX
WindowCornerManager::instance().blockRoundedCorners(secondary_window, true);
#endif
UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry();
LOG_INFO(Frontend, "Attempting to fullscreen secondary window");
secondary_window->showFullScreen();
}
}
void GMainWindow::ShowFullscreen() {
QWidget* window_to_change =
ui->action_Single_Window_Mode->isChecked() ? static_cast<QWidget*>(this) : render_window;
if (ui->action_Single_Window_Mode->isChecked()) {
UISettings::values.geometry = saveGeometry();
ui->menubar->hide();
@ -2710,16 +2706,7 @@ void GMainWindow::ShowFullscreen() {
#ifdef NEEDS_ROUND_CORNERS_FIX
WindowCornerManager::instance().blockRoundedCorners(render_window, true);
#endif
}
bool secondary_on_same = window_to_change->screen() == secondary_window->screen();
window_to_change->showFullScreen();
// try to fullscreen the second window if it is visible and on a different screen from main
if (secondary_window->isVisible() && !secondary_on_same) {
UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry();
LOG_INFO(Frontend, "Attempting to fullscreen secondary window");
secondary_window->showFullScreen();
render_window->showFullScreen();
}
}
@ -2739,10 +2726,6 @@ void GMainWindow::HideFullscreen() {
render_window->showNormal();
render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
}
if (secondary_window->isFullScreen()) {
secondary_window->restoreGeometry(UISettings::values.secondarywindow_geometry);
secondary_window->showNormal();
}
}
void GMainWindow::ToggleWindowMode() {
@ -2761,7 +2744,6 @@ void GMainWindow::ToggleWindowMode() {
// Render in a separate window...
ui->horizontalLayout->removeWidget(render_window);
render_window->setParent(nullptr);
render_window->setFocusPolicy(Qt::NoFocus);
if (emulation_running) {
render_window->setVisible(true);
render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
@ -2781,6 +2763,12 @@ void GMainWindow::UpdateSecondaryWindowVisibility() {
UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry();
secondary_window->hide();
}
// make sure focus is on primary window whenever this changes
if (UISettings::values.single_window_mode.GetValue()) {
QApplication::setActiveWindow(this);
} else {
QApplication::setActiveWindow(render_window);
}
}
void GMainWindow::ChangeScreenLayout() {
@ -4244,6 +4232,8 @@ void GMainWindow::UpdateUISettings() {
if (!ui->action_Fullscreen->isChecked()) {
UISettings::values.geometry = saveGeometry();
UISettings::values.renderwindow_geometry = render_window->saveGeometry();
}
if (!secondary_window->isFullScreen()) {
UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry();
}
UISettings::values.state = saveState();

View File

@ -58,7 +58,6 @@ const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> QtConfi
// UISetting::values.shortcuts, which is alphabetically ordered.
// clang-format off
const std::array<UISettings::Shortcut, 43> QtConfig::default_hotkeys {{
{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::ApplicationShortcut}},
{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::ApplicationShortcut}},
{QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::ApplicationShortcut}},
{QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::ApplicationShortcut}},