diff --git a/CMakeModules/GenerateSettingKeys.cmake b/CMakeModules/GenerateSettingKeys.cmake index 1d705113c..fce95b18a 100644 --- a/CMakeModules/GenerateSettingKeys.cmake +++ b/CMakeModules/GenerateSettingKeys.cmake @@ -194,6 +194,7 @@ if (ENABLE_QT) "geometry" "state" "geometryRenderWindow" + "geometrySecondaryWindow" "gameListHeaderState" "microProfileDialogGeometry" "name" diff --git a/src/citra_qt/citra_qt.cpp b/src/citra_qt/citra_qt.cpp index db3307fa4..51e204200 100644 --- a/src/citra_qt/citra_qt.cpp +++ b/src/citra_qt/citra_qt.cpp @@ -787,12 +787,25 @@ void GMainWindow::InitializeHotkeys() { const auto link_action_shortcut = [&](QAction* action, const QString& action_name, const bool primary_only = false) { static const QString main_window = QStringLiteral("Main Window"); - action->setShortcut(hotkey_registry.GetKeySequence(main_window, action_name)); + auto context = hotkey_registry.GetShortcutContext(main_window, action_name); + auto shortcut = hotkey_registry.GetKeySequence(main_window, action_name); + action->setShortcut(shortcut); + action->setShortcutContext(context); action->setAutoRepeat(false); this->addAction(action); +<<<<<<< HEAD if (!primary_only) secondary_window->addAction(action); hotkey_registry.SetAction(main_window, action_name, action); +======= + // handle the shortcuts that are different per-screen + if (context == Qt::WidgetShortcut) { + render_window->addAction(action); + if (!primary_only) { + secondary_window->addAction(action); + } + } +>>>>>>> 88d1bef1c (Bugfix: All desktop hotkeys now work in dual-window mode.) }; link_action_shortcut(ui->action_Load_File, QStringLiteral("Load File")); @@ -804,7 +817,7 @@ void GMainWindow::InitializeHotkeys() { link_action_shortcut(ui->action_Stop, QStringLiteral("Stop Emulation")); link_action_shortcut(ui->action_Show_Filter_Bar, QStringLiteral("Toggle Filter Bar")); link_action_shortcut(ui->action_Show_Status_Bar, QStringLiteral("Toggle Status Bar")); - link_action_shortcut(ui->action_Fullscreen, fullscreen, true); + link_action_shortcut(ui->action_Fullscreen, fullscreen); link_action_shortcut(ui->action_Capture_Screenshot, QStringLiteral("Capture Screenshot")); link_action_shortcut(ui->action_Screen_Layout_Swap_Screens, QStringLiteral("Swap Screens")); link_action_shortcut(ui->action_Screen_Layout_Upright_Screens, @@ -826,10 +839,7 @@ void GMainWindow::InitializeHotkeys() { // QShortcut Hotkeys const auto connect_shortcut = [&](const QString& action_name, const auto& function) { const auto* hotkey = hotkey_registry.GetHotkey(main_window, action_name, this); - const auto* secondary_hotkey = - hotkey_registry.GetHotkey(main_window, action_name, secondary_window); connect(hotkey, &QShortcut::activated, this, function); - connect(secondary_hotkey, &QShortcut::activated, this, function); }; connect_shortcut(QStringLiteral("Toggle Screen Layout"), &GMainWindow::ToggleScreenLayout); @@ -899,11 +909,6 @@ void GMainWindow::InitializeHotkeys() { connect(action, SIGNAL(triggered()), this, slot); secondary_window->addAction(action); }; - - // Use the same fullscreen hotkey as the main window - const auto fullscreen_hotkey = hotkey_registry.GetKeySequence(main_window, fullscreen); - add_secondary_window_hotkey(action_secondary_fullscreen, fullscreen_hotkey, - SLOT(ToggleSecondaryFullscreen())); } void GMainWindow::SetDefaultUIGeometry() { @@ -922,6 +927,7 @@ void GMainWindow::RestoreUIState() { restoreGeometry(UISettings::values.geometry); restoreState(UISettings::values.state); render_window->restoreGeometry(UISettings::values.renderwindow_geometry); + secondary_window->restoreGeometry(UISettings::values.secondarywindow_geometry); #if MICROPROFILE_ENABLED microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry); microProfileDialog->setVisible(UISettings::values.microprofile_visible.GetValue()); @@ -2594,14 +2600,25 @@ void GMainWindow::ToggleSecondaryFullscreen() { } void GMainWindow::ShowFullscreen() { + QWidget* window_to_change = + ui->action_Single_Window_Mode->isChecked() ? static_cast(this) : render_window; + if (ui->action_Single_Window_Mode->isChecked()) { UISettings::values.geometry = saveGeometry(); ui->menubar->hide(); statusBar()->hide(); - showFullScreen(); } else { UISettings::values.renderwindow_geometry = render_window->saveGeometry(); - render_window->showFullScreen(); + } + + 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(); } } @@ -2615,12 +2632,16 @@ 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() { if (ui->action_Single_Window_Mode->isChecked()) { // Render in the main window... - render_window->BackupGeometry(); + UISettings::values.renderwindow_geometry = render_window->saveGeometry(); ui->horizontalLayout->addWidget(render_window); render_window->setFocusPolicy(Qt::StrongFocus); if (emulation_running) { @@ -2636,7 +2657,7 @@ void GMainWindow::ToggleWindowMode() { render_window->setFocusPolicy(Qt::NoFocus); if (emulation_running) { render_window->setVisible(true); - render_window->RestoreGeometry(); + render_window->restoreGeometry(UISettings::values.renderwindow_geometry); game_list->show(); } } @@ -2647,10 +2668,10 @@ void GMainWindow::UpdateSecondaryWindowVisibility() { return; } if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) { - secondary_window->RestoreGeometry(); + secondary_window->restoreGeometry(UISettings::values.secondarywindow_geometry); secondary_window->show(); } else { - secondary_window->BackupGeometry(); + UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry(); secondary_window->hide(); } } @@ -3077,7 +3098,6 @@ void GMainWindow::OnCaptureScreenshot() { .toString(QStringLiteral("dd.MM.yy_hh.mm.ss.z")) .toStdString(); path.append(fmt::format("/{}_{}.png", filename, timestamp)); - auto* const screenshot_window = secondary_window->HasFocus() ? secondary_window : render_window; screenshot_window->CaptureScreenshot( @@ -4139,6 +4159,7 @@ void GMainWindow::UpdateUISettings() { if (!ui->action_Fullscreen->isChecked()) { UISettings::values.geometry = saveGeometry(); UISettings::values.renderwindow_geometry = render_window->saveGeometry(); + UISettings::values.secondarywindow_geometry = secondary_window->saveGeometry(); } UISettings::values.state = saveState(); #if MICROPROFILE_ENABLED diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index e667468cc..2b3e86cc8 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -896,6 +896,8 @@ void QtConfig::ReadUILayoutValues() { UISettings::values.state = ReadSetting(Settings::QKeys::state).toByteArray(); UISettings::values.renderwindow_geometry = ReadSetting(Settings::QKeys::geometryRenderWindow).toByteArray(); + UISettings::values.secondarywindow_geometry = + ReadSetting(Settings::QKeys::geometrySecondaryWindow).toByteArray(); UISettings::values.gamelist_header_state = ReadSetting(Settings::QKeys::gameListHeaderState).toByteArray(); UISettings::values.microprofile_geometry = @@ -1429,6 +1431,8 @@ void QtConfig::SaveUILayoutValues() { WriteSetting(Settings::QKeys::geometry, UISettings::values.geometry); WriteSetting(Settings::QKeys::state, UISettings::values.state); WriteSetting(Settings::QKeys::geometryRenderWindow, UISettings::values.renderwindow_geometry); + WriteSetting(Settings::QKeys::geometrySecondaryWindow, + UISettings::values.secondarywindow_geometry); WriteSetting(Settings::QKeys::gameListHeaderState, UISettings::values.gamelist_header_state); WriteSetting(Settings::QKeys::microProfileDialogGeometry, UISettings::values.microprofile_geometry); diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index 1be719eb6..e61c98c44 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -72,7 +72,7 @@ struct Values { QByteArray state; QByteArray renderwindow_geometry; - + QByteArray secondarywindow_geometry; QByteArray gamelist_header_state; QByteArray microprofile_geometry;