From f27ce8d30ff3aac11485426fe9bee83981551623 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周三, 13 12月 2023 13:53:43 +0800 Subject: [PATCH] minor tweaks --- src/widgets/widgetwindowagent_win.cpp | 2 src/quick/quickwindowagent_win.cpp | 2 examples/mainwindow/mainwindow.cpp | 7 +++ src/core/contexts/win32windowcontext.cpp | 67 ++++++++++++++++----------------- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index f98f43f..c18fe5d 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -95,6 +95,13 @@ auto clockWidget = new ClockWidget(); clockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + connect(clockWidget, &QAbstractButton::clicked, this, [this]() { + if (!isMaximized()) { + showMaximized(); + } else { + showNormal(); + } + }); setMenuWidget(windowBar); setCentralWidget(clockWidget); diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index a706835..7dfd543 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -1937,7 +1937,7 @@ case WM_THEMECHANGED: case WM_SYSCOLORCHANGE: { - QEvent e(QEvent::UpdateRequest); + QEvent e(QEvent::UpdateLater); dispatch(&e); break; } @@ -1946,7 +1946,7 @@ const QColor color = QColor::fromRgba(wParam); const auto blendWithOpacity = *reinterpret_cast<LPBOOL>(lParam); - QEvent e(QEvent::UpdateRequest); + QEvent e(QEvent::UpdateLater); dispatch(&e); break; } @@ -1957,49 +1957,48 @@ const QColor color = getAccentColor(); } - QEvent e(QEvent::UpdateRequest); + QEvent e(QEvent::UpdateLater); dispatch(&e); break; } - case WM_SIZE: { - const bool max = wParam == SIZE_MAXIMIZED; - const bool min = wParam == SIZE_MINIMIZED; - const bool full = isFullScreen(hWnd); + // case WM_SIZE: { + // const bool max = wParam == SIZE_MAXIMIZED; + // const bool min = wParam == SIZE_MINIMIZED; + // const bool full = isFullScreen(hWnd); - Qt::WindowStates states{}; - if (max) { - states |= Qt::WindowMaximized; - } - if (min) { - states |= Qt::WindowMinimized; - } - if (full) { - states |= Qt::WindowFullScreen; - } + // Qt::WindowStates states{}; + // if (max) { + // states |= Qt::WindowMaximized; + // } + // if (min) { + // states |= Qt::WindowMinimized; + // } + // if (full) { + // states |= Qt::WindowFullScreen; + // } - QTimer::singleShot(0, this, [this, states] { - QWindowStateChangeEvent e(states); - dispatch(&e); - }); - break; - } + // // QTimer::singleShot(0, this, [this, states] { + // QWindowStateChangeEvent e(states); + // dispatch(&e); + // // }); + // break; + // } - case WM_ACTIVATE: { - const auto state = LOWORD(wParam); - const bool active = state == WA_ACTIVE || state == WA_CLICKACTIVE; - Q_UNUSED(state) + // case WM_ACTIVATE: { + // const auto state = LOWORD(wParam); + // const bool active = state == WA_ACTIVE || state == WA_CLICKACTIVE; + // Q_UNUSED(state) - QTimer::singleShot(0, this, [this, active] { - QEvent e(active ? QEvent::WindowActivate : QEvent::WindowDeactivate); - dispatch(&e); - }); - break; - } + // // QTimer::singleShot(0, this, [this, active] { + // QEvent e(active ? QEvent::WindowActivate : QEvent::WindowDeactivate); + // dispatch(&e); + // // }); + // break; + // } default: break; } return false; } - } diff --git a/src/quick/quickwindowagent_win.cpp b/src/quick/quickwindowagent_win.cpp index 8e57584..2049d29 100644 --- a/src/quick/quickwindowagent_win.cpp +++ b/src/quick/quickwindowagent_win.cpp @@ -82,7 +82,7 @@ bool BorderItem::observe(QEvent *event) { switch (event->type()) { - case QEvent::UpdateRequest: { + case QEvent::UpdateLater: { update(); break; } diff --git a/src/widgets/widgetwindowagent_win.cpp b/src/widgets/widgetwindowagent_win.cpp index 58d52dd..d2a49a2 100644 --- a/src/widgets/widgetwindowagent_win.cpp +++ b/src/widgets/widgetwindowagent_win.cpp @@ -34,7 +34,7 @@ protected: bool observe(QEvent *event) override { switch (event->type()) { - case QEvent::UpdateRequest: { + case QEvent::UpdateLater: { widget->update(); break; } -- Gitblit v1.9.1