Skip to content

Draft: Add dockable windows - #16432

Draft
Kontrabant wants to merge 1 commit into
libsdl-org:mainfrom
Kontrabant:docking
Draft

Kontrabant wants to merge 1 commit into
libsdl-org:mainfrom
Kontrabant:docking

Conversation

@Kontrabant

@Kontrabant Kontrabant commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Dockable windows will initially track the pointer when shown, for as long as the left mouse button is held, and will generate drop events when dragged over other windows that are part of the same process, so they can be 'dropped' onto other windows in the same process.

I've had this around for a while, so I think it's worth getting feedback on whether this is useful, worth rebasing, and continuing work on or not. It works on Win, Mac, X, and Wayland*, uses the existing drag and drop events, and doesn't need hacky, client-side workarounds to tell if a window is being dragged/dropped on another belonging to the same process, as it uses the system methods to tell if one window is above another viable drop target (i.e. #15028 would not be necessary with this).

The main use case I can see for this is cross-platform support in the Dear ImGui docking branch (see also ocornut/imgui#8609).

The new functionality can be experimented with in the testdocking test added to the test suite.

*On Wayland, it needs the xdg-toplevel-drag protocol, and after testing on KDE and GNOME, it only seems to work on KDE, despite GNOME advertising support for the protocol (no idea why at the moment; I've tried tweaking things and it just doesn't seem to work).

  • I confirm that I am the author of this code and release it to the SDL project under the zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Comment thread src/events/SDL_dropevents.c Outdated
}
}
if (drag_window) {
event.drop.dropWindowID = drag_window ? drag_window->id : 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant with the if guard above

@slouken

slouken commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Interesting idea. This seems fine to add for 3.6.

I assume this is only in-app docking, you can't drag into another compatible app to host your content?

@slouken slouken added this to the 3.6.0 milestone Oct 2, 2026
@Kontrabant

Copy link
Copy Markdown
Contributor Author

I assume this is only in-app docking, you can't drag into another compatible app to host your content?

Correct, it just lets you know if a dockable window is currently being dragged over another window in the same process. Functionally, it's similar to a QDockWidget in Qt.

@orowith2os

Copy link
Copy Markdown

I assume this is only in-app docking, you can't drag into another compatible app to host your content?

To clarify: this is mostly just because the mime types used are generally in-house. If you used a mime type that allowed another compatible app to reconstruct all of your data within that app (i.e. specifying your own custom mime type with all of the information within your window to rebuild it elsewhere), you could do that just fine, but it's generally quite a bit of hassle and not all that worth it, and the situations in which you could do so are pretty limited (and the more advanced use cases are things like IDEs, where they're usually already used to handling stuff like this, or browsers which, again, know how to handle this).

Dockable windows will initially track the pointer when shown, if the left mouse button is held when they are shown, and will generate drop events when dragged over other windows that are part of the same process.
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.

3 participants