[PATCH weston 2/6] libweston: Use the monotonic clock in weston_compositor_get_time

Dima Ryazanov dima at gmail.com
Tue Dec 6 18:18:41 UTC 2016


On Tue, Dec 6, 2016 at 3:32 AM, Daniel Stone <daniel at fooishbar.org> wrote:

> Hi,
>
> On 5 December 2016 at 03:36, Dima Ryazanov <dima at gmail.com> wrote:
> > (This is kind of a workaround, but perhaps the right thing to do
> anyways.)
> >
> > The menu implementation in window.c needs to know the time of the event
> that
> > triggered the menu - however, the xdg-shell's show_window_menu API does
> not
> > give us that info. There doesn't seem to be an easy way to fake it
> because
> > different compositors use different times when sending events:
> > - compositor-drm uses the monotonic clock
> > - compositor-x11 uses weston_compositor_get_time
> > - compositor-wayland uses the event times in got from the parent
> compositor
> > - GNOME appears to use the monotonic clock
> >
> > Switching weston_compositor_get_time to use the monotonic clock works
> around
> > this issue - though things would break in compositor-wayland if its
> parent
> > uses something else.
> >
> > Signed-off-by: Dima Ryazanov <dima at gmail.com>
>
> I think we may want a check that CLOCK_MONOTONIC actually works (i.e.
> the first time this function is called, assert that ret == 0). But
> yes, it's definitely the right thing to do, so with that:
> Reviewed-by: Daniel Stone <daniels at collabora.com>
>

If we're going to assert, do you think it's ok to just assert every time?
That would make the logic simpler - and it doesn't look like it could
succeed once, then fail later.

Though almost all of the existing code just ignores the return value. It
would be good to either handle failures everywhere, or just assert that the
clock works when Weston starts up.

Cheers,
> Daniel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20161206/bb22db6c/attachment.html>


More information about the wayland-devel mailing list