mirror of https://github.com/PCSX2/pcsx2.git
Qt: Fix returning from fullscreen on MacOS
This commit is contained in:
parent
8dd866a35e
commit
b384a2fff6
|
@ -124,7 +124,6 @@ void DisplayWidget::updateRelativeMode(bool enabled)
|
||||||
QCursor::setPos(m_relative_mouse_start_pos);
|
QCursor::setPos(m_relative_mouse_start_pos);
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayWidget::updateCursor(bool hidden)
|
void DisplayWidget::updateCursor(bool hidden)
|
||||||
|
@ -163,6 +162,20 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event)
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayWidget::destroy()
|
||||||
|
{
|
||||||
|
m_destroying = true;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// See Qt documentation, entire application is in full screen state, and the main
|
||||||
|
// window will get reopened fullscreen instead of windowed if we don't close the
|
||||||
|
// fullscreen window first.
|
||||||
|
if (isFullScreen())
|
||||||
|
close();
|
||||||
|
#endif
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayWidget::updateCenterPos()
|
void DisplayWidget::updateCenterPos()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -206,7 +219,7 @@ bool DisplayWidget::event(QEvent* event)
|
||||||
case QEvent::KeyRelease:
|
case QEvent::KeyRelease:
|
||||||
{
|
{
|
||||||
const QKeyEvent* key_event = static_cast<QKeyEvent*>(event);
|
const QKeyEvent* key_event = static_cast<QKeyEvent*>(event);
|
||||||
|
|
||||||
// Forward text input to imgui.
|
// Forward text input to imgui.
|
||||||
if (ImGuiManager::WantsTextInput() && key_event->type() == QEvent::KeyPress)
|
if (ImGuiManager::WantsTextInput() && key_event->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
|
@ -369,6 +382,9 @@ bool DisplayWidget::event(QEvent* event)
|
||||||
|
|
||||||
case QEvent::Close:
|
case QEvent::Close:
|
||||||
{
|
{
|
||||||
|
if (m_destroying)
|
||||||
|
return QWidget::event(event);
|
||||||
|
|
||||||
handleCloseEvent(static_cast<QCloseEvent*>(event));
|
handleCloseEvent(static_cast<QCloseEvent*>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
void updateCursor(bool hidden);
|
void updateCursor(bool hidden);
|
||||||
|
|
||||||
void handleCloseEvent(QCloseEvent* event);
|
void handleCloseEvent(QCloseEvent* event);
|
||||||
|
void destroy();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void windowResizedEvent(int width, int height, float scale);
|
void windowResizedEvent(int width, int height, float scale);
|
||||||
|
@ -59,6 +60,7 @@ private:
|
||||||
bool m_clip_mouse_enabled = false;
|
bool m_clip_mouse_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
bool m_cursor_hidden = false;
|
bool m_cursor_hidden = false;
|
||||||
|
bool m_destroying = false;
|
||||||
|
|
||||||
std::vector<int> m_keys_pressed_with_modifiers;
|
std::vector<int> m_keys_pressed_with_modifiers;
|
||||||
|
|
||||||
|
|
|
@ -1991,9 +1991,6 @@ std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window,
|
||||||
|
|
||||||
createDisplayWidget(fullscreen, render_to_main);
|
createDisplayWidget(fullscreen, render_to_main);
|
||||||
|
|
||||||
// we need the surface visible.. this might be able to be replaced with something else
|
|
||||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
|
||||||
|
|
||||||
std::optional<WindowInfo> wi = m_display_widget->getWindowInfo();
|
std::optional<WindowInfo> wi = m_display_widget->getWindowInfo();
|
||||||
if (!wi.has_value())
|
if (!wi.has_value())
|
||||||
{
|
{
|
||||||
|
@ -2165,7 +2162,7 @@ void MainWindow::destroyDisplayWidget(bool show_game_list)
|
||||||
|
|
||||||
if (m_display_widget)
|
if (m_display_widget)
|
||||||
{
|
{
|
||||||
m_display_widget->deleteLater();
|
m_display_widget->destroy();
|
||||||
m_display_widget = nullptr;
|
m_display_widget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2247,7 +2244,7 @@ SettingsDialog* MainWindow::getSettingsDialog()
|
||||||
updateLanguage();
|
updateLanguage();
|
||||||
// If you doSettings now, on macOS, the window will somehow end up underneath the main window that was created above
|
// If you doSettings now, on macOS, the window will somehow end up underneath the main window that was created above
|
||||||
// Delay it slightly...
|
// Delay it slightly...
|
||||||
QtHost::RunOnUIThread([]{
|
QtHost::RunOnUIThread([] {
|
||||||
g_main_window->doSettings("Interface");
|
g_main_window->doSettings("Interface");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue