tauri-apps / tao

The TAO of cross-platform windowing. A library in Rust built for Tauri.
Apache License 2.0
1.63k stars 191 forks source link

inner_size() is always 1600 x 1200 on macOS #889

Open jkelleyrtp opened 8 months ago

jkelleyrtp commented 8 months ago

Describe the bug

Calling window.inner_size() always return the same wrong answer on mac (presumably whatever the window started as).

This makes implementing window size restore difficult since we can only set the inner_size of the window, but the outer_size works properly.

Here's me attempting to use it in dioxus. We're able to catch the size from the resize event, which solves the problem I was trying to solve, but is a hacky solution in lieu of this actually working.

Screenshot 2024-03-19 at 4 53 26 PM

Steps To Reproduce

jkelleyrtp commented 8 months ago

I have a fix for this - but I think there's just something wrong with tao internally.

Old:

let view_frame = unsafe { NSView::frame(*self.ns_view) };

Suggested:

let view_frame = unsafe { NSView::frame((*self.ns_window).contentView()) };

I can confirm that this fixes the bug.

However, this leads me to believe the pointer used by the ns_view is just stale, and is endemic to the rest of the tao codebase.

pewsheen commented 7 months ago

Hi, are you calling inner_size() from Tauri window API or from tao?

It looks fine with tao only (from multithreaded example in tao). For Tauri, there is an issue that has already been fixed recently https://github.com/tauri-apps/tauri/issues/9236