diff options
| -rw-r--r-- | src/yuzu/main.cpp | 49 | ||||
| -rw-r--r-- | src/yuzu/main.h | 7 |
2 files changed, 27 insertions, 29 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 54ca2dc1d..47615adfe 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include "core/file_sys/vfs.h" | 20 | #include "core/file_sys/vfs.h" |
| 21 | #include "core/file_sys/vfs_real.h" | 21 | #include "core/file_sys/vfs_real.h" |
| 22 | #include "core/frontend/applets/general_frontend.h" | 22 | #include "core/frontend/applets/general_frontend.h" |
| 23 | #include "core/frontend/scope_acquire_window_context.h" | ||
| 24 | #include "core/hle/service/acc/profile_manager.h" | 23 | #include "core/hle/service/acc/profile_manager.h" |
| 25 | #include "core/hle/service/am/applet_ae.h" | 24 | #include "core/hle/service/am/applet_ae.h" |
| 26 | #include "core/hle/service/am/applet_oe.h" | 25 | #include "core/hle/service/am/applet_oe.h" |
| @@ -985,11 +984,8 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 985 | return; | 984 | return; |
| 986 | 985 | ||
| 987 | // Create and start the emulation thread | 986 | // Create and start the emulation thread |
| 988 | emu_thread = std::make_unique<EmuThread>(render_window); | 987 | emu_thread = std::make_unique<EmuThread>(*render_window); |
| 989 | emit EmulationStarting(emu_thread.get()); | 988 | emit EmulationStarting(emu_thread.get()); |
| 990 | if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) { | ||
| 991 | render_window->moveContext(); | ||
| 992 | } | ||
| 993 | emu_thread->start(); | 989 | emu_thread->start(); |
| 994 | 990 | ||
| 995 | connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); | 991 | connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); |
| @@ -1087,6 +1083,9 @@ void GMainWindow::ShutdownGame() { | |||
| 1087 | emulation_running = false; | 1083 | emulation_running = false; |
| 1088 | 1084 | ||
| 1089 | game_path.clear(); | 1085 | game_path.clear(); |
| 1086 | |||
| 1087 | // When closing the game, destroy the GLWindow to clear the context after the game is closed | ||
| 1088 | render_window->ReleaseRenderTarget(); | ||
| 1090 | } | 1089 | } |
| 1091 | 1090 | ||
| 1092 | void GMainWindow::StoreRecentFile(const QString& filename) { | 1091 | void GMainWindow::StoreRecentFile(const QString& filename) { |
| @@ -2215,48 +2214,47 @@ void GMainWindow::closeEvent(QCloseEvent* event) { | |||
| 2215 | QWidget::closeEvent(event); | 2214 | QWidget::closeEvent(event); |
| 2216 | } | 2215 | } |
| 2217 | 2216 | ||
| 2218 | void GMainWindow::keyPressEvent(QKeyEvent* event) { | 2217 | static bool IsSingleFileDropEvent(const QMimeData* mime) { |
| 2219 | if (render_window) { | 2218 | return mime->hasUrls() && mime->urls().length() == 1; |
| 2220 | render_window->ForwardKeyPressEvent(event); | ||
| 2221 | } | ||
| 2222 | } | 2219 | } |
| 2223 | 2220 | ||
| 2224 | void GMainWindow::keyReleaseEvent(QKeyEvent* event) { | 2221 | void GMainWindow::AcceptDropEvent(QDropEvent* event) { |
| 2225 | if (render_window) { | 2222 | if (IsSingleFileDropEvent(event->mimeData())) { |
| 2226 | render_window->ForwardKeyReleaseEvent(event); | 2223 | event->setDropAction(Qt::DropAction::LinkAction); |
| 2224 | event->accept(); | ||
| 2227 | } | 2225 | } |
| 2228 | } | 2226 | } |
| 2229 | 2227 | ||
| 2230 | static bool IsSingleFileDropEvent(QDropEvent* event) { | 2228 | bool GMainWindow::DropAction(QDropEvent* event) { |
| 2231 | const QMimeData* mimeData = event->mimeData(); | 2229 | if (!IsSingleFileDropEvent(event->mimeData())) { |
| 2232 | return mimeData->hasUrls() && mimeData->urls().length() == 1; | 2230 | return false; |
| 2233 | } | ||
| 2234 | |||
| 2235 | void GMainWindow::dropEvent(QDropEvent* event) { | ||
| 2236 | if (!IsSingleFileDropEvent(event)) { | ||
| 2237 | return; | ||
| 2238 | } | 2231 | } |
| 2239 | 2232 | ||
| 2240 | const QMimeData* mime_data = event->mimeData(); | 2233 | const QMimeData* mime_data = event->mimeData(); |
| 2241 | const QString filename = mime_data->urls().at(0).toLocalFile(); | 2234 | const QString& filename = mime_data->urls().at(0).toLocalFile(); |
| 2242 | 2235 | ||
| 2243 | if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) { | 2236 | if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) { |
| 2237 | // Amiibo | ||
| 2244 | LoadAmiibo(filename); | 2238 | LoadAmiibo(filename); |
| 2245 | } else { | 2239 | } else { |
| 2240 | // Game | ||
| 2246 | if (ConfirmChangeGame()) { | 2241 | if (ConfirmChangeGame()) { |
| 2247 | BootGame(filename); | 2242 | BootGame(filename); |
| 2248 | } | 2243 | } |
| 2249 | } | 2244 | } |
| 2245 | return true; | ||
| 2246 | } | ||
| 2247 | |||
| 2248 | void GMainWindow::dropEvent(QDropEvent* event) { | ||
| 2249 | DropAction(event); | ||
| 2250 | } | 2250 | } |
| 2251 | 2251 | ||
| 2252 | void GMainWindow::dragEnterEvent(QDragEnterEvent* event) { | 2252 | void GMainWindow::dragEnterEvent(QDragEnterEvent* event) { |
| 2253 | if (IsSingleFileDropEvent(event)) { | 2253 | AcceptDropEvent(event); |
| 2254 | event->acceptProposedAction(); | ||
| 2255 | } | ||
| 2256 | } | 2254 | } |
| 2257 | 2255 | ||
| 2258 | void GMainWindow::dragMoveEvent(QDragMoveEvent* event) { | 2256 | void GMainWindow::dragMoveEvent(QDragMoveEvent* event) { |
| 2259 | event->acceptProposedAction(); | 2257 | AcceptDropEvent(event); |
| 2260 | } | 2258 | } |
| 2261 | 2259 | ||
| 2262 | bool GMainWindow::ConfirmChangeGame() { | 2260 | bool GMainWindow::ConfirmChangeGame() { |
| @@ -2377,6 +2375,7 @@ int main(int argc, char* argv[]) { | |||
| 2377 | 2375 | ||
| 2378 | // Enables the core to make the qt created contexts current on std::threads | 2376 | // Enables the core to make the qt created contexts current on std::threads |
| 2379 | QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); | 2377 | QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); |
| 2378 | QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); | ||
| 2380 | QApplication app(argc, argv); | 2379 | QApplication app(argc, argv); |
| 2381 | 2380 | ||
| 2382 | // Qt changes the locale and causes issues in float conversion using std::to_string() when | 2381 | // Qt changes the locale and causes issues in float conversion using std::to_string() when |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 8eba2172c..a67125567 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -78,6 +78,9 @@ public: | |||
| 78 | 78 | ||
| 79 | std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; | 79 | std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; |
| 80 | 80 | ||
| 81 | bool DropAction(QDropEvent* event); | ||
| 82 | void AcceptDropEvent(QDropEvent* event); | ||
| 83 | |||
| 81 | signals: | 84 | signals: |
| 82 | 85 | ||
| 83 | /** | 86 | /** |
| @@ -264,8 +267,4 @@ protected: | |||
| 264 | void dropEvent(QDropEvent* event) override; | 267 | void dropEvent(QDropEvent* event) override; |
| 265 | void dragEnterEvent(QDragEnterEvent* event) override; | 268 | void dragEnterEvent(QDragEnterEvent* event) override; |
| 266 | void dragMoveEvent(QDragMoveEvent* event) override; | 269 | void dragMoveEvent(QDragMoveEvent* event) override; |
| 267 | |||
| 268 | // Overrides used to forward signals to the render window when the focus moves out. | ||
| 269 | void keyPressEvent(QKeyEvent* event) override; | ||
| 270 | void keyReleaseEvent(QKeyEvent* event) override; | ||
| 271 | }; | 270 | }; |