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

fix(windows): calculate accurate window insets for undecorated shadows #1052

Merged
merged 3 commits into from
Feb 9, 2025

Conversation

@amrbashir amrbashir requested a review from a team as a code owner February 8, 2025 06:08
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Package Changes Through d9ee4a7

There are 1 changes which include tao with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tao 0.31.1 0.32.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir
Copy link
Member Author

@Legend-Master can you check if this fixes the Windows 10 borders? I mean this one tauri-apps/tauri#11654

@Legend-Master
Copy link
Contributor

Legend-Master commented Feb 8, 2025

@Legend-Master can you check if this fixes the Windows 10 borders?

Seems like the title bar is still there with the change? The resize handle is at the bottom of the title bar and you can't click that title bar (will click through)

image

Tested on Windows 10 using the decorations example with decorations set to false by default

let window = WindowBuilder::new()
  .with_title("Hit space to toggle decorations.")
  .with_inner_size(LogicalSize::new(400.0, 200.0))
  .with_decorations(false)
  .build(&event_loop)
  .unwrap();

let frame_thickness = get_frame_thickness(dpi);

let top_inset = match WIN_VERSION.build {
v if v >= 2200 => (dpi as f32 / USER_DEFAULT_SCREEN_DPI as f32).round() as i32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
v if v >= 2200 => (dpi as f32 / USER_DEFAULT_SCREEN_DPI as f32).round() as i32,
v if v >= 22000 => (dpi as f32 / USER_DEFAULT_SCREEN_DPI as f32).round() as i32,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, the window looks like this, the top border is missing and also not resizable from that edge

image

I have read about an article https://kubyshkin.name/posts/win32-window-custom-title-bar-caption/ talking about this before, and the idea is that you need to draw your own top border to fake it...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, the window looks like this, the top border is missing and also not resizable from that edge

I have read about an article https://kubyshkin.name/posts/win32-window-custom-title-bar-caption/ talking about this before, and the idea is that you need to draw your own top border to fake it...

I did read that one before but I don't want to add any custom drawing inside taol.

Copy link
Member Author

@amrbashir amrbashir Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is good enough for aesthetics, don't you think?

As for, functionality maybe we bring back custom hittesting for only top border only on Windows 10?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did read that one before but I don't want to add any custom drawing inside taol.

Yeah, same thoughts here

I think this PR is good enough for aesthetics, don't you think?

Yeah, it's good enough to me, at least it's much better than what we had before ;)

Also I have tested WindowsAppSdk sometime ago, and their ExtendsContentIntoTitleBar also had this problem (and they draw control buttons themselves as you tell can from the icons)

image

As for, functionality maybe we bring back custom hittesting for only top border only on Windows 10?

I think we'll need this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Legend-Master does top-left and top-right resizing edge work and only top doesn't or all 3 don't work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually looks like the issues exists in Windows 11 too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good to go now

Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, tested maximized and normal window on Windows 10, the position and size seems to be right as well, awesome work!

@amrbashir amrbashir merged commit 5cc9298 into dev Feb 9, 2025
18 checks passed
@amrbashir amrbashir deleted the fix/windows/undecorated-shadow-insets branch February 9, 2025 03:25
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.

2 participants