Compare commits
No commits in common. "64a436258022977de7f22a6b62ebd4732618ce3b" and "9279500c18cffc5ed9bfbb8d3b80b6c412f9d185" have entirely different histories.
64a4362580
...
9279500c18
|
@ -986,7 +986,7 @@ static constexpr const std::array<Win32Message, 333> g_win32MessageMap =
|
||||||
if (it == g_win32UtilsData()->data.constEnd()) {
|
if (it == g_win32UtilsData()->data.constEnd()) {
|
||||||
return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
// https://github.com/qt/qtbase/blob/e26a87f1ecc40bc8c6aa5b889fce67410a57a702/src/plugins/platforms/windows/qwindowscontext.cpp#L1025
|
// https://github.com/qt/qtbase/blob/e26a87f1ecc40bc8c6aa5b889fce67410a57a702/src/plugins/platforms/windows/qwindowscontext.cpp#L1025C10-L1025C10
|
||||||
// We can see from the source code that Qt will filter out some messages first and then send the unfiltered
|
// We can see from the source code that Qt will filter out some messages first and then send the unfiltered
|
||||||
// messages to the event dispatcher. To activate the Snap Layout feature on Windows 11, we must process
|
// messages to the event dispatcher. To activate the Snap Layout feature on Windows 11, we must process
|
||||||
// some non-client area messages ourself, but unfortunately these messages have been filtered out already
|
// some non-client area messages ourself, but unfortunately these messages have been filtered out already
|
||||||
|
@ -997,14 +997,7 @@ static constexpr const std::array<Win32Message, 333> g_win32MessageMap =
|
||||||
// send it to our own custom native event filter to do all the magic works. But since the system menu feature
|
// send it to our own custom native event filter to do all the magic works. But since the system menu feature
|
||||||
// doesn't necessarily belong to the native implementation, we seperate the handling code and always process
|
// doesn't necessarily belong to the native implementation, we seperate the handling code and always process
|
||||||
// the system menu part in this function for both implementations.
|
// the system menu part in this function for both implementations.
|
||||||
//
|
if (!usePureQtImplementation()) {
|
||||||
// https://github.com/qt/qtbase/blob/946f15efb76fffda37b77f7d194d679b904305b1/src/plugins/platforms/windows/qwindowscontext.cpp#L1541
|
|
||||||
// However, we can't just do this when the message is non-client area size re-calculating, because Qt QPA will
|
|
||||||
// do some extra work after native event filter's handling to ensure Qt windows always have correct frame margins
|
|
||||||
// (and correct client area size, especially when the window is maximized/fullscreen). So we still go through
|
|
||||||
// the normal code path of the original qWindowsWndProc() function, but only for this specific message. It should
|
|
||||||
// be OK because Qt won't prevent us from handling WM_NCCALCSIZE.
|
|
||||||
if (!usePureQtImplementation() && (uMsg != WM_NCCALCSIZE)) {
|
|
||||||
MSG message;
|
MSG message;
|
||||||
SecureZeroMemory(&message, sizeof(message));
|
SecureZeroMemory(&message, sizeof(message));
|
||||||
message.hwnd = hWnd;
|
message.hwnd = hWnd;
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
#include <QtGui/qpainter.h>
|
#include <QtGui/qpainter.h>
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
#include <QtGui/qfontmetrics.h>
|
#include <QtGui/qfontmetrics.h>
|
||||||
#include <QtGui/qscreen.h>
|
|
||||||
#include <QtGui/qguiapplication.h>
|
|
||||||
#include <QtWidgets/qboxlayout.h>
|
#include <QtWidgets/qboxlayout.h>
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
@ -59,42 +57,6 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
static inline void emulateLeaveEvent(QWidget *widget)
|
|
||||||
{
|
|
||||||
Q_ASSERT(widget);
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QTimer::singleShot(0, widget, [widget](){
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
||||||
const QScreen *screen = widget->screen();
|
|
||||||
#else
|
|
||||||
const QScreen *screen = QGuiApplication::primaryScreen();
|
|
||||||
#endif
|
|
||||||
const QPoint globalPos = QCursor::pos(screen);
|
|
||||||
if (!QRect(widget->mapToGlobal(QPoint{ 0, 0 }), widget->size()).contains(globalPos)) {
|
|
||||||
QCoreApplication::postEvent(widget, new QEvent(QEvent::Leave));
|
|
||||||
if (widget->testAttribute(Qt::WA_Hover)) {
|
|
||||||
const QPoint localPos = widget->mapFromGlobal(globalPos);
|
|
||||||
const QPoint scenePos = widget->window()->mapFromGlobal(globalPos);
|
|
||||||
static constexpr const auto oldPos = QPoint{};
|
|
||||||
const Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
|
|
||||||
const auto event = new QHoverEvent(QEvent::HoverLeave, scenePos, globalPos, oldPos, modifiers);
|
|
||||||
Q_UNUSED(localPos);
|
|
||||||
#elif (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
|
|
||||||
const auto event = new QHoverEvent(QEvent::HoverLeave, localPos, globalPos, oldPos, modifiers);
|
|
||||||
Q_UNUSED(scenePos);
|
|
||||||
#else
|
|
||||||
const auto event = new QHoverEvent(QEvent::HoverLeave, localPos, oldPos, modifiers);
|
|
||||||
Q_UNUSED(scenePos);
|
|
||||||
#endif
|
|
||||||
QCoreApplication::postEvent(widget, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
StandardTitleBarPrivate::StandardTitleBarPrivate(StandardTitleBar *q) : QObject(q)
|
StandardTitleBarPrivate::StandardTitleBarPrivate(StandardTitleBar *q) : QObject(q)
|
||||||
{
|
{
|
||||||
Q_ASSERT(q);
|
Q_ASSERT(q);
|
||||||
|
@ -388,11 +350,6 @@ void StandardTitleBarPrivate::initialize()
|
||||||
} else {
|
} else {
|
||||||
window->showMaximized();
|
window->showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's a Qt issue that if a QAbstractButton::clicked triggers a window's maximization,
|
|
||||||
// the button remains to be hovered until the mouse move. As a result, we need to
|
|
||||||
// manully send leave events to the button.
|
|
||||||
emulateLeaveEvent(maximizeButton);
|
|
||||||
});
|
});
|
||||||
closeButton = new StandardSystemButton(SystemButtonType::Close, q);
|
closeButton = new StandardSystemButton(SystemButtonType::Close, q);
|
||||||
connect(closeButton, &StandardSystemButton::clicked, this, [this](){
|
connect(closeButton, &StandardSystemButton::clicked, this, [this](){
|
||||||
|
|
Loading…
Reference in New Issue