-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[detach-window] Use eventFilter to process closeEvent #8096
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
[detach-window] Use eventFilter to process closeEvent #8096
Conversation
This frees us from having to inherit Detachable{Widget,Window}, and
instead we hook the handling directly in SubWindow.
|
One detail I'm not really sure about is if DetachableWidget should still be called that. It's essentially an eventFilter class that we hook, the "Widget" part might be confusing. The reason I kept it initially is because its functionality is very close to original DetachableWidget. |
All removed functionality is being done in the event handler which gets installed immediately after widget is given to SubWindow.
- Use QLayout::setSizeConstraint to set fixed size since it responds to layout changes. - Set widget icon directly since it's useful for detaching, and SubWindow inherits it anyway.
|
everything aside the initial commit is mostly cleanup of things I noticed in diff between feature/detach-window and master. Could be a collection of small PRs but I think it's fine as it is, especially considering for now I'm the only one working on the branch and there's mostly polishing left. |
Make InstrumentTrackWindow prev/next windows preserve detached state, matching how positions are set. SubWindow::attach() move & resize delays removed since their execution order becomes ambiguous, causing issues with manual movement outside the class.
|
Haven't looked at the code yet, but I tested it and it seems to work pretty well. The prev/next buttons in the instruments seems to work correctly now, which is awesome. The only issue I noticed is that when you close an attached window (such as the Song Editor) then reopen it, the size of the window is lost and it resets to a smaller size than the default. |
|
And I still think the detached window's close button behavior should be changed. With the way it is currently, I'm certain people will complain that their window disappeared and they aren't able to open it again. From what I understand, it's a Wayland issue preventing you from moving the window once it's reattached? |
Yes. For at least Qt5, top-level window positions are always reported as 0-0. To avoid having all windows attach to that corner (especially now when scrollbars are gone), they are simply left in the position they were in before detaching. However, currently you have to go out of your way to run LMMS AppImage in wayland-only mode, and most xwayland integrations actually do support window positioning. So no real users are going to be affected.
I have such doubts as well, but I'm not sure of best way to solve this. Do you suggest simply attachng windows and avoiding moving them entirely? Or do you want to still move them, but have them remain closed until asked to show again? |
Are we talking several pixels smaller or noticeably smaller? If it's the former, a lot of resizing/moving functions don't take SubWindow decorations into account (title bar & borders), which is usually fine-ish, but can add up. I'll probably try to fix that. |
|
One more question about behavior: when an editor is detached, should MainWindow editor activation buttons simply raise it or toggle it? Currently they always try to raise the window because it always counts as unfocused which may be confusing to some. |
Make SubWindow::attach() translate and move the child widget accounting for SubWindow decorations (frame size and title bar height).
Introduce m_childGeom to track window movements independantly of Qt. Workaround for Qt not moving top-level windows if they're hidden. Additionally make attach & detach preserve the visibility state instead of force-showing the window.
szeli1
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.
I tested this PR and it works great. I remember somebody else making a similar PR.
if you're talking about #3532, this is a PR to that branch, because the branch is in the LMMS repo and I don't have write access to it (nor should I). |
|
Reserving from doing any doxygen inline comments for now for reasons discussed above and since I'm currently unable to generate doxygen to check how it looks for myself. |
There's no consistent way to control whether detached windows are resizable. The fixed size needs to be applied directly to child widget. isResizable() being false by default also encourages new effects to have fixed size, which something LMMS is movng away from.
this is already being done in setVisible
|
@messmerd this is probably ready to test & merge now if the build succeeds. |
| virtual bool isResizable() const { return false; } | ||
|
|
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.
I don't like that this has been removed. It feels like a step backwards since now plugin devs need to remember to call setSizeConstraint.
I don't really understand the problem that led to you removing isResizable, but is there any other solution?
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.
The problem is that like in other cases, the way this was done without the patch was applying size constraints to the SubWindow. Because detached widgets are no longer contained within a subwindow, they can be resized freely.
The reason isResizable() can't be applied to the child widget is because the child can basically be whatever it wants as long as that is a widget, including but not limited to:
- Not having a layout and calling
setFixedSize(), even before this commit - Having a layout and calling
setFixedSize()with a different size compared to what layout wants (StereoMatrix)
As a result of the above, removing isResizable is mostly just a standardization of sorts - of 23 native effects (not counting LV2 and VST since I can't test them), only 7 were dependent on isResizable()! All others were either resizable by themselves or fixed their size explicitly already.
It feels like a step backwards since now plugin devs need to remember to call
setSizeConstraint.
I'd argue for the reverse, most LMMS-native plugins nowadays aren't just solely knobs and have something doing GUI stuff already. And being resizable unless told otherwise is the default behavior of Qt, so I don't see any reason to stray from it.
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.
As an alternative, we could just lie and set isResizable(true) on StereoMatrix since it's the only widget I've seen to break but that's even worse IMO.
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.
Pinging @rubiefawn since she's using isResizable() over at #7805 (6cf9d41), and an alternative would be needed if we go through with removing that method as discussed here.
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.
@rubiefawn actually could you test if the issues #7805 fixes are even present here? As far as I'm concerned, the issue of replacing instruments keeping their size looks to be gone (possibly associated with layout changes to SubWindow), and I wasn't able to reproduce the other issue.
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.
The testing above was performed on the msvc build, but I installed the mingw build and encountered the same behavior there.
While I don't have a msvc or mingw dev environment set up (I do all that on the Linux partition or WSL if I'm desperate) I do still have the installer for the msvc build of 50a73e4 from my initial tests. Reinstalling and testing that shows that actually, ITWs were the only ones that had the controls to begin with.
Compare this to the mingw build of 98e6078:

Other things I noticed:
- LADSPA plugins have their layout clipped once detached (at least on the newest commit the scrollbar doesn't also get clipped lmao)
- VST plugins have no window border at all once detached
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.
What in the actual... alright, cool. I'm kinda wondering if rebasing this to qt6 would fix this since it's extremely wrong.
...Maybe if I enable FixedSizeDialogHint it starts working?.. I don't know anymore...
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.
So, a couple of observations I have after testing myself.
- Apparently
Qt::SubWindowisn't mutually exclusive withQt::Window, that could be the source of some problems. MSWindowsFixedSizeDialogHintacts as it should, and takes priority over whatever causes no flags to work. If disablingSubWindowflag doesn't work, perhapsCustomizeWindowHintwill be the one to go on windows specifically.
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.
That did it!!!
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.
I wonder if that also fixes the MacOS bug
Returns windowing buttons to all ITWs. Also conforms to Qt's advice, see https://doc.qt.io/qt-6/qt.html#WindowType-enum
Could fix some bugs. Also get rid of manipulating Qt::Widget flag manipulation since it's just 0 (fallback).
|
Side note: though SubWindow icons are visible, most of them are very hard to read depending on the OS considering they're white and MSWindows title background is the same shade of white :P |
|
So how do we want to handle project save & load? Do we save it with all windows attached? Do we preserve the state and positions of detached windows? |
"Ensure both c-s-z and c-y are redo" is removed for parity reasons because it relied on methods that aren't QAction and thus remain local.
|
Regarding shortcuts, should only Undo/Redo be global, or should things like Quit, Save, etc. be too? |
|
|
d050008 to
6aa4b13
Compare
|
One-ITW now partially works; partially in the sense that it doesn't update detached state of new subwindows like arrow keys do, but works in a sense that it actually keeps a single copy of ITW. Playing notes from keyboard on detached subwindows now partially works, but detached window focus is never updated after it's been detached. |
|
Couldn't get detach-everything to work from the |
messmerd
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.
Still good

Finishing PR to #3532.
TODO:
Probably subject to follow-up PRs:
Issues: