Skip to content

Conversation

@lukas-w
Copy link
Member

@lukas-w lukas-w commented May 5, 2017

Allows detaching a window from LMMS's main window, making things like working on multiple screens easier.

Closes #1259

Quick demonstration:
lmms-window-detach

@lukas-w lukas-w force-pushed the feature/detach-window branch from 016df50 to cfed76a Compare May 5, 2017 15:58
@BaraMGB
Copy link
Contributor

BaraMGB commented May 5, 2017

Wow! That's really awesome!

@karmux
Copy link
Contributor

karmux commented May 6, 2017

Very useful functionality especially when using multi-monitor setup! 👍

I played a little bit with it and found some bugs:

  1. When detached instruments are maximized then all instruments stay maximized inside LMMS until LMMS runs. I think there shouldn't be maximize button and functionality for instrument windows at all.
  2. Mixer, project notes and controller rack can't be closed once detached. Clicking on X-button does nothing.
  3. Trying to close instrument when detached crashes LMMS every time.
  4. Detaching any window and then clicking minimize freezes this window inside LMMS main window and the subwindow border icons/labels don't look correct. Expected functionality is to minimize detached window same way like main window.
  5. Detaching any window and then clicking maximize maximizes it inside LMMS main window and scrolling main window too much to the right. Expected functionality is to maximize detached window same way like main window.

LMMS 1.2.0-rc2.153
(Linux x86_64, Qt 5.7.1, GCC 6.3.0 20170406)

@lukas-w
Copy link
Member Author

lukas-w commented May 6, 2017

@karmux Thanks for testing! I'll have a look at the issues you pointed out as soon as I find the time. I already noticed number 2 (X-button doesn't work), but couldn't find the cause.

@Umcaruje Umcaruje added this to the 1.3.0 milestone May 7, 2017
@ivhacks
Copy link
Contributor

ivhacks commented May 7, 2017

This is super useful!!

I can't seem to make a windows build of it though. The build seems to go without a hitch, but when I open the app, it doesn't have the detach button. This might be my own error, but maybe someone else should look into it.

I can confirm all the issues that @karmux pointed out. Also, getting the detached window back into lmms is a little unwieldy. I basically need to re-open the window (for exmaple, clicking the FX-Mixer button to re-attach the FX-Mixer). Not exactly a bug, but it would be useful if the minimize button reattached the window, or if there was another button entirely.

Good job, looking forward to be able to use this for major producing :)

@NickAcPT
Copy link

NickAcPT commented Oct 9, 2017

Sorry for the bump.
@Jousboxx I agree with you when you gave the idea to make the minimize button reattach the window into LMMS.
But, if they were going to add a button inside the window to attach it back, they would need to adjust the window's content to account for the button.
Also, if you were talking about adding a button to the title bar, that would be a bit complicated and hard to maintain.

PS: Sorry to bother...

@ivhacks
Copy link
Contributor

ivhacks commented Oct 9, 2017

@NickAcPT Yeah, my idea is that since the minimize button reattaches, they wouldn't have to add another button. The minimize button on the main LMMS window should probably shrink all child windows so there is a way to minimize them.

@PhysSong PhysSong mentioned this pull request Mar 12, 2018
@PhysSong
Copy link
Member

This uses some Qt5-only features, so it's best to wait with merging this until we've switched

Now we've, so I think we can continue working on this.

When detached instruments are maximized then all instruments stay maximized inside LMMS until LMMS runs. I think there shouldn't be maximize button and functionality for instrument windows at all.

It's already fixed.

Mixer, project notes and controller rack can't be closed once detached. Clicking on X-button does nothing.

Trying to close instrument when detached crashes LMMS every time.

vstSubWin, ControllerDialog, EffectControlDialog, FxMixerView, SongEditor(this is fine because SongEditorWindow doesn't), ControllerRackView, ProjectNotes and IntrumentTrackWindow class overrides closeEvent and ignores close event. See #1495 (comment) for why we have such workarounds.

Detaching any window and then clicking minimize freezes this window inside LMMS main window and the subwindow border icons/labels don't look correct. Expected functionality is to minimize detached window same way like main window.

Detaching any window and then clicking maximize maximizes it inside LMMS main window and scrolling main window too much to the right. Expected functionality is to maximize detached window same way like main window.

I guess the event is propagated to SubWindow in some way. Installing an event filter which blocks propagation seems to fix it.

@PhysSong
Copy link
Member

PhysSong commented May 23, 2018

Found some more issues:

  • Window size is not preserved when using some window manager on X11(compiz on Ubuntu 18.04, unity session in my case). There's a known issue with frameGeometry on X11 so I'm not sure if we can work around this when attaching. It's from the difference between widget's size and subwindow's size.
  • When switching instrument, detached windows get attached automatically.

@PhysSong
Copy link
Member

if the minimize button reattached the window, or if there was another button entirely.

If the minimize button is used for attaching, wouldn't it be confusing? Also, I can't find platform-independent way to add such a button to the title bar unless we create a custom window class which would be quite difficult. There's an easier workaround, wrapping window content and window controls in a layout. It might be a little bit ugly, but it's easy.

@lukas-w may I continue this work?

@lukas-w
Copy link
Member Author

lukas-w commented May 24, 2018

@lukas-w may I continue this work?

Go for it. 👍

@PhysSong PhysSong force-pushed the feature/detach-window branch from cfed76a to 0b5eae1 Compare June 17, 2018 13:58
@PhysSong
Copy link
Member

Fixed almost all bugs reported by @karmux. As a side effects, minimize button doesn't re-attach windows anymore. I can restore the behavior, but I think that might be confusing.
Bugs in #3532 (comment) still needs to be fixed.

@karmux
Copy link
Contributor

karmux commented Jun 17, 2018

@PhysSong thank you! During a quick test I couldn't reproduce any of my previously reported bugs.
While testing I discovered now that I can't close sample track instrument in detached mode. Maybe happens because I have #3866 merged.

@PhysSong
Copy link
Member

Maybe happens because I have #3866 merged.

I think that's correct. IIRC I copied some code from instrument track and it had some issue(fixed in this PR).
When/If that one is merged, I will add a fix.

@lukas-w
Copy link
Member Author

lukas-w commented Jun 17, 2018

As a side effects, minimize button doesn't re-attach windows anymore.

It never did. This was just suggested by @Jousboxx in #3532 (comment).

@pwepwe973
Copy link

hello,
how to enable this option please?
thank you

@PhysSong
Copy link
Member

PhysSong commented Oct 9, 2018

@pwepwe973 This feature is in development and not a part of released versions. Sorry.

@pwepwe973
Copy link

thank you

@pwepwe973 This feature is in development and not a part of released versions. Sorry.

thank you for your message

@winniehell
Copy link
Contributor

@PhysSong Can you please summarize the current state of this? Is it ready to be merged?

I'm willing to help get this finished if possible.

@PhysSong
Copy link
Member

PhysSong commented Nov 7, 2019

@PhysSong Can you please summarize the current state of this?

I unintentionally abandoned this one, but I can restart working on this.

Is it ready to be merged?

Not yet, mainly due to #3532 (comment).

@messmerd
Copy link
Member

I tested the Linux AppImage that was automatically built for this PR, and there were some issues. The detach button didn't display correctly and the taskbar icon bug was back. However, when I built it locally, these issues were gone. I'm using Qt 5.15.2 locally, while the CI uses Qt 5.12.8, so they were likely upstream Qt bugs that got fixed.

#7316 updates our Qt version on Linux to Qt 5.15.2, so it would probably fix the CI issues here. I've just been waiting on people to review that PR.

@sqrvrt
Copy link
Contributor

sqrvrt commented Jan 27, 2025

@messmerd Since mixer can't be resized vertically anymore, shouldn't we disable maximizing? Is it even a good idea to disable vertical resizing?

@Rossmaxx
Copy link
Contributor

Didn't we add resize ability for mixer recently? Why you saying it ain't resizeable?

@sqrvrt
Copy link
Contributor

sqrvrt commented Jan 27, 2025

It was added back in bf922af#diff-ae4b38c15f268a0cd930edea9a6481663edf21a1ff206291784fd55b8513904eR182 for some reason. This was written long before I joined the discussion so I didn't really question it lol

So should we revert that line?

@messmerd
Copy link
Member

I haven't been following the recent work on the Mixer. If the Mixer in this PR deviates from the resize behavior on master, it should probably be reverted.

Conflicts:
- include/SubWindow.h
- src/gui/ControllerRackView.cpp
- src/gui/Editor.cpp
- src/gui/instrument/InstrumentTrackWindow.cpp

NOTE: PR #7514 caused a regression in InstrumentTrackWindow when merged
into this detachable windows PR.
@sqrvrt
Copy link
Contributor

sqrvrt commented Feb 4, 2025

Also what's the desired behavior for VeSTige controller window? rn it's very janky, doesn't have a title nor a maximize button and its maximum width is less than embedded area width.

Should I unfix the width so that it can be maximized and resized? (Here it could also be beneficial to tamper with scrollarea to snap the controls into the empty space, but this is really out of scope now)
or should I just set the flag to stop maximizing so that the behavior persists

@sqrvrt
Copy link
Contributor

sqrvrt commented Feb 8, 2025

#7688 fixes everything remaining I know of.

If no new issues are found, after its merge this pr will be actually ready this time.

@sqrvrt
Copy link
Contributor

sqrvrt commented Mar 28, 2025

Another issue I found with this is that opening any track in piano roll snaps it back to main window. This is probably due to the fact it "reopens" when the track is opened and this triggers the snap-back behavior buttons are supposed to do.

Something tells me reopening really shouldn't snap windows back.

@sqrvrt
Copy link
Contributor

sqrvrt commented Oct 14, 2025

Is there even a point in differentiation between DetachableWidget and DetachableWindow? From what I can see the only difference in them is the latter applies to QMainWindow (in codebase - things like Piano Roll, Song Editor, etc.) instead of Qwidget.

But QMainWindow inherits QWidget, shouldn't we be able to apply DetachableWidget to windows too?

* Attach windows on close instead of show

* use dynamic_cast instead of C cast
@messmerd
Copy link
Member

@SpomJ

Is there even a point in differentiation between DetachableWidget and DetachableWindow?

They are mostly the same, so if one of them could be removed, that would be awesome.

Conflicts:
- include/ControllerRackView.h
- include/Editor.h
- include/MixerView.h
- src/gui/SampleTrackWindow.cpp
- src/gui/SubWindow.cpp
- src/gui/editors/Editor.cpp
- src/gui/widgets/SimpleTextFloat.cpp
@sqrvrt
Copy link
Contributor

sqrvrt commented Oct 17, 2025

Heard some people say detaching straight up doesn't work on MacOS. If that's the case, perhaps we should add a check for mac in detach()?

@sqrvrt
Copy link
Contributor

sqrvrt commented Oct 17, 2025

btw working on #8091 right now, if there are any concerns about code style/structure I'd be happy to know. It's apparently a near-half rewrite of the way this currently works (it seems I overestimated the size of this PR lol), so I'm afraid to leave redundant functionality somewhere.

@sqrvrt
Copy link
Contributor

sqrvrt commented Oct 17, 2025

IMO it would also be interesting to have a setting to make all windows detached by default. What do you think?

@sqrvrt
Copy link
Contributor

sqrvrt commented Oct 19, 2025

Can someone explain SubWindow::eventFilter()? I don't immediately see it applied anywhere in the class and it doesn't seem to be referenced outside too. And yet it compares *obj to child widget(). Does this mean it's never actually different from QMdiSubWindow::eventFilter?

* Use eventFilter to process closeEvent

This frees us from having to inherit Detachable{Widget,Window}, and
instead we hook the handling directly in SubWindow.

* revert MixerView height cap

* Remove obsolete part of ITW::closeEvent

All removed functionality is being done in the event handler which gets
installed immediately after widget is given to SubWindow.

* refactor SampleTrackWindow, sync detached icon

- 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.

* Set window icon directly on InstrumenTrackView

* Preserve detached state in ITW prev/next buttons

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.

* remove leftover comment

* Account for size of decorations

Make SubWindow::attach() translate and move the child widget accounting
for SubWindow decorations (frame size and title bar height).

* Fix ITW movement again (lazy version)

* Move the close hook into SubWindow eventFilter

* Keep track of detached window while it's hidden

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.

* Code cleanup

* re-fix ITW because apparently it still breaks

* fix codestyle

* make another `if` inline

* more codestyle fixes

* Expand SubWindow::setWidget() docs

* Constrain attached window positions

Limit the positions to which the windows can be attached to those that
leave at least a small margin (currently 40px width, 40px height incl.
decorations) of the window visible. This is done to avoid windows
attaching extremely far if they're on a different workspace / monitor,
as well as hopefully help the user avoid losing their windows in
general.

* Hide windows when attaching on closeEvent

* Clarify wayland move workaround

* Remove redundant includes

* make detached closeEvent transparent

* fix editor windows minimizing their height on close

* Enable minimize button on detached windows

* Change detach button SVG

* rename detach icon

* clean up detach.svg

* Disable broken detach for MacOS builds

* fix typo

* revert SimpleTextFloat to master branch

* clean up diff against master

* Fix effect control views bing killed on close

DeleteOnClose flag is unset from being default in SubWindow since it
doesn't seem to be a desired default and in many places simply requires
workarounds that disable it.

Useless size restrictions EffectView imposes on SubWindow are removed
since those are already implicit and conform to layout size policy of
controlView.

* Use, init and update childGeomm only when detached

Tracking is only required for OS-level windows, and so is only
initialized when necessary. Avoids a function overload.

* Use std::clamp

* Make hide-on-attach-on-close configurable

Provide an option to hide/show SubWindow after attaching with close
button.

* Fix window size resetting for real this time

The reason it happened was because SubWindowgot shown before the widget
was visible, causing its height to reset to 0. Now widget visible state
is always set first, so this doesn't happen.

* Restore EffectView functionality actually

* Fix SubWindow label overlapping detach button

* Add SubWindow::eventFilter docs

* Get rid of childGeom

* Keep attached widget position

* Initial attempt at always-detach

* close autodetached windows properly

* Improve window positioning on attach

* Fix editor windows having minimal height on first show

* Remove redundant subwindow-related code from MainWindow

* fix typo in setup menu

* Fix ITW icon always showing up as piano

InstrumentView always overrides the icon (which didn't happen here for
wharever reason), rendering the icon setting useless even without the
bugfix.

* Update ControllerView

* minor formatting fixes

* even more minor formatting fixes

* Don't hard-set size of EffectView

This is optimistic and assumes all widgets that don't have a layout
already  fix their size. Even when this isn't true, it's better to set
it inside the effects and not the EffectView.

* Change label text

* Destroy childless subwindows

This is done in hopes that nothing ever uses SubWindow::setWidget
directly. Perhaps a more stable solution using SubWindow::childEvent is
due.

* Get rid of isResizable in EffectView

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.

* Fix EffectControlDialog not hiding the title bar

* Remove redundant widget->show() on showEvent

this is already being done in setVisible

* fix drag&drop not updating ITW SubWindow

* Disable FixedSizeDialogHint on ITW

Returns windowing buttons to all ITWs. Also conforms to Qt's advice, see
https://doc.qt.io/qt-6/qt.html#WindowType-enum

* Disable SubWindow flag when detaching a window

Could fix some bugs. Also get rid of manipulating Qt::Widget flag
manipulation since it's just 0 (fallback).

* Try disabling MacOS soft-fail

* Enable Undo/Redo globally

"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.

* Save detached window visibility properly; refactor

* remove obsolete qt version workarounds

* remove setFixedSize from LadspaControlDialog

* Fix resizing LadspaMatrixControlDialog

* Allow detached windows in topLevelITW; refactor

* allow detach to be disabled

* disable detach on embedded VST subwindows

* add attach/detach everything actions
@sqrvrt
Copy link
Contributor

sqrvrt commented Nov 24, 2025

PianoRollWindow::showEvent() calls hide() which softlocks the UI.
Conclusion: don't-show-piano-roll is being reworked

details **Edit:**

To clarify, it looks like showing a TextFloat from a hidden detached window crashes the X11 server in its entirety, and when running wayland-native softlocks the GUI (though strace still shows some activity).

Steps to reproduce:

  1. Add two or more non-empty clips to an instrument track
  2. Add an empty clip
  3. Open the empty clip in Piano Roll
  4. Detach piano roll
  5. Remove the empty clip (=> Piano Roll window is hidden)
  6. Open piano roll window with a toolbar button or the shortcut

On XWayland it appears to show an empty TextFloat before it dies

Edit 2:

It wasn't actually a Textfloat itself, but rather the subsequent hide(). For some reason PianoRollWindow::hide() inside PianoRollWindow::showEvent() just deadlocks the entire thing and lags the host, possibly due to an infinite recursion.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple Monitors