-
Notifications
You must be signed in to change notification settings - Fork 3.1k
21148: Undocked panels change their sizes between MuseScore sessions #27729
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
21148: Undocked panels change their sizes between MuseScore sessions #27729
Conversation
mathesoncalum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @krasko78 - just investigating/discussing a couple of things internally related to this. In the meantime if you could address the warning that would be ideal:
QRect geometry = !isNormalWindowState(windowState) ? normalGeometry : geometry;
declaration of 'geometry' hides class member
Many thanks!
79f0fec to
f105e63
Compare
mathesoncalum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience @krasko78! Your other PRs are on my radar as well, I'm just trying to balance a few things at the moment :)
Something I find quite curious about this bug is that it doesn't occur when you load from recent files (HomePage). I could be wrong, but the fact that it only occurs when loading straight to the NotationPage would seemingly imply there's something we can do about this on the MuseScore Studio side of things (as opposed to tweaking the KDDockWidgets framework directly, which we try to avoid where possible).
Would be interested to hear your thoughts on that!
|
@mathesoncalum Thank you for looking at my PRs. Take your time! :) Let me do a bit more research on this one. |
f105e63 to
0cbfe75
Compare
|
Cheers @mathesoncalum! Everything I said previously holds true but I have some updates regarding the fix. First let me sum up the two problems that we have:
Yesterday I looked at the source code of KDDockWidgets on GitHub and discovered that this was indeed a bug in KDDockWidgets fixed a long time ago but we didn't fix it. Our So I propose we fix
Before I didn't understand how this was supposed to work for the calculation of the scaling coefficients where the saved geometry is matched against the current (normal) geometry. For a maximized window the saved geometry is the maximized size. I now do have a very good explanation - KDDockWidgets must be expecting the main window to be visible when its layout is getting restored. If it is visible, setting the normal geometry and then the state to maximized maximizes the window immediately causing it to resize to its maximized size. So later However, if the main window is not visible, as is our case, then setting the normal geometry works fine but setting the state to maximized is where things go wrong: the window is not maximized (resized) until it is actually made visible. This causes So to fix this we need to make sure that the main window of MuseScore is visible when the layout is getting restored. I've added a line for that in DockWindow. This works and indeed fixes the scaling, but the caveat is that it now causes wose user experience when MuseScore is starting: on my system, after the splash screen disappears, I see a blank maximized window with a big rectangle that does not repaint itself, then I see the window getting filled with the tollbars, panels, etc. and finally the score. I have updated the PR with these two fixes so that you can see for yourself. I am not sure how to avoid the empty window on startup now that the window is made visible much early in the startup cycle. Would be nice to hear your thoughts. The only thing that passes my mind is to make the main window transparent and remove the transparency when everything has loaded... P.S. The reason why the bug does not appear when opening from the Recent file list is simply because at that moment the Score page is not open. It is open and restored when opening a score and at that moment the main window of MuseScore is already visible and maximized. So the problem only appears when starting MuseScore with a score (either double-clicking on a file or in my case having MuseScore set to restore the last session). And as I mentioned in the story, it looks like the bug is not present in this case but the heights are slightly reduced: this is because of the first part of the bug. If the maximized window has a size of 1920 x 1050px for example, our |
0cbfe75 to
2c2c307
Compare
|
Update: I figured we don't actually need to show the main window as early as I thought. The scaling happens when the pages are open (Home, Score, etc.) which does not happen until I noticed something though that bothers me a bit: Have a great weekend. |
mathesoncalum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent stuff @krasko78! Just one requested change from me.
Yeah I'm not sure what that Rectangle is for actually (maybe @igorkorsukov knows). Is calling processEvents immediatedly after setProperty necessary for this fix?
This is just for debugging, to understand what is happening, if we see this rectangle, it means that the main window itself has loaded, but the page does not load, there is probably some kind of error there. |
2c2c307 to
0dc4efb
Compare
|
Fortunately I did see the warning about I've also shortened the comment a bit as it includes a link to the issue with all the info. |
|
Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved |
Resolves: #21148 (partially, the other half should be covered by PR27695
Symptoms:
Undocked panels change their width and height with each launch of MuseScore. They can increase or decrease them with decrease being the more common case. The Mixer auto-calculates its height so the height is not problematic, but the width is: it will usually shrink significantly upon every launch eventually ending up as wide as a pen (as described by many users). A vertical panel, e.g. the Layout panel, when undocked will also significantly reduce its height with every launch ending up as high as a pen. The vertical panels are constrained to a width of 300px so it is not as problematic.
Increase or decrease? By how much?
The next time MuseScore is launched:
1150 / WwhereWis the width of the MuseScore window it had when it was last closed. Consequently, ifWis less than 1150px, all widths will increase; if W is more than 1150px, all widths will be reduced. The farther W is from 1150, the more pronounced the width change.768 / HwhereHis the height of the MuseScore window it had when it was last closed. Consequently, ifHis less than 768px, all heights will increase; if H is more than 768px, all heights will be reduced. The farther H is from 768, the more pronounced the height change.The numbers 1150 and 768 are approximate and may vary from system to system a bit. I suppose most users have MuseScore maximized to something close to 1920x1080px on their laptops. This is the reason why the panels mostly shrink.
Cause:
The
LayoutSaverscales all the widget sizes relative to the the main window. InLayoutSaver::restoreLayout()there is a calllayout.scaleSizes(d->m_restoreOptions);(LayoutSaver.cpp:220) which callsscaleSizes()on each main window (line 528). This is where the saved geometry of the window when it was last closed is compared against its current size and then everything is scaled according to that ratio. I believe the idea is that if the main window would end up outside of the screen, its size and position will be adjusted but at the same time all other floating windows should be adjusted by the same amount so as to scale the whole layout evently. The problem is this does not seem to work quite correctly.I see a couple of issues here:
LayoutSaver::Private::deserializeWindowGeometry()is where the size of the main window is restored. If the window was not maximized, the method will use its saved size. If the window was maximized, the method will use the normal (restored) size and the window will be maximized later. This is fine. The problem is that later whenLayoutSaver::MainWindow::scaleSizes()is calculating the scaling coefficients, it always takes the saved size of the window. So if the window was maximized, it will be created with its normal size and this normal size will be used together with the saved (maximized) size for the scaling. Does not make sense to me. There is no way for the coefficients to be 1.0 so some scaling will take place. It feels like comparing apples to pears.The second problem is that in
LayoutSaver::ScalingInfo::ScalingInfothe saved size of the window is not compared to the actual size of the window set byLayoutSaver::Private::deserializeWindowGeometry(). The latter usessetTopLevelGeometrywhich sets the size of the main window correctly but the former usesmainWindow->window()->geometry();instead. This returns a width like 1150px and height like 768px which are very close to the width and height set on theApplicationWindowinAppWindow.qml(probably the height excludes the titlebar). So the scaling coefficients always dependent on: a) the size of main window of MuseScore when it was last closed - and - b) the fixed width and height set inAppWindow.qml. This does not make sense to me either.My fix:
I propose that in
LayoutSaver::MainWindow::scaleSizes()we use the same logic as indeserializeWindowGeometry(): use either the save or normal size of the window as the denominator and make the nominator the same size but run throughFloatingWindow::ensureRectIsOnScreen. In almost 100% of the time the two will be equal except when the size goes out of the screen and needs adjustment. Due to the unknowns as to why KDDockWidgets does all that, my fix may not be optimal. Shout out if you have better ideas.