How are GDK_WINDOW_CHILD windows created as subsurfaces in wayland?

I noticed that in wayland , popovers are created as subsurfaces rather than new windows. (I discovered this while investigating https://github.com/swaywm/sway/issues/4924.) I’m not really sure why it is a subsurface instead of using xdg_popup, but anyway, I was looking through the code of gtk and gdk to figure out how this was happening, and am quite confused about it. It appears that GtkPopover sets the window type to GDK_WINDOW_CHILD. But in should_map_as_subsurface we have the following code (https://github.com/swaywm/sway/issues/4924):

  if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_SUBSURFACE)
    return TRUE;

  if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TEMP)
    return FALSE;

but since the window type is GDK_WINDOW_CHILD, it seems like this should return false, but apparantly it doesn’t. What is going on?

The GtkPopover widget is a GtkBin container. When it is associated with a GtkWindow, the window creates a GDK_WINDOW_SUBSURFACE (Wayland only) and puts the popover’s GDK_WINDOW_CHILD inside of it: https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkwindow.c#L6720

1 Like

Ah, that makes sense. Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.