-
-
Notifications
You must be signed in to change notification settings - Fork 199
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(wayland): fix the inaccurately applied inner_size when creating a new window. #984
base: dev
Are you sure you want to change the base?
Conversation
Package Changes Through 77b40c2There are 1 changes which include tao with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually after a second test, there is a few things I noticed:
-
if you launch the app and cursor is out of the window (i.e the eventloop doesn't recieve any events) the whole window size will be 300x300, once you move the mouse inside the window, it will jump into a bigger size (352x399)
-
if I create a window with 300x300 inner size, then
window.inner_size
should report the same size later on, I think this is a problem in dev as well though
Thank you for your review. After testing the window example on GNOME + Wayland, I found that the event loop fetches the size of the top layout, GtkApplicationWindow (352 x 399), instead of the inner size. If the event loop is intended to receive the inner size rather than the window size including decorations, I believe we need to modify it to fetch the size of its child (GtkBox). As a side note, I previously mentioned that the total size of the app includes a border width of 45px, but that applies to KDE. I have confirmed that on GNOME, the default border width is 26px. |
fn connect_configure_event(window: &ApplicationWindow, title_label: &Label, char_width: f64) { | ||
let title_label_clone = title_label.clone(); | ||
window.connect_configure_event(move |_, event| { | ||
let (width, _) = event.size(); | ||
let max_chars = (width as f64 / char_width).floor() as i32; | ||
title_label_clone.set_max_width_chars(if width < 220 { 0 } else { max_chars }); | ||
false | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resizing here makes the window create with a smaller size than expected, and then after a brief moment, it will jump into the requested size
Previously, the header’s title affected the inner size, which made the size appear to jump.
before.mov
I added an event to prevent the title from affecting the inner size.
after.mov
Additionally, the number of title characters displayed is updated when the window is resized based on its width.
resize.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was unable to reproduce the issue.
The only potentially suspicious part I can think of is the priority when creating a new window, so I’ve tried setting all related priorities to a higher level.
Could you check if this makes a difference?
Hi guys, Thanks for your great work on this project. I encountered this problem and want to have a discussion about it. By referring to the comments on tauri-apps/tauri#10686 (comment), the Hello World application seems to work on Wayland OOTB. Why must we use the hack solution (by introducing a custom header on Wayland) to fix the moving problem? Is it possible that we are using the wrong API? I'm totally new to the Tao system, above is just my humble opinion. |
Fixes #929
Reproduce
When setting
with_inner_size
to300 x 300
and running withcargo run --example window
, a window size discrepancy occurs, resulting in300 x 261
.The size of the window border is 45px on KDE Wayland, and it’s the same for all apps.
This is because the window border is included in the inner_size value, causing a mismatch when
window.resize()
.The 39px discrepancy in height is due to the inclusion of the titlebar’s height.
Changes
Added width and height settings to the window box properties corresponding to the inner size.
Added a height property to the header so that it is included in the window border, not the inner_size.
See: https://blog.gtk.org/2019/03/27/layout-managers-in-gtk-4/
Additional Context
In Tao’s Linux window box properties,
width_request = -1
,height_request = -1
is passed, and when resized to the min_size, the internal window size changes to include the window borders.Compared with the Firefox app on KDE Wayland.
In Firefox, the properties are set with values other than
-1
forsize_request
, so when reduced to size, the inner window size does not include the border values.Conclusion
To prevent inaccurate
inner_size
, we need to setsize_request
and configure the width and height values in the window properties.