Commit Graph

163 Commits

Author SHA1 Message Date
Yuhang Zhao bb8d174c56 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-14 15:26:49 +08:00
Yuhang Zhao 3216defd59 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-13 15:36:18 +08:00
Yuhang Zhao 2073cb9fd2 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-13 15:17:27 +08:00
Yuhang Zhao 556741cfb1 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-13 12:14:08 +08:00
Yuhang Zhao d0e19a2b1e wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-12 16:58:58 +08:00
Yuhang Zhao 2881874d7a wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-12 15:53:50 +08:00
Yuhang Zhao 01ad24aae1 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-11 21:57:24 +08:00
Yuhang Zhao 0ce352ff22 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-11 17:59:53 +08:00
Yuhang Zhao 0e4f95fe2c wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-11 16:23:12 +08:00
Yuhang Zhao 8e69a57039 wip
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-11 09:33:27 +08:00
Yuhang Zhao bbd20b6476 win32: minor improvements
1. Adds some more comments
2. Fixed a typo in QMainWindow example
3. Commented out a block of code that may cause issues
4. Return WVR_REDRAW by default in WM_NCCALCSIZE
5. Other minor tweaks

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-03-09 10:21:52 +08:00
Yuhang Zhao a9256ba4b3 QtQuick demo: work-around a QtQuick bug
See https://bugreports.qt.io/browse/QTBUG-69711
Also some minor tweaks of the constexpr variables.

Fixes: #35

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-02-10 10:14:54 +08:00
Yuhang Zhao e0c00bce35 Example improvements
Try to fix the frame border issue on high dpi monitors.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-01-10 10:07:26 +08:00
Yuhang Zhao 485d9665ea Fix build on Qt versions below 5.14
QStringView introduced in Qt 5.10.0
qExchange() introduced in Qt 5.14.0
qSwap() is deprecated, use std::swap() instead

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-01-07 13:15:46 +08:00
Yuhang Zhao e85e3f891e Example: special case for Win11
1. On Win11 we don't need to paint the frame border, the OS will always draw one for us.
2. Fix the wrong coordinate of the right and bottom frame border of the widget example.
3. Improve the Qt Quick example.
4. Correctly detect the OS version when building against Qt below 5.9.
5. Other minor tweaks.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-01-07 11:10:28 +08:00
Yuhang Zhao e3adb917a6 Fix build on Qt before 5.14
1. The QWinRegistryKey class was introduced in 5.14.0. The implementation is quite clean, so just copy the sources files from Qt repo in case the user is linking against a version older than 5.14.
2. Fixes the rounding error of the self-painted frame border of the examples.
3. Other minor tweaks.

Fixes: #95
Task-number: #94

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2022-01-06 11:18:33 +08:00
Yuhang Zhao 17601f386f Code refactor
1. Load dwmapi.dll and winmm.dll dynamically at runtime, to remove the dependency on those dlls
2. Use QSystemLibrary to load dlls, it can make the loading of system dlls safer, and avoid duplicating the code
3. Use QWinRegistryKey to access registry, no need to use QSettings in such scenarios
4. Adapt to new code when building against Qt 6.3 and newer.
5. Other minor tweaks.

Fixes: #94
2022-01-05 11:00:31 +08:00
Yuhang Zhao fb8f061091 Win32: Add workaround for DWM flicker
And some other minor tweaks.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-12-01 14:59:29 +08:00
Yuhang Zhao 2fafa7a433 Fix the border width of the examples
Amends commit 3aba956d66

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-11-19 14:29:44 +08:00
Yuhang Zhao 3aba956d66 Minor improvements
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-11-19 14:11:55 +08:00
Yuhang Zhao 330669e34a Quality improvements
1. Use native frame color in the MainWindow example, just like the Widget example. Fixes #87
2. Rename setHitTestVisibleInChrome() to setHitTestVisible(): This name was taken from Microsoft's WindowChrome class in WPF. Now they removed the legacy "Chrome" suffix in their new products, so we removed it as well.
3. Fix build with Qt older than 5.15: Q_NAMESPACE_EXPORT was introduced in Qt 5.14
4. Removed code that supports native frame: they are just leftovers of the previous refactoring.
4. Correctly detect SetWindowLongPtrW() and GetWindowLongPtrW() 's operation result: they won't modify the Last Error state on success, so we have to set Last Error state to ERROR_SUCCESS before calling them to make sure we get the correct error code.
5. Remove implicitly conversions, use explicit casts where possible
6. Fixed FormatMessage() usage, correctly retrieve the error message: According to MSDN, we should pass the address of a LPWSTR, not the LPWSTR itself.
7. Removed the special handing of WM_SIZE: It turns out that this handling is not needed at all and it's causing new issues, so just remove it.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-10-08 15:43:33 +08:00
Yuhang Zhao 138a2b90cb Minor refactor
1. Remove compiler specific flags
2. Build shared library by default
3. Remove unused functions
4. Minor tweaks of some internal logic, the final behavior is not affected

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-09-06 14:24:43 +08:00
Yuhang Zhao 8367331278 Win32: move all win32 staff to one header
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-09-05 13:24:12 +08:00
Yuhang Zhao d64b38a8db Improve the widget example
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-09-05 12:27:16 +08:00
Yuhang Zhao bc8a70dbb2 Win32: Fix window content will be cut-off for some pixels when window is fullscreened
1. Fix that bug
2. Some adjustments of the variable names to make them more clear
3. Some tweaks to the title bar height value

TODO: Add a button to switch between fullscreen and windowed mode for the widget example
TODO: Add a title text to the widget example

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-09-04 22:40:13 +08:00
Yuhang Zhao 2c106ffef9 Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-09-01 15:26:36 +08:00
Altair Wei 01dd43c356
fix unwanted cursor change when leave edge region (#80) 2021-08-23 09:29:50 +08:00
Yuhang Zhao f18468dcca Win32: QMake: fix build error
Fixes: #76

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-08-16 16:24:14 +08:00
Yuhang Zhao 5a2d498445 Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-08-11 17:58:47 +08:00
Yuhang Zhao 2b6d0fccb6 Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-23 11:04:48 +08:00
Yuhang Zhao 6698033a1a Fix Qt 5.9 build
Use lower import version for Qt Quick

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-21 17:23:10 +08:00
Yuhang Zhao d43d126d3f Fix wrong system button size in example
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-21 11:16:45 +08:00
Yuhang Zhao 233ebba3ec Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-20 09:58:00 +08:00
Yuhang Zhao f30339ff54 Minor cleanup
1. Remove unneeded functions
2. Rename some functions and variables to match their real functionality

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-19 10:43:10 +08:00
Yuhang Zhao 151e8a1664 Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-07-06 10:54:11 +08:00
Yuhang Zhao 28144b1e74 Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-06-09 13:27:11 +08:00
Julien 938756a757
FIX frame in QMainWindow (#58)
Co-authored-by: Julien Maille <julien.maille@data-pixel.com>
2021-06-09 08:59:51 +08:00
Yuhang Zhao e0b5244420 Rename function
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-06-01 13:10:05 +08:00
Yuhang Zhao 4139cf0ab2 redesign API 2021-05-31 11:52:32 +08:00
Yuhang Zhao d12198a7bc Update
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-04-04 12:09:34 +08:00
Yuhang Zhao cdb7b87eb4 Remove acrylic related things
They'll be moved to a separate repo instead

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-04-02 12:02:46 +08:00
Yuhang Zhao ef34a7c699 Minor fixes
1. Fix MainWindow example issue
2. Add a comment about the inverted argument
3. Fix some memory leaks

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-04-01 09:52:38 +08:00
Yuhang Zhao f188c0f88d Examples: Quick: lower required version
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-30 11:03:16 +08:00
Yuhang Zhao 18d883b96a Minor tweaks
Amends commit 0759f7f010

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-26 17:35:33 +08:00
Julien 0759f7f010
NEW: QMainWindow example (#50)
* WIP: qmainwindow example

* NEW: option to disable acrylic on QMainWindow

* IMP: accept standard QMainWindow parameters

* NEW: enable acrylic in QMainWindow example

* IMP: qmainwindow sets acrylic outside constructor

* IMP: center windowTitle

* cleanup

* IMP: move setContentMargin in QtAcrylicMainWIndow class

* more cleanup

* small cleanup

* improvement copied from qtacrylicwidget

* minor improvement

* always connect needRepaint

* close button thickness is now similar to native windows buttons

* add context menu on left icon

* simpler context menu implementation

* IMP: use displaySystemMenu from Utilities

Co-authored-by: Julien Maille <julien.maille@data-pixel.com>
2021-03-26 16:53:32 +08:00
Yuhang Zhao 4cba3a4dd4 Minor improvements
1. Update margins when maximized for the examples
2. Prepare for the UNIX version of utility functions

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-25 15:12:47 +08:00
Yuhang Zhao 3e09c0f9b8 Example: Widget: Fix build below 5.14
Fixes: #54

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-24 11:15:58 +08:00
Yuhang Zhao 8ebf9cfc58 Disable acrylic blur by default
If the user want to use it, the user should enable it.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-21 11:13:09 +08:00
Yuhang Zhao a183a6d4a1 Make the wallpaper blur dynamic update
The window background will update dynamically once
it's being moved.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-10 14:18:08 +08:00
Yuhang Zhao 0931b73671 Some refactor
Rename some functions to make it more clear.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-10 10:05:23 +08:00
Yuhang Zhao b51c6ce564 Use new screenshot
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-09 14:06:36 +08:00
Yuhang Zhao 8b3da2d31a Add CMake project files for the examples
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-09 13:43:46 +08:00
Yuhang Zhao f70158a276 Add cross-platform Acrylic Effect
Currently still lacking Linux and macOS support,
but will be added sooner.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-08 14:10:55 +08:00
Yuhang Zhao 8a20747ba8 Minor tweaks
Mainly cleanup the WinNativeEventFilter

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-05 10:40:52 +08:00
Yuhang Zhao eeba7d854f Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2021-03-04 15:45:10 +08:00
Yuhang Zhao 7522273331 Get rid of latin-1 strings
Use UTF-8 strings everywhere.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-12-22 20:46:39 +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 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 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 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 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 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 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 5fe936f631 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-13 09:56:11 +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 1bf0d59efa Fix Qt5 and Qt6 build.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-11-07 00:29:36 +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 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
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
Yuhang Zhao 3a17359978 Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-23 14:34:51 +08:00
Yuhang Zhao 9d4a3a453c Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-23 14:03:04 +08:00
Yuhang Zhao 286fc26d3f Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-23 12:47:37 +08:00
Yuhang Zhao 12923d9bbd Fix icon size again.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-22 21:59:09 +08:00
Yuhang Zhao 2e1075235c Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-22 19:55:13 +08:00
Yuhang Zhao b21f1023b5 Fix wrong size of the 3 system buttons.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-22 16:36:00 +08:00
Yuhang Zhao d671fd703d Minor improvements.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-22 11:49:30 +08:00
Yuhang Zhao 6a12cb1a30 Minor improvements.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-21 21:21:56 +08:00
Yuhang Zhao 8c21be9e64 Fixed two issues.
1. The border color on Win10 when in light theme is also #707070, not pure white.
2. The brush color of the Acrylic effect is reversed before, it is now correct.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-21 11:10:51 +08:00
Yuhang Zhao f3e863e14b Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-20 23:26:03 +08:00
Yuhang Zhao cde5ebcf8d Fix build on 5.12
Q_DISABLE_COPY_MOVE: since 5.13
QLatin1String arg: since 5.14

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-20 13:01:43 +08:00
Yuhang Zhao 17b35173ef Minor improvements to the Win32Demo project.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-20 09:55:20 +08:00
Yuhang Zhao 886f31d0c0 Fix two issues.
1. The border line may disappear when resizing: fixed by change the line width to 2px.
2. Some part of the window become totally transparent after DPI changes: fixed by calling update() after DPI changes.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-19 22:07:12 +08:00
Yuhang Zhao af65f2d9e3 Link to system dlls by default.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-19 16:29:00 +08:00
Yuhang Zhao 72db8e7043 Improve the Win32Demo project.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-19 14:54:13 +08:00
Yuhang Zhao 396b7a2f69 Adapt to file rename.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-18 21:23:24 +08:00
Yuhang Zhao 8ea85ed3ba Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-18 21:21:03 +08:00
Yuhang Zhao 3b54e37c5e Move the resources folder into the examples folder.
That's where it should be.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-18 14:20:47 +08:00
Yuhang Zhao c0de790138 Fix Linux build.
Signed-off-by: Yuhang Zhao  <2546789017@qq.com>
2020-10-18 14:15:13 +08:00
Yuhang Zhao ae92a00628 Guard against the event.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-18 13:23:59 +08:00
Yuhang Zhao f38b86e992 Fix the context menu issue.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-18 11:53:04 +08:00
Yuhang Zhao d3f58ae98f Use blur instead of Acrylic on Win10.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-17 20:19:52 +08:00
Yuhang Zhao 226bc52ece Fix the acrylic effect.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-17 18:09:59 +08:00
Yuhang Zhao 073ad117ba Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-17 13:08:47 +08:00
Yuhang Zhao ff10ae21f4 Update.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-16 20:02:38 +08:00
Yuhang Zhao 0debbb890f Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
2020-10-16 15:53:20 +08:00