From 94cb8729aaba1d2f2ee63d91f5cf6071ad0a4ace Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 22 Apr 2020 11:19:23 +0800 Subject: [PATCH] Update. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- README.md | 27 ++++++++++++++++++++++++++- winnativeeventfilter.cpp | 5 ++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 303b4a9..a20c9f3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,26 @@ ## Usage +### Windows + +```cpp +// include other files ... +#include "winnativeeventfilter.h" +// include other files ... + +// Anywhere you like, we use the main function here. +int main(int argc, char *argv[]) { + // ... + QWidget widget; + // Do this before the widget is shown. + WinNativeEventFilter::addFramelessWindow(reinterpret_cast(widget.winId())); + widget.show(); + // ... +} +``` + +### Linux and macOS + ```cpp // include other files ... #include "framelesshelper.h" @@ -36,7 +56,7 @@ Notes - Only top level windows can be frameless. Applying this code to child windows or widgets will result in unexpected behavior. - If you want to use your own border width, border height, titlebar height or minimum window size, just use the original numbers, no need to scale them according to DPI, this code will do the scaling automatically. -## Tested Platforms +## Supported Platforms - Windows 7 ~ 10 - Should work on X11, Wayland and macOS, but not tested. @@ -80,6 +100,11 @@ Notes - +### Windows Terminal + +- +- + ### GitHub - diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index ca2ba3f..d60baf2 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -468,7 +468,10 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, // window. On exit, the structure should contain the screen coordinates // of the corresponding window client area. const auto getClientAreaInsets = [](HWND _hWnd) -> RECT { - if (IsMaximized(_hWnd) || IsFullScreened(_hWnd)) { + // We don't need this correction when we're fullscreen. We will have + // the WS_POPUP size, so we don't have to worry about borders, and + // the default frame will be fine. + if (IsMaximized(_hWnd) || !IsFullScreened(_hWnd)) { // Windows automatically adds a standard width border to all // sides when a window is maximized. int frameThickness_x =