Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 15, 2023
2 parents a292a8e + b384a2f commit c8b32ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
20 changes: 18 additions & 2 deletions pcsx2-qt/DisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ void DisplayWidget::updateRelativeMode(bool enabled)
QCursor::setPos(m_relative_mouse_start_pos);
releaseMouse();
}

}

void DisplayWidget::updateCursor(bool hidden)
Expand Down Expand Up @@ -163,6 +162,20 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event)
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()
{
#ifdef _WIN32
Expand Down Expand Up @@ -206,7 +219,7 @@ bool DisplayWidget::event(QEvent* event)
case QEvent::KeyRelease:
{
const QKeyEvent* key_event = static_cast<QKeyEvent*>(event);

// Forward text input to imgui.
if (ImGuiManager::WantsTextInput() && key_event->type() == QEvent::KeyPress)
{
Expand Down Expand Up @@ -369,6 +382,9 @@ bool DisplayWidget::event(QEvent* event)

case QEvent::Close:
{
if (m_destroying)
return QWidget::event(event);

handleCloseEvent(static_cast<QCloseEvent*>(event));
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions pcsx2-qt/DisplayWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DisplayWidget final : public QWidget
void updateCursor(bool hidden);

void handleCloseEvent(QCloseEvent* event);
void destroy();

Q_SIGNALS:
void windowResizedEvent(int width, int height, float scale);
Expand All @@ -59,6 +60,7 @@ class DisplayWidget final : public QWidget
bool m_clip_mouse_enabled = false;
#endif
bool m_cursor_hidden = false;
bool m_destroying = false;

std::vector<int> m_keys_pressed_with_modifiers;

Expand Down
7 changes: 2 additions & 5 deletions pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,9 +1991,6 @@ std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window,

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();
if (!wi.has_value())
{
Expand Down Expand Up @@ -2165,7 +2162,7 @@ void MainWindow::destroyDisplayWidget(bool show_game_list)

if (m_display_widget)
{
m_display_widget->deleteLater();
m_display_widget->destroy();
m_display_widget = nullptr;
}

Expand Down Expand Up @@ -2247,7 +2244,7 @@ SettingsDialog* MainWindow::getSettingsDialog()
updateLanguage();
// If you doSettings now, on macOS, the window will somehow end up underneath the main window that was created above
// Delay it slightly...
QtHost::RunOnUIThread([]{
QtHost::RunOnUIThread([] {
g_main_window->doSettings("Interface");
});
});
Expand Down
12 changes: 11 additions & 1 deletion pcsx2/x86/ix86-32/iR5900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,17 @@ static void recExecute()
void R5900::Dynarec::OpcodeImpl::recSYSCALL()
{
EE::Profiler.EmitOp(eeOpcode::SYSCALL);

if (GPR_IS_CONST1(3))
{
// If it's FlushCache or iFlushCache, we can skip it since we don't support cache in the JIT.
if (g_cpuConstRegs[3].UC[0] == 0x64 || g_cpuConstRegs[3].UC[0] == 0x68)
{
// Emulate the amount of cycles it takes for the exception handlers to run
// This number was found by using github.com/F0bes/flushcache-cycles
s_nBlockCycles += 5650;
return;
}
}
recCall(R5900::Interpreter::OpcodeImpl::SYSCALL);
g_branch = 2; // Indirect branch with event check.
}
Expand Down

0 comments on commit c8b32ec

Please sign in to comment.