Skip to content

Conversation

@damywise
Copy link
Contributor

@damywise damywise commented Mar 30, 2022

  • Removed ~50 lines of code that doesn't do anything and when removed doesn't break anything
  • Implemented hasShadow and setHasShadow in frameless mode (setAsFrameless())

Note:
hasShadow() and setHasShadow() will only work in frameless mode. Otherwise (TitleBarStyle.normal/hidden), hasShadow() will always return true.
This is because in Windows, according to my experience, a window's shadow will only be removed/hidden if the client area is fully covering the window frame (

MARGINS margins = {0, 0, 0, 0};
DwmExtendFrameIntoClientArea(hWnd, &margins[has_shadow_]);

).

However, if the app doesn't cover the window frame, even if only on one side (

MARGINS margins = {0, 0, 1, 0};
DwmExtendFrameIntoClientArea(hWnd, &margins[has_shadow_]);

), the shadow will reappear.

Also note that to enable resizing in frameless mode, You must wrap the app with VirtualWindowFrame with all ResizeEdges enabled. However, this will only enable mouse resize border inside the app, unlike TitleBarStyle.hidden, which still has invisible frame with resizable border on the left, bottom, and right side of the app.

In the future, I would like to replicate Microsoft Office apps, which has 4 separate windows on each border with class name MSO_BORDEREFFECT_WINDOW_CLASS and WS_EX_TOOLWINDOW style. I think it also draws/paints a fake shadow on its own and is used to resize the app outside the app. I took this conclusion because when I hid that window using WinSpy+, the shadow disappears and I can no longer resize the app outside the window.
If we succeed, we don't have to worry about not being able to interact with any widget on the border of the app while still enabling resize border and window shadow.

- A bunch of code for doesn't seem to do anything so I've removed them.
- Added g_is_frameless_before_fullscreen which is required in SetFullScreen() otherwise it'll crash
@lijy91 lijy91 merged commit 875a617 into leanflutter:main Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants