Another attempt at adding support for popups #4444
Draft
+1,095
−503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
changelogmodule if knowledge of this change could be valuable to usersThis PR attempts to add support for popups, using an API design similar to that of GTK's low level popup API.
This adds a new
create_popupmethod to theActiveEventLooptrait, similar tocreate_window, but takes extraPopupAttributesandparent: WindowIdarguments.The new
PopupAttributesstruct is pretty much a direct mirror of GTK'sPopupLayout(barring the shadow width) (perhaps it would be worth linking to that page in the docs, since it provides a good explanation of the properties).I decided (at least for now) that this method should return a
dyn Window, since it seems most platforms treat popups the same as regular windows, and this would reduce code duplication, making it easier to add support for more platforms (though maybe it could be worth creating atrait Popup: Windowfor any popup-specific methods (seegdk_popup_get_{rect,surface}_anchor)).I have chosen to implement wayland support first, partly because it's what I use, and partly because it seems to be the only platform that treats popups specially, and is the most restrictive about their functionality (popups must have a parent, are positioned relative to that parent and are destroyed when they lose focus), so it was useful for figuring out the ideal API.
I've tried to implemnt this for X11, using an
override_redirectwindow andgrab_pointer, but I haven't found any way to destroy it when it loses focus (they don't seem to getXI_FocusOutevents).