qt: Send dialog status to VM-manager & fix pause
- Manager is notified of modal dialogs blocking the main window. - Pause command from manager uses action to prevent desyncing pause status in the menus and toolbar.
This commit is contained in:
@@ -144,15 +144,23 @@ int main(int argc, char* argv[]) {
|
||||
std::unique_ptr<WindowsManagerFilter> wmfilter;
|
||||
if (source_hwnd)
|
||||
{
|
||||
HWND main_hwnd = (HWND)main_window->winId();
|
||||
|
||||
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::pause, main_window, MainWindow::togglePause);
|
||||
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(); });
|
||||
QObject::connect(wmfilter.get(), WindowsManagerFilter::dialogstatus, [main_hwnd](bool open){
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDDLGSTATUS, (WPARAM)(open ? 1 : 0), (LPARAM)main_hwnd);
|
||||
});
|
||||
|
||||
/* Native filter to catch VM-managers commands */
|
||||
app.installNativeEventFilter(wmfilter.get());
|
||||
|
||||
HWND main_hwnd = (HWND)main_window->winId();
|
||||
/* Filter to catch main window being blocked (by modal dialog) */
|
||||
main_window->installEventFilter(wmfilter.get());
|
||||
|
||||
/* Send main window HWND to manager */
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
|
||||
|
@@ -1500,4 +1500,9 @@ void MainWindow::showSettings()
|
||||
void MainWindow::hardReset()
|
||||
{
|
||||
ui->actionHard_Reset->trigger();
|
||||
}
|
||||
|
||||
void MainWindow::togglePause()
|
||||
{
|
||||
ui->actionPause->trigger();
|
||||
}
|
@@ -50,6 +50,7 @@ signals:
|
||||
public slots:
|
||||
void showSettings();
|
||||
void hardReset();
|
||||
void togglePause();
|
||||
private slots:
|
||||
void on_actionFullscreen_triggered();
|
||||
void on_actionSettings_triggered();
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "qt_winmanagerfilter.hpp"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <86box/win.h>
|
||||
|
||||
bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
@@ -59,4 +60,18 @@ bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void *
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WindowsManagerFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowBlocked)
|
||||
{
|
||||
emit dialogstatus(1);
|
||||
}
|
||||
else if (event->type() == QEvent::WindowUnblocked)
|
||||
{
|
||||
emit dialogstatus(0);
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
@@ -33,6 +33,8 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QByteArray>
|
||||
#include <QEvent>
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
#define result_t qintptr
|
||||
@@ -40,6 +42,10 @@
|
||||
#define result_t long
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Filters native events for messages from VM-manager and
|
||||
* window blocked events to notify about open modal dialogs.
|
||||
*/
|
||||
class WindowsManagerFilter : public QObject, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -53,6 +59,10 @@ signals:
|
||||
void showsettings();
|
||||
void reset();
|
||||
void shutdown();
|
||||
void dialogstatus(bool open);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user