mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #5782 from ligfx/fixqtinput
Qt: allow emulation input when background input is disabled
This commit is contained in:
@ -4,55 +4,46 @@
|
|||||||
|
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMutexLocker>
|
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
#include "DolphinQt2/Host.h"
|
#include "DolphinQt2/Host.h"
|
||||||
#include "DolphinQt2/MainWindow.h"
|
|
||||||
|
|
||||||
Host* Host::m_instance = nullptr;
|
Host::Host() = default;
|
||||||
|
|
||||||
Host* Host::GetInstance()
|
Host* Host::GetInstance()
|
||||||
{
|
{
|
||||||
if (m_instance == nullptr)
|
static Host* s_instance = new Host();
|
||||||
m_instance = new Host();
|
return s_instance;
|
||||||
return m_instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Host::GetRenderHandle()
|
void* Host::GetRenderHandle()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
return m_render_handle;
|
return m_render_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::SetRenderHandle(void* handle)
|
void Host::SetRenderHandle(void* handle)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
m_render_handle = handle;
|
m_render_handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::GetRenderFocus()
|
bool Host::GetRenderFocus()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
return m_render_focus;
|
return m_render_focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::SetRenderFocus(bool focus)
|
void Host::SetRenderFocus(bool focus)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
m_render_focus = focus;
|
m_render_focus = focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::GetRenderFullscreen()
|
bool Host::GetRenderFullscreen()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
return m_render_fullscreen;
|
return m_render_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::SetRenderFullscreen(bool fullscreen)
|
void Host::SetRenderFullscreen(bool fullscreen)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
|
||||||
m_render_fullscreen = fullscreen;
|
m_render_fullscreen = fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSize>
|
#include <atomic>
|
||||||
|
|
||||||
// Singleton that talks to the Core via the interface defined in Core/Host.h.
|
// Singleton that talks to the Core via the interface defined in Core/Host.h.
|
||||||
// Because Host_* calls might come from different threads than the MainWindow,
|
// Because Host_* calls might come from different threads than the MainWindow,
|
||||||
@ -35,11 +34,9 @@ signals:
|
|||||||
void RequestRenderSize(int w, int h);
|
void RequestRenderSize(int w, int h);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Host() {}
|
Host();
|
||||||
static Host* m_instance;
|
|
||||||
QMutex m_lock;
|
|
||||||
|
|
||||||
void* m_render_handle;
|
std::atomic<void*> m_render_handle;
|
||||||
bool m_render_focus;
|
std::atomic<bool> m_render_focus;
|
||||||
bool m_render_fullscreen;
|
std::atomic<bool> m_render_fullscreen;
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,6 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
|
|||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
||||||
connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
|
connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
|
||||||
connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus);
|
|
||||||
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen);
|
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen);
|
||||||
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle);
|
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle);
|
||||||
emit HandleChanged((void*)winId());
|
emit HandleChanged((void*)winId());
|
||||||
@ -43,9 +42,11 @@ bool RenderWidget::event(QEvent* event)
|
|||||||
case QEvent::WinIdChange:
|
case QEvent::WinIdChange:
|
||||||
emit HandleChanged((void*)winId());
|
emit HandleChanged((void*)winId());
|
||||||
break;
|
break;
|
||||||
case QEvent::FocusIn:
|
case QEvent::WindowActivate:
|
||||||
case QEvent::FocusOut:
|
Host::GetInstance()->SetRenderFocus(true);
|
||||||
emit FocusChanged(hasFocus());
|
break;
|
||||||
|
case QEvent::WindowDeactivate:
|
||||||
|
Host::GetInstance()->SetRenderFocus(false);
|
||||||
break;
|
break;
|
||||||
case QEvent::WindowStateChange:
|
case QEvent::WindowStateChange:
|
||||||
emit StateChanged(isFullScreen());
|
emit StateChanged(isFullScreen());
|
||||||
|
@ -14,13 +14,12 @@ class RenderWidget final : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit RenderWidget(QWidget* parent = nullptr);
|
explicit RenderWidget(QWidget* parent = nullptr);
|
||||||
|
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void EscapePressed();
|
void EscapePressed();
|
||||||
void Closed();
|
void Closed();
|
||||||
void HandleChanged(void* handle);
|
void HandleChanged(void* handle);
|
||||||
void FocusChanged(bool focus);
|
|
||||||
void StateChanged(bool fullscreen);
|
void StateChanged(bool fullscreen);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user