Skip to content
  • Jonas Ådahl's avatar
    wayland: Make MetaWaylandDataSource ownership protocol specific · 5547c98f
    Jonas Ådahl authored
    Firstly, this patch makes MetawaylandDataSource a GObject. This is in
    order to easier track its lifetime without adding destroy signals etc. It
    also makes the vfunc table GObject class functions instead while at it,
    as well as moves protocol specific part of the source into their own
    implementations.
    
    An important part of this patch is the change of ownership. Prior to this
    patch, MetaWaylandDataDevice would kind of own the source, but for
    Wayland sources it would remove it if the corresponding wl_resource was
    destroyed. For XWayland clients it would own it completely, and only
    remove it if the source was replaced.
    
    This patch changes so that the protocol implementation owns the source.
    For Wayland sources, the wl_resource owns the source, and the
    MetaWaylandDataDevice sets a weak reference (so in other words, no
    semantical changes really). For XWayland sources, the source is owned by
    the selection bridge, and not removed until replaced or if the client
    goes away.
    
    Given the changes in ownership, data offers may now properly track the
    lifetime of a source it represents. Prior to this patch, if an offer with
    an XWayland source would loose its source, it wouldn't get notified and
    have an invalid pointer it would potentally crash on. For Wayland
    sources, an offer would have a weak reference and clean itself up if the
    source went away. This patch changes so the behavior is consistent,
    meaning a weak reference is added to the source GObject so that the offer
    can behave correctly both for Wayland sources and XWayland sources.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750680
    5547c98f