Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: Allow setting Windows titlebar separately from its resize border #4100

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

eugenesvk
Copy link

@eugenesvk eugenesvk commented Jan 30, 2025

Set WS_CAPTION separately to allow implementing custom titlebar while maintaining resize borders.

Currently MARKER_DECORATIONS internal window flag is used for both WS_CAPTION and WS_BORDER

Also add a separate way to set the top resize border for windows without title bars to allow implementing custom title bars that would handle their own resizing from the top and thus avoid the default thick resize border at the top that Windows adds when there is no title bar.

Set via TOP_RESIZE_BORDER window flag and the corresponding methods to (un)set/check it. Requires manuall override of WM_NCCALCSIZE and WM_NCACTIVATE to change the border of the non-client window area to 0 and prevent it from being redrawn on window activation events

closes #3730

(for testing also used similar (but slightly different due to moving Win to dyn) changes on top of v0.30.8 in https://github.com/eugenesvk/winit/tree/v30_8)

  • Tested on all platforms changed (Windows only)
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality (topless.rs example that illustrates and allows live toggling of title bar/resize border/top resize border (for wins without a title bar))

@eugenesvk eugenesvk requested a review from notgull as a code owner January 30, 2025 17:37
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@eugenesvk eugenesvk force-pushed the fr-win-titlebar branch 2 times, most recently from 205f47f to 1a20968 Compare January 30, 2025 18:44
set WS_CAPTION to allow implementing custom titlebar while maintaining resize borders.

Currently MARKER_DECORATIONS internal window flag is used for both WS_CAPTION and WS_BORDER
for windows without title bars to allow implementing custom title bars that would handle their own resizing from the top.

via TOP_RESIZE_BORDER flag and the corresponding methods to set it. Requires manuall override of WM_NCCALCSIZE and WM_NCACTIVATE to change the border of the non-client window area to 0 and prevent it from being redrawn on window activation events
@eugenesvk eugenesvk force-pushed the fr-win-titlebar branch 5 times, most recently from 3c6c592 to 6902428 Compare February 1, 2025 10:07
A minimal example of a window supporting a custom title bar

allowing toggling the default title bar on/off, while maintaining control over the resize borders overall and the top resize border specifically

The custom title bar itself is not implemented and left as an exercise for the reader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Should need separate decoration control.
2 participants