diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp index f5b9471..1418c20 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp @@ -5,10 +5,11 @@ #include #include +#include + #include #include #include // Fixes error C2504: 'IUnknown' : base class undefined -#include #include #pragma comment(lib, "Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved #pragma comment(lib, "User32.lib") @@ -18,7 +19,8 @@ // WS_SYSMENU: enables the context menu with the move, close, maximize, minize... commands (shift + right-click on the task bar item) // WS_CAPTION: enables aero minimize animation/transition // WS_MAXIMIZEBOX, WS_MINIMIZEBOX: enable minimize/maximize -enum class Style : DWORD { +enum class Style : DWORD +{ windowed = WS_OVERLAPPEDWINDOW | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX, aero_borderless = WS_POPUP | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX, basic_borderless = WS_POPUP | WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX @@ -35,7 +37,8 @@ static Style selectBorderLessStyle() } static void setShadow(HWND handle, bool enabled) { - if (isCompositionEnabled()) { + if (isCompositionEnabled()) + { static const MARGINS shadow_state[2] { { 0, 0, 0, 0 }, { 1, 1, 1, 1 } }; ::DwmExtendFrameIntoClientArea(handle, &shadow_state[enabled]); } @@ -43,51 +46,68 @@ static void setShadow(HWND handle, bool enabled) static long hitTest(RECT winrect, long x, long y, int borderWidth) { // 鼠标区域位于窗体边框,进行缩放 - if ((x >= winrect.left) && (x < winrect.left + borderWidth) && (y >= winrect.top) && (y < winrect.top + borderWidth)) { + if ((x >= winrect.left) && (x < winrect.left + borderWidth) && (y >= winrect.top) && (y < winrect.top + borderWidth)) + { return HTTOPLEFT; - } else if (x < winrect.right && x >= winrect.right - borderWidth && y >= winrect.top && y < winrect.top + borderWidth) { + } + else if (x < winrect.right && x >= winrect.right - borderWidth && y >= winrect.top && y < winrect.top + borderWidth) + { return HTTOPRIGHT; - } else if (x >= winrect.left && x < winrect.left + borderWidth && y < winrect.bottom && y >= winrect.bottom - borderWidth) { + } + else if (x >= winrect.left && x < winrect.left + borderWidth && y < winrect.bottom && y >= winrect.bottom - borderWidth) + { return HTBOTTOMLEFT; - } else if (x < winrect.right && x >= winrect.right - borderWidth && y < winrect.bottom && y >= winrect.bottom - borderWidth) { + } + else if (x < winrect.right && x >= winrect.right - borderWidth && y < winrect.bottom && y >= winrect.bottom - borderWidth) + { return HTBOTTOMRIGHT; - } else if (x >= winrect.left && x < winrect.left + borderWidth) { + } + else if (x >= winrect.left && x < winrect.left + borderWidth) + { return HTLEFT; - } else if (x < winrect.right && x >= winrect.right - borderWidth) { + } + else if (x < winrect.right && x >= winrect.right - borderWidth) + { return HTRIGHT; - } else if (y >= winrect.top && y < winrect.top + borderWidth) { + } + else if (y >= winrect.top && y < winrect.top + borderWidth) + { return HTTOP; - } else if (y < winrect.bottom && y >= winrect.bottom - borderWidth) { + } + else if (y < winrect.bottom && y >= winrect.bottom - borderWidth) + { return HTBOTTOM; - } else { + } + else + { return 0; } } -static bool isMaxWin(QWindow *win) +static bool isMaxWin(QWindow* win) { return win->windowState() == Qt::WindowMaximized; } -static bool isFullWin(QQuickView *win) +static bool isFullWin(QQuickView* win) { return win->windowState() == Qt::WindowFullScreen; } - class TaoFrameLessViewPrivate { public: bool m_isMax; - QQuickItem *m_titleItem = nullptr; - bool borderless = true; // is the window currently borderless + QQuickItem* m_titleItem = nullptr; + bool borderless = true; // is the window currently borderless bool borderless_resize = true; // should the window allow resizing by dragging the borders while borderless - bool borderless_drag = true; // should the window allow moving my dragging the client area + bool borderless_drag = true; // should the window allow moving my dragging the client area bool borderless_shadow = true; // should the window display a native aero shadow while borderless void setBorderLess(HWND handle, bool enabled) { auto newStyle = enabled ? selectBorderLessStyle() : Style::windowed; auto oldStyle = static_cast