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;
|
std::unique_ptr<WindowsManagerFilter> wmfilter;
|
||||||
if (source_hwnd)
|
if (source_hwnd)
|
||||||
{
|
{
|
||||||
|
HWND main_hwnd = (HWND)main_window->winId();
|
||||||
|
|
||||||
wmfilter.reset(new WindowsManagerFilter());
|
wmfilter.reset(new WindowsManagerFilter());
|
||||||
QObject::connect(wmfilter.get(), WindowsManagerFilter::showsettings, main_window, MainWindow::showSettings);
|
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::reset, main_window, MainWindow::hardReset);
|
||||||
QObject::connect(wmfilter.get(), WindowsManagerFilter::shutdown, [](){ plat_power_off(); });
|
QObject::connect(wmfilter.get(), WindowsManagerFilter::shutdown, [](){ plat_power_off(); });
|
||||||
QObject::connect(wmfilter.get(), WindowsManagerFilter::ctrlaltdel, [](){ pc_send_cad(); });
|
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());
|
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 */
|
/* Send main window HWND to manager */
|
||||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
|
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
|
||||||
|
@@ -1501,3 +1501,8 @@ void MainWindow::hardReset()
|
|||||||
{
|
{
|
||||||
ui->actionHard_Reset->trigger();
|
ui->actionHard_Reset->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::togglePause()
|
||||||
|
{
|
||||||
|
ui->actionPause->trigger();
|
||||||
|
}
|
@@ -50,6 +50,7 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void showSettings();
|
void showSettings();
|
||||||
void hardReset();
|
void hardReset();
|
||||||
|
void togglePause();
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionFullscreen_triggered();
|
void on_actionFullscreen_triggered();
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "qt_winmanagerfilter.hpp"
|
#include "qt_winmanagerfilter.hpp"
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
#include <86box/win.h>
|
#include <86box/win.h>
|
||||||
|
|
||||||
bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||||
@@ -60,3 +61,17 @@ bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
|
|
||||||
return false;
|
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 <QObject>
|
||||||
#include <QAbstractNativeEventFilter>
|
#include <QAbstractNativeEventFilter>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
#if QT_VERSION_MAJOR >= 6
|
||||||
#define result_t qintptr
|
#define result_t qintptr
|
||||||
@@ -40,6 +42,10 @@
|
|||||||
#define result_t long
|
#define result_t long
|
||||||
#endif
|
#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
|
class WindowsManagerFilter : public QObject, public QAbstractNativeEventFilter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -53,6 +59,10 @@ signals:
|
|||||||
void showsettings();
|
void showsettings();
|
||||||
void reset();
|
void reset();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
void dialogstatus(bool open);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user