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

Incorrect maximize behaviour #3494

Open
JumpyLionnn opened this issue Oct 22, 2023 · 5 comments · Fixed by #3601
Open

Incorrect maximize behaviour #3494

JumpyLionnn opened this issue Oct 22, 2023 · 5 comments · Fixed by #3601
Labels
bug Something is broken

Comments

@JumpyLionnn
Copy link

Describe the bug
There are a few problem with maximizing a native window in eframe.

  1. Every frame eframe provides a Frame struct and inside it there is an IntegrationInfo struct that you can retrieve with the info() method. In the integration info, there is some data about the native window including a boolean that indicates if the window is maximized or not. this boolean doesn't change to true even if the window is maximized.
  2. With the persist window option in NativeOptions Ive noticed when I start up the app with maximized set to true it does start that way, but instantly shrinks to the previous session's dimensions and if it was closed while maximized it does try to do the dimensions of a maximized window but not actually maximized and it becomes slightly offset.

To Reproduce
Steps to reproduce the behavior:
I dont know if it matters but here are my egui and eframe in my Cargo.toml

eframe = {version="0.23.0", features = ["persistence"]}
egui = {version="0.23.0", features = ["persistence", "serde"]}
  1. Set presist_window to true
  2. Run the app
  3. Maximize the window
  4. Close the window
  5. Rerun the the app and the window state wont be persisted correctly

Expected behavior
When opening the window, if the presist_window is true and the window was maximized in the last session it should be maximized again in the same monitor.
Also the WindowInfo struct in the Frame provided by eframe should have maximized set to true if the window is maximized.

Desktop:

  • OS: Windows
@JumpyLionnn JumpyLionnn added the bug Something is broken label Oct 22, 2023
@Turun
Copy link

Turun commented Nov 21, 2023

probably related to #1517

Workaround: save the maximized state in you App struct and add a sentinel variable to indicate the first frame (not persisted, default false, set to true on the first frame). Then you can do:

if self.first_frame {
    self.first_frame = false;
    frame.set_maximized(self.persisted_maximized_state);
}

@emilk
Copy link
Owner

emilk commented Nov 21, 2023

Fix coming in #3601

emilk added a commit that referenced this issue Nov 21, 2023
* Closes #3494

This makes sure it is always up-to-date.

Previously (years back) this caused a deadlock on Mac, but this seems to
have been fixed
emilk added a commit that referenced this issue Nov 23, 2023
* Reopens #3494

It caused a deadlock on Mac when running `custom_window_frame`
emilk added a commit that referenced this issue Nov 23, 2023
* Reverts commit e037489 (#3601)
* Reopens #3494

It caused a deadlock on Mac when running `custom_window_frame`
@emilk
Copy link
Owner

emilk commented Nov 23, 2023

Re-opened because of dead-lock: #3612

@emilk emilk reopened this Nov 23, 2023
@emilk
Copy link
Owner

emilk commented Jan 17, 2024

#3831 will fix this for Windows, but Linux and Mac still has the issue

@seritools
Copy link

seritools commented Mar 9, 2024

Hmm, even without the deadlock and with the Windows fix, I think bug 2 in the issue is not addressed. persist_window does not seem to save the maximized state in the ron file at all.

After closing a maximized window, this is what is saved:

    "window": "(inner_position_pixels:Some((x:0.0,y:34.0)),outer_position_pixels:Some((x:-11.0,y:-11.0)),fullscreen:false,inner_size_points:Some((x:2560.0,y:1386.6666)))",

There is no info about maximization saved, which means the window will never be maximized on startup automatically. (In fact, for me, it causes a maximized-sized window to appear halfway off-screen on the wrong monitor).

The coordinates saved are also the ones of the maximized window. I think for consistent and nice behavior, the state should persist:

  1. the unmaximized position and size, i.e. what a window would restore its position and size to when pressing the restore button
  2. a flag whether the window was maximized

This way both the maximization state and even the size and position when un-maximizing the window are preserved, even across app restarts.

Maybe it makes sense to split bug 2 out into its own issue, since it's more a feature request than a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants