[PATCH 2/3] Add an id field to outputs
Pekka Paalanen
ppaalanen at gmail.com
Mon Apr 23 01:02:26 PDT 2012
On Fri, 20 Apr 2012 13:16:27 -0400
Kristian Hoegsberg <hoegsberg at gmail.com> wrote:
> On Thu, Apr 19, 2012 at 10:50:08PM -0400, cdahlin at redhat.com wrote:
> > From: Casey Dahlin <cdahlin at redhat.com>
> >
> > All outputs now have a unique integer ID, allocated from a bitfield pool in the
> > compositor.
>
> Committed this one with a few edits as described below.
>
> > Signed-off-by: Casey Dahlin <cdahlin at redhat.com>
> > ---
> > src/compositor.c | 15 +++++++++++++++
> > src/compositor.h | 4 ++++
> > 2 files changed, 19 insertions(+), 0 deletions(-)
> >
> > diff --git a/src/compositor.c b/src/compositor.c
> > index 3065f81..798b1e1 100644
> > --- a/src/compositor.c
> > +++ b/src/compositor.c
> > @@ -2303,6 +2303,17 @@ weston_output_move(struct weston_output *output, int x, int y)
> > output->current->height);
> > }
> >
> > +static void
> > +output_allocate_id(struct weston_output *output)
> > +{
> > + output->id = 0;
> > +
> > + while ((1 << output->id) & output->compositor->output_id_pool)
> > + output->id++;
> > +
> > + output->compositor->output_id_pool |= 1 << output->id;
> > +}
> > +
>
> We can just use ffs(~pool) - 1 to find the first available id here.
> With that this function is down to just two lines so I folded it back
> into weston_output_init.
Hi,
I see at least this patch in the weston repo does not detect running
out of ids. When output_id_pool is full, you get ffs(0)-1 = -1, and...
I guess the output_id using logic will fail. Was there something that
prevents allocating too many outputs (apart from reality ;-)?
Thanks,
pq
More information about the wayland-devel
mailing list