fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.67k stars 1.37k forks source link

Remember last window position (plus size and maximized state) #554

Open deluan opened 4 years ago

deluan commented 4 years ago

I'd like to have my app's windows re-open in the same spot as I left it last time.... Just a small nuisance to keep moving it every time I open it.

In macOS, this is the default behaviour, but Fyne apps don't behave like that. Not sure if this should be considered a bug or not.

I'm also aware that this is a desktop responsibility (positioning new windows), and that some Linux window managers have a "Remember" feature, but this is not consistent in all environments.

After briefly discussing this in Fyne's Slack channel, the proposal is to add a feature that would allow the app to request this behaviour, something like window.RememberPosition(). This would of course only work in environments that provide such capability

Jacalz commented 2 years ago

This is something that I personally think should be handled by the window manager and not the toolkit.

andydotxyz commented 2 years ago

Perhaps it should be requested from the OS and on by default? If the OS does not support it we could code into the toolkit as well I would think...

e1fueg0 commented 2 years ago

This is something that I personally think should be handled by the window manager and not the toolkit.

Unfortunately, Microsoft programmers think another way, so it would be very good if it would be implemented somehow.

Or, at least, developers would like to get something like bool Maximized() and Maximize(bool) in the Window interface, please. The rest of the remember code we can write by ourselves =)

andydotxyz commented 2 years ago

The challenge is balancing platform-specific expectations with operations that can be expected to work across all platforms. As illustrated above this would have to be an extension for specific OS combinations which we have avoided up to this point. We can implement the remember functionality without exposing Maximized - this feature would work on all platforms.

Why do you feel that Microsoft users expect software to start maximized when they did not ask it to?

Bluebugs commented 2 years ago

I would really dislike if Fyne was trying to do the remember instead of my windows manager on Linux. If it is expected that application do that on Windows, I guess it might make sense to have a specific logic for Windows to remember the window placement on Windows.

e1fueg0 commented 2 years ago

Why do you feel that Microsoft users expect software to start maximized when they did not ask it to?

I can't tell for all MS users, but I'm also a user, not just a developer. And, as a user, I do hate some apps don't remember their maximized state. Some people like small windows on their desktop. I like (and I'm sure I'm not alone in this =) to maximize windows, and I would like if an app at least has a setting to do this. That's why I'm asking for a possibility to do this.

e1fueg0 commented 2 years ago

In fact, I came here from #776, which is closed. Should I move my comments there?

andydotxyz commented 2 years ago

And, as a user, I do hate some apps don't remember their maximized state.

Agreed, the windows should be remembered. If the OS will not do it then we could do that in the toolkit. That is why this ticket exists but "add SetMaximized" tickets get closed. We want the behaviour not the APIs that can be abused.

andydotxyz commented 2 years ago

(Hopefully the new title is less ambiguous)

e1fueg0 commented 2 years ago

@andydotxyz And please keep in mind that the main windows are usually being shown like this:

    w.Resize(fyne.NewSize(640, 460))
    w.ShowAndRun()

(that was a code from main.go of fyne_demo) So if you plan to do automatic restoring, transparent to a developer, this may need to be overwhelmed.

andydotxyz commented 2 years ago

That is a good point @e1fueg0 however a complex one to resolve. I think it would be unwise to start ignoring APIs that have an expected outcome, but Resize() of a window is always a little special as the OS may ignore or override as well... Perhaps SetPreferredSize() as a new call that over time replaces Resize() would be beneficial? Not quite such a discoverable name but with a clearer expectation.

stuartmscott commented 2 years ago

SetFallbackSize(fyne.Size)? If there is a user preference/previous setting use that, else fallback to the given size

e1fueg0 commented 2 years ago

@andydotxyz I'd vote for the name SetFallbackSize(fyne.Size) proposed by @stuartmscott.

I think it would be unwise to start ignoring APIs that have an expected outcome

Completely agree with you @andydotxyz, and I would have wanted to propose to add a field like app.StoreMainWindowPosition, but I suppose every Linux developer would turn it off, so the mechanism would never work on Windows =)

Goltanju commented 12 months ago

Just want to add another use case for this sort of programmatic behavior.

I have an application that is usually just one main window. The user can launch a slideshow however, which opens a new window. I'd like that new window to open maximized. Fyne currently won't let me do that (I have to hack the repo myself).

The "remembering" thing is something I also want, but how would remembering work with additional windows? Would I need to have a unique identifier for every window remember-me-type I want? That could work. Then the first time the user opens a slideshow it wouldn't be maximized, but it would be stay maximized if they closed as such. Not exactly what I want, but "okay".

I do know about the Fullscreen attribute. I don't want that in this case, as it hides absolutely everything, taskbar, other program's widgets, etc. I just want a maximized window, lol.

I also get that Fyne is trying to stay platform agnostic as much as possible, but I mean, a balance between that and providing long known features users would expect on a given platform... This particular hyper-focus on "no features unless all platforms support it" can make working with Fyne quite frustrating at times.

Anyway, back to hacking my fork...

Edit: I also wanted to mention a notification of window state changes would be quite nice.

andydotxyz commented 12 months ago

Yea it should work with additional windows.

Regarding your "edit: it would be nice if..." - please open a feature request to ask for new functionality.