Commit Graph

999 Commits

Author SHA1 Message Date
zhengchangfa 7d844ab95f fix compile 2020-12-08 15:21:18 +08:00
Yuhang Zhao ca2a3be39d Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-05 21:55:26 +08:00
Yuhang Zhao 6c76dda4f0 Update README.md
Adapt to the latest changes in code.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-04 11:52:59 +08:00
Yuhang Zhao ff9dddef76 Update README_win32.md
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-04 11:48:39 +08:00
Yuhang Zhao 684b05ccad Simplify FramelessHelper code
Remove unused code.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-04 11:41:54 +08:00
Yuhang Zhao ba4095251d Fix Qt 5.12 build
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-02 16:40:21 +08:00
Yuhang Zhao a610c84a3c QWidget2: Fix Qt 5.12 build
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-01 17:56:56 +08:00
Yuhang Zhao 27be916e11 Simplify the code a bit
Introduce a small helper function to simplify the code a bit.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-28 12:10:22 +08:00
Yuhang Zhao 68bc4c31ed Cleanup
WinNativeEventFilter:
1. Removed all unused functions and macros.
Win32 API prototypes are not touched because
we may still need them in the future.
2. Don't store data through SetWindowLongPtrW,
using dynamic properties of QWindow instead.
People may rely on GetWindowLongPtrW(hwnd, GWLP_USERDATA)
to do their own work.
3. Some helper functions are removed, such as
moveWindowToDesktopCenter(). You can implement them
yourself. Keep them in the source code will keep
pulling in new dependencies so I have to get rid
of them.
4. Some blocks are removed, such as WM_GETMINMAXIINFO.
It's not needed. You can call Qt's standard API now,
such as setMaximumSize() and setMinimumSize().

FramelessQuickHelper:
1. Removed all functions that can be replaced by Qt's
own API, such as setMaximumSize() and setMinimumSize().
2. Removed helper functions, such as moveWindowToDesktopCenter().
You can implement them yourself. Just few lines of code.

FramelessWindowsManager:
Adapt to the above changes.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-28 11:54:56 +08:00
Yuhang Zhao b601d083bf Fix crash in many cases
Check whether the QWindow is null

Fixes: #37

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-27 18:55:45 +08:00
Yuhang Zhao 84ce2eb418 Simplify the code a bit
There is a type called QObjectList already.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-20 20:52:12 +08:00
Yuhang Zhao 095731d741 Minor improvement.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-20 13:43:02 +08:00
Yuhang Zhao 8e78e275e4 Add a cross-platform frameless window example
Written in pure Qt. Cross-platform.
Lacking the system features on Windows of course.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-19 12:20:11 +08:00
Yuhang Zhao e5cd434500 Simplify style sheet
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-18 16:46:40 +08:00
Yuhang Zhao bd60d9d1d2 Remove the widget and quick dependency for UNIX as well
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-18 12:07:29 +08:00
Yuhang Zhao f258cf3ae4 Fix Qt 5 build
We need the platformwindow.h for Qt5 as well.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-17 15:18:35 +08:00
Yuhang Zhao 137019f7e6 Refactor
Use QWindow pointer on all platforms.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-17 15:08:39 +08:00
Yuhang Zhao 4c65cba578 Update CMakeList file
Adapt to the previous commit.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-17 10:58:16 +08:00
Yuhang Zhao d3f2ad8658 Merge remote-tracking branch 'origin/win32-clean-dependency' into master
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-16 23:03:47 +08:00
Yuhang Zhao b672851f51 Win32: Remove the dependency of the widgets and quick module
This commit totally removed the dependency of the widgets
and quick modules for the Windows platform. Now the library
itself only depends on the core and gui modules. Currently
no bug can be found. But there are some side effects: one is
we can't set a palette for a widget due to we can't access
QWidget specific functions so if you want to enable blur
effect, you will have to do this by yourself. Another one is
you now have to pass the window handle to WinNativeEventFilter
instead of the pointer of a QObject. Before this patch, I'm
using QWidget::winId() to get the window handle, now we have
get rid of the widgets dependency so I can't get the window
handle now, you have to pass it explicitly. And it leads to
huge refactoring of the whole repository. But I think it's
worth doing. If anyone knows how to get the window handle
without introducing new dependencies, please tell me. It will
help me a lot.

To remove the quick dependency, the FramelessQuickHelper class
is moved out of the library now. If your project needs it,
please copy the files to your project and include them directly.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-16 23:01:00 +08:00
Yuhang Zhao 74d865a3e3 Fix a multi-screen bug
Before this patch, the maximum size of a frameless window
will be limited to the primary screen's size if the user
doesn't set a maximum window size explicitly.

It works fine on single screen cases, however, if you have
multiple screens and when you are trying to resize the window
to some size bigger than the primary screen, such as expand
it from one screen to another, the window will refuse to
continue resizing after it reaches the primary screen's size.

The solution is simple and straightforward: if the user doesn't
set the maximum window size explicitly, just don't set the maximum
size to let it can be resized without any limitations.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-16 18:13:52 +08:00
Yuhang Zhao 8ca84fd435 Fix a regression.
If the user set a custom title bar height, just return
the original value, don't plus the border height afterwards,
this is not what the user would want.

But if we are querying the standard value, it should be
border height + caption height.

Border width and border height don't have this issue.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-16 17:15:06 +08:00
Yuhang Zhao 9cb3392ce4 Fix system metric is double scaled
Fixes: #36

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-14 20:42:16 +08:00
Yuhang Zhao 14556d8b2d Update documentation.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-14 17:41:17 +08:00
Yuhang Zhao c24fec11ab Add some useful information for developers
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-14 17:32:24 +08:00
Yuhang Zhao 9cd7e368de Minor improvement.
It turns out that the final title bar height contains
the border height as well.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-14 16:27:20 +08:00
Yuhang Zhao 1822333268 Remove unnecessary cast to QWidget.
TO BE VARIFIED!

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-14 10:22:38 +08:00
Yuhang Zhao 5fe936f631 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-13 09:56:11 +08:00
Yuhang Zhao ddef1cab43 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-12 21:20:20 +08:00
Yuhang Zhao 13e974a078 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-12 20:58:04 +08:00
Yuhang Zhao f35407ce5c Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-12 20:34:12 +08:00
Yuhang Zhao c783bc1fe2 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-12 11:34:41 +08:00
Yuhang Zhao f597b64f46 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-09 20:22:31 +08:00
Yuhang Zhao 1bf0d59efa Fix Qt5 and Qt6 build.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-07 00:29:36 +08:00
Yuhang Zhao fd3fb7deda Fix Qt6 build.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-06 10:31:19 +08:00
Yuhang Zhao d3152df01f UNIX: resize: fix wrong logic.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-05 20:19:04 +08:00
Yuhang Zhao b5e497e6ff UNIX: fall back to traditional way.
The startSystemMove and startSystemResize may
return false on some systems, just fallback to
use the old way to move and resize the window.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-05 18:25:44 +08:00
Yuhang Zhao d06a5ccab9
Merge pull request #31 from SBG-Systems/fix_dual_screen
Fix object detection with dual screen
2020-11-03 14:25:03 +08:00
Yuhang Zhao b1ddc5010d Fix build on old Qt versions.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-03 14:11:47 +08:00
Yuhang Zhao 9964d97374 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-30 16:18:38 +08:00
Yuhang Zhao f5a6493364 Minor improvements.
If there is a API, use API instead of reading registry.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-29 12:16:25 +08:00
Alexandre Petitjean bf2c085519 Fix object detection with dual screen 2020-10-28 17:06:06 +01:00
Yuhang Zhao c302bf331c Fix regression.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-26 18:12:51 +08:00
Yuhang Zhao 1cc4d92aca Minor improvements.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-26 17:36:40 +08:00
Yuhang Zhao be507e0475 Fix CMake builds.
Link to missing libraries.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-25 11:31:23 +08:00
Yuhang Zhao 10876e6f0b Fix DPI functions are link to system libraries directly.
Forgot to change them during refactor.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-25 11:26:06 +08:00
Yuhang Zhao 1c0e4a4657 Minor improvements.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-25 11:06:48 +08:00
Yuhang Zhao 7c255ea79e Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-25 09:57:11 +08:00
Yuhang Zhao 955961cf9b Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-24 23:45:23 +08:00
Yuhang Zhao c3d54c616d Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-23 19:04:52 +08:00