tauri-apps / wry

Cross-platform WebView library in Rust for Tauri.
Apache License 2.0
3.7k stars 278 forks source link

Window getters #116

Closed amrbashir closed 3 years ago

amrbashir commented 3 years ago

Is your feature request related to a problem? Please describe. Add getters on WindowProxy

Describe alternatives you've considered Keep track of an Attributes struct and update it whenever a setter method is called but that won't work properly for maximized, minimized and more.

Would you assign yourself to implement this feature?

Additional context Most of the getters can be implemented for gkt-backend but not winit-backend I made a table to list what is possible and what is not

getters winit gtk
resizable no yes
title no yes
maximized yes yes
minimized no maybe(2)
visible no yes
decoration no yes
always_on_top no maybe(2)
width, height yes yes
min/max width/height no maybe(2)
x , y yes yes
fullscreen yes maybe(2)
skip_taskbar no yes
url(3)
icon(4)
transparent(4)
initialization_scripts(4)
  1. gtk docs are confusing and I am not sure if the getter is possible.
  2. url is possible I guess but not sure if it's worth it.
  3. I think transparent, icon, initialization_scripts, and skip_taskbar don't need getters imo.
wusyong commented 3 years ago

We do can add it to the struct field but this will bloat up the size of many types. Attributes is one of the biggest types in this crate. And since it has Clone trait, maybe we just let users handle this.

amrbashir commented 3 years ago

The drawback with tracking and manually mutating an Attribute struct rather than querying the OS, is that users can't track changes to the window state (ie maximized, minimzed, size changes) unless it is changed programatically.

wusyong commented 3 years ago

Sorry I misread the description in your top comments. Yeah I think getters can be achieved by adding another channel but reversed (sender on Application, receiver on WindowProxy)

amrbashir commented 3 years ago

I am not sure we are talking about the same thing.

The main problem I see is when a window gets maximized by clicking the maximize button of the titlebar of a window, there is no way for us or the user to know that the window is maximized ( neither wry or winit have an event for that) so the struct can get out of sync with the actual window state.

Providing getters (that query the os rather than querying a struct) on the WindowProxy is necessary so users can have access to that info whenever they want.

we have to wait for winit to implement the getters so we can add them in wry unless we want to implement them on wry.

wusyong commented 3 years ago

I see. Maybe we could introduce some that are already available on both winit and gtk just like what your list above.

wusyong commented 3 years ago

Close this because we use new application api and those waiting to be implemented are listed in #165