win: minor tweaks

This commit is contained in:
Yuhang Zhao 2023-08-24 13:10:11 +08:00
parent 4a1f5fb1f4
commit 01f3750efd
6 changed files with 468 additions and 58 deletions

View File

@ -81,7 +81,7 @@ FramelessApplicationWindow {
} }
Timer { Timer {
interval: 500 interval: 100
running: true running: true
repeat: true repeat: true
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss") onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")

View File

@ -81,7 +81,7 @@ FramelessWindow {
} }
Timer { Timer {
interval: 500 interval: 100
running: true running: true
repeat: true repeat: true
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss") onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")

View File

@ -54,7 +54,7 @@ FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio)
Widget::Widget(QWidget *parent) : FramelessWidget(parent) Widget::Widget(QWidget *parent) : FramelessWidget(parent)
{ {
initialize(); initialize();
startTimer(500); startTimer(100);
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet); connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
} }

View File

@ -86,6 +86,130 @@
#include <FramelessHelper/Core/framelesshelpercore_global.h> #include <FramelessHelper/Core/framelesshelpercore_global.h>
#ifndef WM_SIZEWAIT
# define WM_SIZEWAIT (0x0004)
#endif
#ifndef WM_SETVISIBLE
# define WM_SETVISIBLE (0x0009)
#endif
#ifndef WM_SYSTEMERROR
# define WM_SYSTEMERROR (0x0017)
#endif
#ifndef WM_CTLCOLOR
# define WM_CTLCOLOR (0x0019)
#endif
#ifndef WM_LOGOFF
# define WM_LOGOFF (0x0025)
#endif
#ifndef WM_ALTTABACTIVE
# define WM_ALTTABACTIVE (0x0029)
#endif
#ifndef WM_SHELLNOTIFY
# define WM_SHELLNOTIFY (0x0034)
#endif
#ifndef WM_ISACTIVEICON
# define WM_ISACTIVEICON (0x0035)
#endif
#ifndef WM_QUERYPARKICON
# define WM_QUERYPARKICON (0x0036)
#endif
#ifndef WM_WINHELP
# define WM_WINHELP (0x0038)
#endif
#ifndef WM_FULLSCREEN
# define WM_FULLSCREEN (0x003A)
#endif
#ifndef WM_CLIENTSHUTDOWN
# define WM_CLIENTSHUTDOWN (0x003B)
#endif
#ifndef WM_DDEMLEVENT
# define WM_DDEMLEVENT (0x003C)
#endif
#ifndef WM_TESTING
# define WM_TESTING (0x0040)
#endif
#ifndef WM_OTHERWINDOWCREATED
# define WM_OTHERWINDOWCREATED (0x0042)
#endif
#ifndef WM_OTHERWINDOWDESTROYED
# define WM_OTHERWINDOWDESTROYED (0x0043)
#endif
#ifndef WM_COPYGLOBALDATA
# define WM_COPYGLOBALDATA (0x0049)
#endif
#ifndef WM_KEYF1
# define WM_KEYF1 (0x004D)
#endif
#ifndef WM_ACCESS_WINDOW
# define WM_ACCESS_WINDOW (0x004F)
#endif
#ifndef WM_FINALDESTROY
# define WM_FINALDESTROY (0x0070)
#endif
#ifndef WM_MEASUREITEM_CLIENTDATA
# define WM_MEASUREITEM_CLIENTDATA (0x0071)
#endif
#ifndef WM_SYNCTASK
# define WM_SYNCTASK (0x0089)
#endif
#ifndef WM_KLUDGEMINRECT
# define WM_KLUDGEMINRECT (0x008B)
#endif
#ifndef WM_LPKDRAWSWITCHWND
# define WM_LPKDRAWSWITCHWND (0x008C)
#endif
#ifndef WM_UAHDESTROYWINDOW
# define WM_UAHDESTROYWINDOW (0x0090)
#endif
#ifndef WM_UAHDRAWMENU
# define WM_UAHDRAWMENU (0x0091)
#endif
#ifndef WM_UAHDRAWMENUITEM
# define WM_UAHDRAWMENUITEM (0x0092)
#endif
#ifndef WM_UAHINITMENU
# define WM_UAHINITMENU (0x0093)
#endif
#ifndef WM_UAHMEASUREMENUITEM
# define WM_UAHMEASUREMENUITEM (0x0094)
#endif
#ifndef WM_UAHNCPAINTMENUPOPUP
# define WM_UAHNCPAINTMENUPOPUP (0x0095)
#endif
#ifndef WM_UAHUPDATE
# define WM_UAHUPDATE (0x0096)
#endif
#ifndef WM_NCUAHDRAWCAPTION #ifndef WM_NCUAHDRAWCAPTION
# define WM_NCUAHDRAWCAPTION (0x00AE) # define WM_NCUAHDRAWCAPTION (0x00AE)
#endif #endif
@ -94,6 +218,206 @@
# define WM_NCUAHDRAWFRAME (0x00AF) # define WM_NCUAHDRAWFRAME (0x00AF)
#endif #endif
#ifndef WM_YOMICHAR
# define WM_YOMICHAR (0x0108)
#endif
#ifndef WM_CONVERTREQUEST
# define WM_CONVERTREQUEST (0x010A)
#endif
#ifndef WM_CONVERTRESULT
# define WM_CONVERTRESULT (0x010B)
#endif
#ifndef WM_INTERIM
# define WM_INTERIM (0x010C)
#endif
#ifndef WM_SYSTIMER
# define WM_SYSTIMER (0x0118)
#endif
#ifndef WM_GESTUREINPUT
# define WM_GESTUREINPUT (0x011B)
#endif
#ifndef WM_GESTURENOTIFIED
# define WM_GESTURENOTIFIED (0x011C)
#endif
#ifndef WM_LBTRACKPOINT
# define WM_LBTRACKPOINT (0x0131)
#endif
#ifndef WM_DROPOBJECT
# define WM_DROPOBJECT (0x022A)
#endif
#ifndef WM_QUERYDROPOBJECT
# define WM_QUERYDROPOBJECT (0x022B)
#endif
#ifndef WM_BEGINDRAG
# define WM_BEGINDRAG (0x022C)
#endif
#ifndef WM_DRAGLOOP
# define WM_DRAGLOOP (0x022D)
#endif
#ifndef WM_DRAGSELECT
# define WM_DRAGSELECT (0x022E)
#endif
#ifndef WM_DRAGMOVE
# define WM_DRAGMOVE (0x022F)
#endif
#ifndef WM_STOPINERTIA
# define WM_STOPINERTIA (0x023B)
#endif
#ifndef WM_ENDINERTIA
# define WM_ENDINERTIA (0x023C)
#endif
#ifndef WM_EDGYINERTIA
# define WM_EDGYINERTIA (0x023D)
#endif
#ifndef WM_VISIBILITYCHANGED
# define WM_VISIBILITYCHANGED (0x0270)
#endif
#ifndef WM_VIEWSTATECHANGED
# define WM_VIEWSTATECHANGED (0x0271)
#endif
#ifndef WM_UNREGISTER_WINDOW_SERVICES
# define WM_UNREGISTER_WINDOW_SERVICES (0x0272)
#endif
#ifndef WM_CONSOLIDATED
# define WM_CONSOLIDATED (0x0273)
#endif
#ifndef WM_IME_REPORT
# define WM_IME_REPORT (0x0280)
#endif
#ifndef WM_IME_SYSTEM
# define WM_IME_SYSTEM (0x0287)
#endif
#ifndef WM_POINTERDEVICEADDED
# define WM_POINTERDEVICEADDED (0x02C8)
#endif
#ifndef WM_POINTERDEVICEDELETED
# define WM_POINTERDEVICEDELETED (0x02C9)
#endif
#ifndef WM_FLICK
# define WM_FLICK (0x02CB)
#endif
#ifndef WM_FLICKINTERNAL
# define WM_FLICKINTERNAL (0x02CD)
#endif
#ifndef WM_BRIGHTNESSCHANGED
# define WM_BRIGHTNESSCHANGED (0x02CE)
#endif
#ifndef WM_SYSMENU
# define WM_SYSMENU (0x0313)
#endif
#ifndef WM_HOOKMSG
# define WM_HOOKMSG (0x0314)
#endif
#ifndef WM_EXITPROCESS
# define WM_EXITPROCESS (0x0315)
#endif
#ifndef WM_WAKETHREAD
# define WM_WAKETHREAD (0x0316)
#endif
#ifndef WM_UAHINIT
# define WM_UAHINIT (0x031B)
#endif
#ifndef WM_DESKTOPNOTIFY
# define WM_DESKTOPNOTIFY (0x031C)
#endif
#ifndef WM_DWMEXILEFRAME
# define WM_DWMEXILEFRAME (0x0322)
#endif
#ifndef WM_MAGNIFICATION_STARTED
# define WM_MAGNIFICATION_STARTED (0x0324)
#endif
#ifndef WM_MAGNIFICATION_ENDED
# define WM_MAGNIFICATION_ENDED (0x0325)
#endif
#ifndef WM_DWMTHUMBNAILSIZECHANGED
# define WM_DWMTHUMBNAILSIZECHANGED (0x0327)
#endif
#ifndef WM_MAGNIFICATION_OUTPUT
# define WM_MAGNIFICATION_OUTPUT (0x0328)
#endif
#ifndef WM_BSDRDATA
# define WM_BSDRDATA (0x0329)
#endif
#ifndef WM_DWMTRANSITIONSTATECHANGED
# define WM_DWMTRANSITIONSTATECHANGED (0x032A)
#endif
#ifndef WM_KEYBOARDCORRECTIONCALLOUT
# define WM_KEYBOARDCORRECTIONCALLOUT (0x032C)
#endif
#ifndef WM_KEYBOARDCORRECTIONACTION
# define WM_KEYBOARDCORRECTIONACTION (0x032D)
#endif
#ifndef WM_UIACTION
# define WM_UIACTION (0x032E)
#endif
#ifndef WM_ROUTED_UI_EVENT
# define WM_ROUTED_UI_EVENT (0x032F)
#endif
#ifndef WM_MEASURECONTROL
# define WM_MEASURECONTROL (0x0330)
#endif
#ifndef WM_GETACTIONTEXT
# define WM_GETACTIONTEXT (0x0331)
#endif
#ifndef WM_FORWARDKEYDOWN
# define WM_FORWARDKEYDOWN (0x0333)
#endif
#ifndef WM_FORWARDKEYUP
# define WM_FORWARDKEYUP (0x0334)
#endif
#ifndef WM_NOTIFYWOW
# define WM_NOTIFYWOW (0x0340)
#endif
#ifndef WM_DWMCOMPOSITIONCHANGED #ifndef WM_DWMCOMPOSITIONCHANGED
# define WM_DWMCOMPOSITIONCHANGED (0x031E) # define WM_DWMCOMPOSITIONCHANGED (0x031E)
#endif #endif

View File

@ -242,7 +242,7 @@ struct Win32Message
}; };
#define DEFINE_WIN32_MESSAGE(Message) Win32Message{ Message, #Message }, #define DEFINE_WIN32_MESSAGE(Message) Win32Message{ Message, #Message },
static constexpr const std::array<Win32Message, 252> g_win32MessageMap = static constexpr const std::array<Win32Message, 333> g_win32MessageMap =
{ {
DEFINE_WIN32_MESSAGE(WM_NULL) DEFINE_WIN32_MESSAGE(WM_NULL)
DEFINE_WIN32_MESSAGE(WM_CREATE) DEFINE_WIN32_MESSAGE(WM_CREATE)
@ -376,7 +376,6 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
DEFINE_WIN32_MESSAGE(WM_CTLCOLORDLG) DEFINE_WIN32_MESSAGE(WM_CTLCOLORDLG)
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSCROLLBAR) DEFINE_WIN32_MESSAGE(WM_CTLCOLORSCROLLBAR)
DEFINE_WIN32_MESSAGE(WM_CTLCOLORSTATIC) DEFINE_WIN32_MESSAGE(WM_CTLCOLORSTATIC)
DEFINE_WIN32_MESSAGE(MN_GETHMENU)
DEFINE_WIN32_MESSAGE(WM_MOUSEMOVE) // WM_MOUSEFIRST DEFINE_WIN32_MESSAGE(WM_MOUSEMOVE) // WM_MOUSEFIRST
DEFINE_WIN32_MESSAGE(WM_LBUTTONDOWN) DEFINE_WIN32_MESSAGE(WM_LBUTTONDOWN)
DEFINE_WIN32_MESSAGE(WM_LBUTTONUP) DEFINE_WIN32_MESSAGE(WM_LBUTTONUP)
@ -433,7 +432,6 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
DEFINE_WIN32_MESSAGE(WM_TOUCHHITTESTING) DEFINE_WIN32_MESSAGE(WM_TOUCHHITTESTING)
DEFINE_WIN32_MESSAGE(WM_POINTERWHEEL) DEFINE_WIN32_MESSAGE(WM_POINTERWHEEL)
DEFINE_WIN32_MESSAGE(WM_POINTERHWHEEL) DEFINE_WIN32_MESSAGE(WM_POINTERHWHEEL)
DEFINE_WIN32_MESSAGE(DM_POINTERHITTEST)
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDTO) DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDTO)
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDAWAY) DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDAWAY)
DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDRELEASED) DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDRELEASED)
@ -496,6 +494,90 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
DEFINE_WIN32_MESSAGE(WM_PENWINLAST) DEFINE_WIN32_MESSAGE(WM_PENWINLAST)
DEFINE_WIN32_MESSAGE(WM_APP) DEFINE_WIN32_MESSAGE(WM_APP)
DEFINE_WIN32_MESSAGE(WM_USER) DEFINE_WIN32_MESSAGE(WM_USER)
// Undocumented messages:
DEFINE_WIN32_MESSAGE(WM_SIZEWAIT)
DEFINE_WIN32_MESSAGE(WM_SETVISIBLE)
DEFINE_WIN32_MESSAGE(WM_SYSTEMERROR)
DEFINE_WIN32_MESSAGE(WM_CTLCOLOR)
DEFINE_WIN32_MESSAGE(WM_LOGOFF)
DEFINE_WIN32_MESSAGE(WM_ALTTABACTIVE)
DEFINE_WIN32_MESSAGE(WM_SHELLNOTIFY)
DEFINE_WIN32_MESSAGE(WM_ISACTIVEICON)
DEFINE_WIN32_MESSAGE(WM_QUERYPARKICON)
DEFINE_WIN32_MESSAGE(WM_WINHELP)
DEFINE_WIN32_MESSAGE(WM_FULLSCREEN)
DEFINE_WIN32_MESSAGE(WM_CLIENTSHUTDOWN)
DEFINE_WIN32_MESSAGE(WM_DDEMLEVENT)
DEFINE_WIN32_MESSAGE(WM_TESTING)
DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWCREATED)
DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWDESTROYED)
DEFINE_WIN32_MESSAGE(WM_COPYGLOBALDATA)
DEFINE_WIN32_MESSAGE(WM_KEYF1)
DEFINE_WIN32_MESSAGE(WM_ACCESS_WINDOW)
DEFINE_WIN32_MESSAGE(WM_FINALDESTROY)
DEFINE_WIN32_MESSAGE(WM_MEASUREITEM_CLIENTDATA)
DEFINE_WIN32_MESSAGE(WM_SYNCTASK)
DEFINE_WIN32_MESSAGE(WM_KLUDGEMINRECT)
DEFINE_WIN32_MESSAGE(WM_LPKDRAWSWITCHWND)
DEFINE_WIN32_MESSAGE(WM_UAHDESTROYWINDOW)
DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENU)
DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENUITEM)
DEFINE_WIN32_MESSAGE(WM_UAHINITMENU)
DEFINE_WIN32_MESSAGE(WM_UAHMEASUREMENUITEM)
DEFINE_WIN32_MESSAGE(WM_UAHNCPAINTMENUPOPUP)
DEFINE_WIN32_MESSAGE(WM_UAHUPDATE)
DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWCAPTION)
DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWFRAME)
DEFINE_WIN32_MESSAGE(WM_YOMICHAR)
DEFINE_WIN32_MESSAGE(WM_CONVERTREQUEST)
DEFINE_WIN32_MESSAGE(WM_CONVERTRESULT)
DEFINE_WIN32_MESSAGE(WM_INTERIM)
DEFINE_WIN32_MESSAGE(WM_SYSTIMER)
DEFINE_WIN32_MESSAGE(WM_GESTUREINPUT)
DEFINE_WIN32_MESSAGE(WM_GESTURENOTIFIED)
DEFINE_WIN32_MESSAGE(WM_LBTRACKPOINT)
DEFINE_WIN32_MESSAGE(WM_DROPOBJECT)
DEFINE_WIN32_MESSAGE(WM_QUERYDROPOBJECT)
DEFINE_WIN32_MESSAGE(WM_BEGINDRAG)
DEFINE_WIN32_MESSAGE(WM_DRAGLOOP)
DEFINE_WIN32_MESSAGE(WM_DRAGSELECT)
DEFINE_WIN32_MESSAGE(WM_DRAGMOVE)
DEFINE_WIN32_MESSAGE(WM_STOPINERTIA)
DEFINE_WIN32_MESSAGE(WM_ENDINERTIA)
DEFINE_WIN32_MESSAGE(WM_EDGYINERTIA)
DEFINE_WIN32_MESSAGE(WM_VISIBILITYCHANGED)
DEFINE_WIN32_MESSAGE(WM_VIEWSTATECHANGED)
DEFINE_WIN32_MESSAGE(WM_UNREGISTER_WINDOW_SERVICES)
DEFINE_WIN32_MESSAGE(WM_CONSOLIDATED)
DEFINE_WIN32_MESSAGE(WM_IME_REPORT)
DEFINE_WIN32_MESSAGE(WM_IME_SYSTEM)
DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEADDED)
DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEDELETED)
DEFINE_WIN32_MESSAGE(WM_FLICK)
DEFINE_WIN32_MESSAGE(WM_FLICKINTERNAL)
DEFINE_WIN32_MESSAGE(WM_BRIGHTNESSCHANGED)
DEFINE_WIN32_MESSAGE(WM_SYSMENU)
DEFINE_WIN32_MESSAGE(WM_HOOKMSG)
DEFINE_WIN32_MESSAGE(WM_EXITPROCESS)
DEFINE_WIN32_MESSAGE(WM_WAKETHREAD)
DEFINE_WIN32_MESSAGE(WM_UAHINIT)
DEFINE_WIN32_MESSAGE(WM_DESKTOPNOTIFY)
DEFINE_WIN32_MESSAGE(WM_DWMEXILEFRAME)
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_STARTED)
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_ENDED)
DEFINE_WIN32_MESSAGE(WM_DWMTHUMBNAILSIZECHANGED)
DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_OUTPUT)
DEFINE_WIN32_MESSAGE(WM_BSDRDATA)
DEFINE_WIN32_MESSAGE(WM_DWMTRANSITIONSTATECHANGED)
DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONCALLOUT)
DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONACTION)
DEFINE_WIN32_MESSAGE(WM_UIACTION)
DEFINE_WIN32_MESSAGE(WM_ROUTED_UI_EVENT)
DEFINE_WIN32_MESSAGE(WM_MEASURECONTROL)
DEFINE_WIN32_MESSAGE(WM_GETACTIONTEXT)
DEFINE_WIN32_MESSAGE(WM_FORWARDKEYDOWN)
DEFINE_WIN32_MESSAGE(WM_FORWARDKEYUP)
DEFINE_WIN32_MESSAGE(WM_NOTIFYWOW)
}; };
#undef DEFINE_WIN32_MESSAGE #undef DEFINE_WIN32_MESSAGE
@ -804,8 +886,7 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
{ {
if (edges == Qt::Edges{}) { if (edges == Qt::Edges{}) {
return 0; return 0;
} } else if (edges == (Qt::LeftEdge)) {
if (edges == (Qt::LeftEdge)) {
return 0xF001; // SC_SIZELEFT return 0xF001; // SC_SIZELEFT
} else if (edges == (Qt::RightEdge)) { } else if (edges == (Qt::RightEdge)) {
return 0xF002; // SC_SIZERIGHT return 0xF002; // SC_SIZERIGHT
@ -840,22 +921,15 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
[[nodiscard]] static inline bool isNonClientMessage(const UINT message) [[nodiscard]] static inline bool isNonClientMessage(const UINT message)
{ {
if ((message >= WM_NCCREATE) && (message <= WM_NCACTIVATE)) { if (((message >= WM_NCCREATE) && (message <= WM_NCACTIVATE))
|| ((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
|| ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK))
|| ((message >= WM_NCPOINTERUPDATE) && (message <= WM_NCPOINTERUP))
|| ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) {
return true; return true;
} else {
return false;
} }
if ((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK)) {
return true;
}
if ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK)) {
return true;
}
if ((message >= WM_NCPOINTERUPDATE) && (message <= WM_NCPOINTERUP)) {
return true;
}
if ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE)) {
return true;
}
return false;
} }
[[nodiscard]] static inline bool isMouseMessage(const UINT message, bool *isNonClient = nullptr) [[nodiscard]] static inline bool isMouseMessage(const UINT message, bool *isNonClient = nullptr)
@ -866,16 +940,16 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
*isNonClient = false; *isNonClient = false;
} }
return true; return true;
} } else if (((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
if (((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK))
|| ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK)) || ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK))
|| ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) { || ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) {
if (isNonClient) { if (isNonClient) {
*isNonClient = true; *isNonClient = true;
} }
return true; return true;
} else {
return false;
} }
return false;
} }
[[nodiscard]] static inline bool usePureQtImplementation() [[nodiscard]] static inline bool usePureQtImplementation()
@ -892,16 +966,32 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
return 0; return 0;
} }
if (isWin32MessageDebuggingEnabled()) { if (isWin32MessageDebuggingEnabled()) {
const auto it = std::find(g_win32MessageMap.cbegin(), g_win32MessageMap.cend(), Win32Message{ uMsg, nullptr }); const QString messageCodeHex = FRAMELESSHELPER_STRING_LITERAL("0x") + QString::number(uMsg, 16).toUpper().rightJustified(4, u'0');
if (it != g_win32MessageMap.cend()) { QString text = {};
QString text = {}; QTextStream stream(&text);
QTextStream stream(&text); stream << "Win32 message received: ";
stream << "Win32 message received: " << it->Str << " (0x" if (uMsg >= WM_APP) {
<< QString::number(uMsg, 16).toUpper().rightJustified(4, u'0') << ')'; const UINT diff = (uMsg - WM_APP);
stream << "WM_APP + " << diff << " (" << messageCodeHex
<< ") [private message owned by current application]";
} else if (uMsg >= WM_USER) {
const UINT diff = (uMsg - WM_USER);
stream << "WM_USER + " << diff << " (" << messageCodeHex
<< ") [private message owned by all kinds of controls]";
} else {
const auto it = std::find(g_win32MessageMap.cbegin(), g_win32MessageMap.cend(), Win32Message{ uMsg, nullptr });
if (it == g_win32MessageMap.cend()) {
stream << "UNKNOWN";
} else {
stream << it->Str;
}
stream << " (" << messageCodeHex << ')';
auto screenPos = POINT{ 0, 0 };
auto clientPos = POINT{ 0, 0 };
bool isNonClientMouseMessage = false; bool isNonClientMouseMessage = false;
if (isMouseMessage(uMsg, &isNonClientMouseMessage)) { if (isMouseMessage(uMsg, &isNonClientMouseMessage)) {
if (isNonClientMouseMessage) { if (isNonClientMouseMessage) {
const auto screenPos = [uMsg, lParam]() -> POINT { screenPos = [uMsg, lParam]() -> POINT {
if (uMsg == WM_NCMOUSELEAVE) { if (uMsg == WM_NCMOUSELEAVE) {
const DWORD dwScreenPos = ::GetMessagePos(); const DWORD dwScreenPos = ::GetMessagePos();
return POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) }; return POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
@ -909,42 +999,35 @@ static constexpr const std::array<Win32Message, 252> g_win32MessageMap =
return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
} }
}(); }();
POINT clientPos = screenPos; clientPos = screenPos;
if (::ScreenToClient(hWnd, &clientPos) == FALSE) { if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
WARNING << Utils::getSystemErrorMessage(kScreenToClient); WARNING << Utils::getSystemErrorMessage(kScreenToClient);
clientPos = {}; clientPos = {};
} }
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
<< screenPos.y << "), client coordinate: POINT(x: "
<< clientPos.x << ", y: " << clientPos.y << ')';
} else { } else {
const auto clientPos = [hWnd, uMsg, lParam]() -> POINT { if (uMsg == WM_MOUSELEAVE) {
if (uMsg == WM_MOUSELEAVE) { const DWORD dwScreenPos = ::GetMessagePos();
const DWORD dwScreenPos = ::GetMessagePos(); screenPos = POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) };
const auto screenPos = POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) }; clientPos = screenPos;
POINT clientPos = screenPos; if (::ScreenToClient(hWnd, &clientPos) == FALSE) {
if (::ScreenToClient(hWnd, &clientPos) == FALSE) { WARNING << Utils::getSystemErrorMessage(kScreenToClient);
WARNING << Utils::getSystemErrorMessage(kScreenToClient); clientPos = {};
return {}; }
} else { } else {
return clientPos; clientPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
} screenPos = clientPos;
} else { if (::ClientToScreen(hWnd, &screenPos) == FALSE) {
return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; WARNING << Utils::getSystemErrorMessage(kClientToScreen);
screenPos = {};
} }
}();
POINT screenPos = clientPos;
if (::ClientToScreen(hWnd, &screenPos) == FALSE) {
WARNING << Utils::getSystemErrorMessage(kClientToScreen);
screenPos = {};
} }
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
<< screenPos.y << "), client coordinate: POINT(x: "
<< clientPos.x << ", y: " << clientPos.y << ')';
} }
stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: "
<< screenPos.y << "), client coordinate: POINT(x: "
<< clientPos.x << ", y: " << clientPos.y << ')';
} }
DEBUG.noquote() << text;
} }
DEBUG.noquote() << text;
} }
const auto windowId = reinterpret_cast<WId>(hWnd); const auto windowId = reinterpret_cast<WId>(hWnd);
const auto it = g_win32UtilsData()->data.constFind(windowId); const auto it = g_win32UtilsData()->data.constFind(windowId);

View File

@ -374,6 +374,9 @@ bool StandardTitleBarPrivate::mouseEventHandler(QMouseEvent *event)
QRect StandardTitleBarPrivate::windowIconRect() const QRect StandardTitleBarPrivate::windowIconRect() const
{ {
Q_Q(const StandardTitleBar); Q_Q(const StandardTitleBar);
if (!windowIconVisible_real()) {
return {};
}
const QSize size = windowIconSize(); const QSize size = windowIconSize();
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
const auto x = [this, q, &size]() -> int { const auto x = [this, q, &size]() -> int {