Skip to content

Made save / restore size and position of the main window using wxConfig - #30

Open
ManeFunction wants to merge 13 commits into
Ravbug:masterfrom
ManeFunction:window-size-save
Open

ManeFunction wants to merge 13 commits into
Ravbug:masterfrom
ManeFunction:window-size-save

Conversation

@ManeFunction

Copy link
Copy Markdown
Contributor

Added a feature to keep main window's size and position, and not reset it on each launch. Used default wxConfig feature already included in project, so no any new tools here.

Tested on Mac, can't test it on Windows or Linux at the time. Sorry if I did something wrong, C++ is not my main language.

@ManeFunction ManeFunction changed the title Made save / restore of the main window size and position using wxConfig Made save / restore size and position of the main window using wxConfig Feb 16, 2023
@Ravbug

Ravbug commented Feb 16, 2023

Copy link
Copy Markdown
Owner

Thanks for the PR! I will take a look when I have a chance.

@Ravbug

Ravbug commented Feb 16, 2023

Copy link
Copy Markdown
Owner

I tested it on both mac and windows, and while this works on mac, it does not work on windows. The call to config->Read on windows always fails. Not sure if this is an issue with wxConfig or with our usage of it here.

@ManeFunction

Copy link
Copy Markdown
Contributor Author

Thank you for the test! I'll check this out a bit later if no one helps with this.

@Ravbug Ravbug linked an issue Nov 5, 2024 that may be closed by this pull request
@ManeFunction

Copy link
Copy Markdown
Contributor Author

Hello, @Ravbug! I’m really sorry this fix took so long. I forgot about this PR after I stopped using Native Hub. It launches the standard Hub, which makes the whole thing feel kind of pointless, but I’d like to start using it again, so I hope I can get this fixed, if you don’t mind.

As for this PR, I’ve updated the branch, added a few features (like saving the state of the projects table), and fixed the Windows-related issue. It actually affected macOS as well, but only partially.

@Ravbug

Ravbug commented Nov 3, 2026

Copy link
Copy Markdown
Owner

I'm hesitant to merge this because of the many edge cases that could result in the app's window becoming inaccessible, eg, the app is quit then the monitor the window was on is disconnected, so the window attempts to restore to an invalid coordinate on its next launch and ends up offscreen. Based on my research I don't think wxWidgets currently provides a good way of telling the OS to handle window restore, and I don't think UnityHubNative should attempt handling this itself.

For now I think I'll leave this PR here in case anyone wants this in their own fork. Thank you for your effort though!

@ManeFunction

Copy link
Copy Markdown
Contributor Author

Thank you for pointing that out! I hadn’t considered that case, but I think we can easily fix it. Take a look: I’ve added a check that runs when the hub launches, checks its position, and brings it back into the visible viewport if it’s off-screen. Also, to be extra safe, I’ve added a “Window > Center Window on Current Display” menu item that brings the window back onto your current display. But honestly, with the first fix in place, that shouldn’t happen anymore.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save window size and columns width between runs

2 participants