Package: gdk

GBoxed gdk:popup-layout

Details

Popups are positioned relative to their parent surface. The gdk:popup-layout structure contains information that is necessary to do so. The positioning requires a negotiation with the windowing system, since it depends on external constraints, such as the position of the parent surface, and the screen dimensions.

The basic ingredients are a rectangle on the parent surface, and the anchor on both that rectangle and the popup. The anchors specify a side or corner to place next to each other.

Figure: Popup anchors

For cases where placing the anchors next to each other would make the popup extend offscreen, the layout includes some hints for how to resolve this problem. The hints may suggest to flip the anchor position to the other side, or to 'slide' the popup along a side, or to resize it. These hints may be combined.

Figure: Flipping popups

Figure: Sliding popups

Ultimatively, it is up to the windowing system to determine the position and size of the popup. You can learn about the result by calling the gdk:popup-position-x, gdk:popup-position-y, gdk:popup-rect-anchor and gdk:popup-surface-anchor functions after the popup has been presented. This can be used to adjust the rendering. For example, the gtk:popover object changes its arrow position accordingly. But you have to be careful avoid changing the size of the popover, or it has to be presented again.
 

Returned by

See also

2024-2-17