qt: Add VM-manager message handling on windows

This commit is contained in:
ts-korhonen
2022-01-22 01:10:11 +02:00
parent 7fdeff1851
commit 7995be4adb
7 changed files with 174 additions and 3 deletions

View File

@@ -20,6 +20,8 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
#ifdef Q_OS_WINDOWS
#include "qt_winrawinputfilter.hpp"
#include "qt_winmanagerfilter.hpp"
#include <86box/win.h>
#endif
#include <86box/86box.h>
@@ -30,6 +32,7 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
#include <thread>
#include <iostream>
#include <memory>
#include "qt_mainwindow.hpp"
#include "qt_progsettings.hpp"
@@ -102,7 +105,7 @@ main_thread_fn()
}
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
QApplication app(argc, argv);
qt_set_sequence_auto_mnemonic(false);
Q_INIT_RESOURCE(qt_resources);
Q_INIT_RESOURCE(qt_translations);
@@ -137,6 +140,30 @@ int main(int argc, char* argv[]) {
app.installEventFilter(main_window);
#ifdef Q_OS_WINDOWS
/* Setup VM-manager messages */
std::unique_ptr<WindowsManagerFilter> wmfilter;
if (source_hwnd)
{
wmfilter.reset(new WindowsManagerFilter());
QObject::connect(wmfilter.get(), WindowsManagerFilter::showsettings, main_window, MainWindow::showSettings);
QObject::connect(wmfilter.get(), WindowsManagerFilter::pause, [](){ plat_pause(dopause ^ 1); });
QObject::connect(wmfilter.get(), WindowsManagerFilter::reset, main_window, MainWindow::hardReset);
QObject::connect(wmfilter.get(), WindowsManagerFilter::shutdown, [](){ plat_power_off(); });
QObject::connect(wmfilter.get(), WindowsManagerFilter::ctrlaltdel, [](){ pc_send_cad(); });
app.installNativeEventFilter(wmfilter.get());
HWND main_hwnd = (HWND)main_window->winId();
/* Send main window HWND to manager */
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
/* Send shutdown message to manager */
QObject::connect(&app, &QApplication::destroyed, [main_hwnd](QObject*) {
PostMessage((HWND)(uintptr_t)source_hwnd, WM_HAS_SHUTDOWN, (WPARAM)0, (LPARAM)main_hwnd);
});
}
/* Setup raw input */
auto rawInputFilter = WindowsRawInputFilter::Register(main_window);
if (rawInputFilter)
{
@@ -144,7 +171,7 @@ int main(int argc, char* argv[]) {
QObject::disconnect(main_window, &MainWindow::pollMouse, 0, 0);
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter*)rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
main_window->setSendKeyboardInput(false);
}
}
#endif
pc_reset_hard_init();