summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-09-26 05:18:14 +0200
committerMorph <39850852+Morph1984@users.noreply.github.com>2021-10-02 05:39:54 +0200
commit282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1 (patch)
tree7743a6378d6ca4fe213ac34c1fdaedf6a7ef10e5
parentcore: Add Exit and ExitCallback (diff)
downloadyuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar.gz
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar.bz2
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar.lz
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar.xz
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.tar.zst
yuzu-282bdfd1bf87de150f4a2e7686a4f062b4b9f7c1.zip
-rw-r--r--src/yuzu/bootmanager.cpp5
-rw-r--r--src/yuzu/bootmanager.h4
-rw-r--r--src/yuzu/main.cpp7
-rw-r--r--src/yuzu/main.h1
4 files changed, 17 insertions, 0 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 1519a46ed..8b9e186b0 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -302,12 +302,17 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete);
connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram,
Qt::QueuedConnection);
+ connect(this, &GRenderWindow::ExitSignal, parent, &GMainWindow::OnExit, Qt::QueuedConnection);
}
void GRenderWindow::ExecuteProgram(std::size_t program_index) {
emit ExecuteProgramSignal(program_index);
}
+void GRenderWindow::Exit() {
+ emit ExitSignal();
+}
+
GRenderWindow::~GRenderWindow() {
input_subsystem->Shutdown();
}
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 402dd2ee1..54c4e2142 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -181,6 +181,9 @@ public:
*/
void ExecuteProgram(std::size_t program_index);
+ /// Instructs the window to exit the application.
+ void Exit();
+
public slots:
void OnEmulationStarting(EmuThread* emu_thread);
void OnEmulationStopping();
@@ -191,6 +194,7 @@ signals:
void Closed();
void FirstFrameDisplayed();
void ExecuteProgramSignal(std::size_t program_index);
+ void ExitSignal();
void MouseActivity();
private:
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 3c2824362..0bd0c5b04 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1384,6 +1384,9 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
system.RegisterExecuteProgramCallback(
[this](std::size_t program_index) { render_window->ExecuteProgram(program_index); });
+ // Register an Exit callback such that Core can exit the currently running application.
+ system.RegisterExitCallback([this]() { render_window->Exit(); });
+
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
@@ -2469,6 +2472,10 @@ void GMainWindow::OnExecuteProgram(std::size_t program_index) {
BootGame(last_filename_booted, 0, program_index);
}
+void GMainWindow::OnExit() {
+ OnStopGame();
+}
+
void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) {
OverlayDialog dialog(render_window, Core::System::GetInstance(), error_code, error_text,
QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter);
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 36eed6103..60ce01471 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -153,6 +153,7 @@ signals:
public slots:
void OnLoadComplete();
void OnExecuteProgram(std::size_t program_index);
+ void OnExit();
void ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters);
void SoftwareKeyboardInitialize(