snap layout: improve
This commit is contained in:
parent
f7368d0a08
commit
bdb1b5d68f
|
@ -58,6 +58,8 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
|
static constexpr const auto kMessageTag = WPARAM(2546789017);
|
||||||
|
|
||||||
FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow)
|
FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow)
|
||||||
FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW)
|
FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW)
|
||||||
FRAMELESSHELPER_STRING_CONSTANT(ScreenToClient)
|
FRAMELESSHELPER_STRING_CONSTANT(ScreenToClient)
|
||||||
|
@ -173,6 +175,11 @@ Q_GLOBAL_STATIC(FramelessWin32HelperInternal, g_framelessWin32HelperData)
|
||||||
return WindowPart::NotInterested;
|
return WindowPart::NotInterested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] static inline constexpr bool isTaggedMessage(const WPARAM wParam)
|
||||||
|
{
|
||||||
|
return (wParam == kMessageTag);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] static inline bool listenForMouseLeave(const HWND hWnd, const bool nonClient)
|
[[nodiscard]] static inline bool listenForMouseLeave(const HWND hWnd, const bool nonClient)
|
||||||
{
|
{
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
|
@ -340,7 +347,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
const auto emulateClientAreaMessage = [hWnd, uMsg, wParam, lParam](const std::optional<int> overrideMessage = std::nullopt) -> void {
|
const auto emulateClientAreaMessage = [hWnd, uMsg, wParam, lParam](const std::optional<int> overrideMessage = std::nullopt) -> void {
|
||||||
const auto wparam = [uMsg, wParam]() -> WPARAM {
|
const auto wparam = [uMsg, wParam]() -> WPARAM {
|
||||||
if (uMsg == WM_NCMOUSELEAVE) {
|
if (uMsg == WM_NCMOUSELEAVE) {
|
||||||
return 0;
|
return kMessageTag;
|
||||||
}
|
}
|
||||||
const quint64 keyState = Utils::getKeyState();
|
const quint64 keyState = Utils::getKeyState();
|
||||||
if ((uMsg >= WM_NCXBUTTONDOWN) && (uMsg <= WM_NCXBUTTONDBLCLK)) {
|
if ((uMsg >= WM_NCXBUTTONDOWN) && (uMsg <= WM_NCXBUTTONDBLCLK)) {
|
||||||
|
@ -424,7 +431,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (uMsg == WM_MOUSELEAVE) {
|
if ((uMsg == WM_MOUSELEAVE) && !isTaggedMessage(wParam)) {
|
||||||
// Qt will call TrackMouseEvent() to get the WM_MOUSELEAVE message when it receives
|
// Qt will call TrackMouseEvent() to get the WM_MOUSELEAVE message when it receives
|
||||||
// WM_MOUSEMOVE messages, and since we are converting every WM_NCMOUSEMOVE message
|
// WM_MOUSEMOVE messages, and since we are converting every WM_NCMOUSEMOVE message
|
||||||
// to WM_MOUSEMOVE message and send it back to the window to be able to hover our
|
// to WM_MOUSEMOVE message and send it back to the window to be able to hover our
|
||||||
|
@ -998,9 +1005,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
if (nowWindowPart == WindowPart::NotInterested) {
|
if (nowWindowPart == WindowPart::NotInterested) {
|
||||||
std::ignore = listenForMouseLeave(hWnd, false);
|
std::ignore = listenForMouseLeave(hWnd, false);
|
||||||
}
|
}
|
||||||
if ((previousWindowPart == WindowPart::ChromeButton) && (nowWindowPart == WindowPart::ClientArea)) {
|
if (previousWindowPart == WindowPart::ChromeButton) {
|
||||||
|
if (nowWindowPart == WindowPart::ClientArea) {
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
return true;
|
return true;
|
||||||
|
} else if (nowWindowPart == WindowPart::NotInterested) {
|
||||||
|
emulateClientAreaMessage(WM_NCMOUSELEAVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (uMsg == WM_NCMOUSEMOVE) {
|
if (uMsg == WM_NCMOUSEMOVE) {
|
||||||
|
|
|
@ -323,8 +323,6 @@ void StandardTitleBarPrivate::initialize()
|
||||||
this, &StandardTitleBarPrivate::updateTitleBarColor);
|
this, &StandardTitleBarPrivate::updateTitleBarColor);
|
||||||
connect(chromePalette, &ChromePalette::chromeButtonColorChanged,
|
connect(chromePalette, &ChromePalette::chromeButtonColorChanged,
|
||||||
this, &StandardTitleBarPrivate::updateChromeButtonColor);
|
this, &StandardTitleBarPrivate::updateChromeButtonColor);
|
||||||
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
||||||
q->setFixedHeight(kDefaultTitleBarHeight);
|
|
||||||
connect(window, &QWidget::windowIconChanged, this, [q](const QIcon &icon){
|
connect(window, &QWidget::windowIconChanged, this, [q](const QIcon &icon){
|
||||||
Q_UNUSED(icon);
|
Q_UNUSED(icon);
|
||||||
q->update();
|
q->update();
|
||||||
|
@ -337,7 +335,6 @@ void StandardTitleBarPrivate::initialize()
|
||||||
const auto titleBarLayout = new QHBoxLayout(q);
|
const auto titleBarLayout = new QHBoxLayout(q);
|
||||||
titleBarLayout->setSpacing(0);
|
titleBarLayout->setSpacing(0);
|
||||||
titleBarLayout->setContentsMargins(0, 0, 0, 0);
|
titleBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
q->setTitleLabelAlignment(Qt::AlignCenter);
|
|
||||||
#else // !Q_OS_MACOS
|
#else // !Q_OS_MACOS
|
||||||
minimizeButton = new StandardSystemButton(SystemButtonType::Minimize, q);
|
minimizeButton = new StandardSystemButton(SystemButtonType::Minimize, q);
|
||||||
connect(minimizeButton, &StandardSystemButton::clicked, window, &QWidget::showMinimized);
|
connect(minimizeButton, &StandardSystemButton::clicked, window, &QWidget::showMinimized);
|
||||||
|
@ -377,7 +374,6 @@ void StandardTitleBarPrivate::initialize()
|
||||||
titleBarLayout->setContentsMargins(0, 0, 0, 0);
|
titleBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
titleBarLayout->addStretch();
|
titleBarLayout->addStretch();
|
||||||
titleBarLayout->addLayout(systemButtonsOuterLayout);
|
titleBarLayout->addLayout(systemButtonsOuterLayout);
|
||||||
q->setTitleLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
updateTitleBarColor();
|
updateTitleBarColor();
|
||||||
|
@ -388,6 +384,13 @@ void StandardTitleBarPrivate::initialize()
|
||||||
StandardTitleBar::StandardTitleBar(QWidget *parent)
|
StandardTitleBar::StandardTitleBar(QWidget *parent)
|
||||||
: QWidget(parent), d_ptr(new StandardTitleBarPrivate(this))
|
: QWidget(parent), d_ptr(new StandardTitleBarPrivate(this))
|
||||||
{
|
{
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
setFixedHeight(kDefaultTitleBarHeight);
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
setTitleLabelAlignment(Qt::AlignCenter);
|
||||||
|
#else
|
||||||
|
setTitleLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardTitleBar::~StandardTitleBar() = default;
|
StandardTitleBar::~StandardTitleBar() = default;
|
||||||
|
|
Loading…
Reference in New Issue