Implement focus-shifting on Windows and waiting status

This commit is contained in:
Cacodemon345
2025-07-11 18:04:58 +06:00
parent bb7ebc72c8
commit 07c6a8a154
11 changed files with 70 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
* Copyright 2024 cold-brewed
*/
#include <QString>
#include <QDirIterator>
#include <QDebug>
@@ -26,10 +27,15 @@
#include <QtNetwork>
#include <QElapsedTimer>
#include <QProgressDialog>
#include <QWindow>
#include "qt_vmmanager_system.hpp"
// #include "qt_vmmanager_details_section.hpp"
#include "qt_vmmanager_detailsection.hpp"
#ifdef Q_OS_WINDOWS
#include <windows.h>
#endif
extern "C" {
#include <86box/86box.h>
@@ -427,6 +433,11 @@ VMManagerSystem::launchSettings() {
// If the system is already running, instruct it to show settings
if (process->processId() != 0) {
#ifdef Q_OS_WINDOWS
if (this->id) {
SetForegroundWindow((HWND)this->id);
}
#endif
socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::ShowSettings);
return;
}
@@ -776,6 +787,7 @@ VMManagerSystem::startServer() {
connect(socket_server, &VMManagerServerSocket::dataReceived, this, &VMManagerSystem::dataReceived);
connect(socket_server, &VMManagerServerSocket::windowStatusChanged, this, &VMManagerSystem::windowStatusChangeReceived);
connect(socket_server, &VMManagerServerSocket::runningStatusChanged, this, &VMManagerSystem::runningStatusChangeReceived);
connect(socket_server, &VMManagerServerSocket::winIdReceived, this, [this] (WId id) { this->id = id; });
return true;
} else {
return false;
@@ -892,12 +904,20 @@ VMManagerSystem::runningStatusChangeReceived(VMManagerProtocol::RunningState sta
{
if(state == VMManagerProtocol::RunningState::Running) {
process_status = VMManagerSystem::ProcessStatus::Running;
window_obscured = false;
windowStatusChanged();
} else if(state == VMManagerProtocol::RunningState::Paused) {
process_status = VMManagerSystem::ProcessStatus::Paused;
window_obscured = false;
windowStatusChanged();
} else if(state == VMManagerProtocol::RunningState::RunningWaiting) {
process_status = VMManagerSystem::ProcessStatus::RunningWaiting;
window_obscured = true;
windowStatusChanged();
} else if(state == VMManagerProtocol::RunningState::PausedWaiting) {
process_status = VMManagerSystem::ProcessStatus::PausedWaiting;
window_obscured = true;
windowStatusChanged();
} else {
process_status = VMManagerSystem::ProcessStatus::Unknown;
}