summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-02-17 21:49:52 +0100
committerbunnei <bunneidev@gmail.com>2020-02-26 03:23:00 +0100
commitb2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece (patch)
tree8e0fcf14c990ba6a9cf24bbde75a45b99cbef905 /src
parentcore: frontend: Refactor scope_acquire_window_context to scope_acquire_context. (diff)
downloadyuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar.gz
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar.bz2
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar.lz
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar.xz
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.tar.zst
yuzu-b2a38cce4ef7e4d98b981ba7e7f2a1e3a9ed7ece.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp49
-rw-r--r--src/yuzu/main.h7
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 @@
#include "core/file_sys/vfs.h"
#include "core/file_sys/vfs_real.h"
#include "core/frontend/applets/general_frontend.h"
-#include "core/frontend/scope_acquire_window_context.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/am/applet_ae.h"
#include "core/hle/service/am/applet_oe.h"
@@ -985,11 +984,8 @@ void GMainWindow::BootGame(const QString& filename) {
return;
// Create and start the emulation thread
- emu_thread = std::make_unique<EmuThread>(render_window);
+ emu_thread = std::make_unique<EmuThread>(*render_window);
emit EmulationStarting(emu_thread.get());
- if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
- render_window->moveContext();
- }
emu_thread->start();
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
@@ -1087,6 +1083,9 @@ void GMainWindow::ShutdownGame() {
emulation_running = false;
game_path.clear();
+
+ // When closing the game, destroy the GLWindow to clear the context after the game is closed
+ render_window->ReleaseRenderTarget();
}
void GMainWindow::StoreRecentFile(const QString& filename) {
@@ -2215,48 +2214,47 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
QWidget::closeEvent(event);
}
-void GMainWindow::keyPressEvent(QKeyEvent* event) {
- if (render_window) {
- render_window->ForwardKeyPressEvent(event);
- }
+static bool IsSingleFileDropEvent(const QMimeData* mime) {
+ return mime->hasUrls() && mime->urls().length() == 1;
}
-void GMainWindow::keyReleaseEvent(QKeyEvent* event) {
- if (render_window) {
- render_window->ForwardKeyReleaseEvent(event);
+void GMainWindow::AcceptDropEvent(QDropEvent* event) {
+ if (IsSingleFileDropEvent(event->mimeData())) {
+ event->setDropAction(Qt::DropAction::LinkAction);
+ event->accept();
}
}
-static bool IsSingleFileDropEvent(QDropEvent* event) {
- const QMimeData* mimeData = event->mimeData();
- return mimeData->hasUrls() && mimeData->urls().length() == 1;
-}
-
-void GMainWindow::dropEvent(QDropEvent* event) {
- if (!IsSingleFileDropEvent(event)) {
- return;
+bool GMainWindow::DropAction(QDropEvent* event) {
+ if (!IsSingleFileDropEvent(event->mimeData())) {
+ return false;
}
const QMimeData* mime_data = event->mimeData();
- const QString filename = mime_data->urls().at(0).toLocalFile();
+ const QString& filename = mime_data->urls().at(0).toLocalFile();
if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) {
+ // Amiibo
LoadAmiibo(filename);
} else {
+ // Game
if (ConfirmChangeGame()) {
BootGame(filename);
}
}
+ return true;
+}
+
+void GMainWindow::dropEvent(QDropEvent* event) {
+ DropAction(event);
}
void GMainWindow::dragEnterEvent(QDragEnterEvent* event) {
- if (IsSingleFileDropEvent(event)) {
- event->acceptProposedAction();
- }
+ AcceptDropEvent(event);
}
void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
- event->acceptProposedAction();
+ AcceptDropEvent(event);
}
bool GMainWindow::ConfirmChangeGame() {
@@ -2377,6 +2375,7 @@ int main(int argc, char* argv[]) {
// Enables the core to make the qt created contexts current on std::threads
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication app(argc, argv);
// 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:
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
+ bool DropAction(QDropEvent* event);
+ void AcceptDropEvent(QDropEvent* event);
+
signals:
/**
@@ -264,8 +267,4 @@ protected:
void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
-
- // Overrides used to forward signals to the render window when the focus moves out.
- void keyPressEvent(QKeyEvent* event) override;
- void keyReleaseEvent(QKeyEvent* event) override;
};