Record monitor connect/disconnect events.

Each time we receive an XEvent we diff the list of currently connected
monitors with the list of previously connected monitors. Any
differences are recorded using the event recorder API. It is possible
that there will be no differences to record because XEvents are sent
for more events than just monitor connects and disconnects.

[endlessm/eos-sdk#635]
that makes no sense. and GVariantBuilder is doing precisely what you ask:
add bytes to an array. the issue is that you already know the size of the
array, and the contents, so there's no point in feeding it byte by byte.

also, g_variant_new() does not expect a GVariantBuilder for arrays: it
expects GVariant*, like the rest of the GVariant API.
`g_variant_new_fixed_array()` returns a GVariant of type a + `element_type`.

ciao,
 Emmanuele.




On 7 August 2014 19:30, Kurt von Laven <notifications@github.com> wrote:

> In src/core/monitor-xrandr.c:
>
> > @@ -1281,6 +1296,104 @@ meta_monitor_manager_xrandr_rebuild_derived (MetaMonitorManager *manager,
> >    meta_monitor_manager_rebuild_derived (manager);
> >  }
> >
> > +static GVariant *
> > +meta_monitor_manager_get_output_auxiliary_payload (MetaMonitorManager *manager,
> > +                                                   MetaOutput         *output)
> > +{
> > +  GVariantBuilder edid_builder;
> > +  GBytes *edid;
> > +  const guint8 *raw_edid;
> > +  gsize edid_length, i;
> > +
> > +  g_variant_builder_init (&edid_builder, G_VARIANT_TYPE ("ay"));
> > +  edid = meta_monitor_manager_xrandr_read_edid (manager, output);
> > +  raw_edid = g_bytes_get_data (edid, &edid_length);
> > +
> > +  for (i = 0; i < edid_length; i++)
>
> Actually, this optimization causes a crash because g_variant_new expects
> a GVariantBuilder * for an array of unsigned bytes ("ay"). Switching back
> to the original implementation. If GVariantBuilder is really inefficient,
> I think we should fix this upstream.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/endlessm/mutter/pull/9/files#r15954251>.
>



-- 
http://www.bassi.io
[@] ebassi [@gmail.com]