[PATCH xserver 3/4 v3] xwayland: refactor Wayland event handling
Peter Hutterer
peter.hutterer at who-t.net
Fri Jun 3 04:20:33 UTC 2016
On Mon, May 23, 2016 at 06:11:43PM +0200, Olivier Fourdan wrote:
> To be able to reuse some code.
>
> Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
> ---
> v2: call prepre_read() before read() so we don't end up in a deadlock
> v3: no change, just keep the patch series together.
>
> hw/xwayland/xwayland.c | 44 ++++++++++++++++++++++++++++++++------------
> hw/xwayland/xwayland.h | 2 ++
> 2 files changed, 34 insertions(+), 12 deletions(-)
>
> diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
> index 151e044..748abdf 100644
> --- a/hw/xwayland/xwayland.c
> +++ b/hw/xwayland/xwayland.c
> @@ -460,14 +460,13 @@ static const struct wl_registry_listener registry_listener = {
> };
>
> static void
> -socket_handler(int fd, int ready, void *data)
> +xwl_read_events (struct xwl_screen *xwl_screen)
> {
> - struct xwl_screen *xwl_screen = data;
> int ret;
>
> ret = wl_display_read_events(xwl_screen->display);
> if (ret == -1)
> - FatalError("failed to dispatch Wayland events: %s\n", strerror(errno));
> + FatalError("failed to read Wayland events: %s\n", strerror(errno));
>
> xwl_screen->prepare_read = 0;
>
> @@ -477,18 +476,10 @@ socket_handler(int fd, int ready, void *data)
> }
>
> static void
> -wakeup_handler(void *data, int err, void *pRead)
> -{
> -}
> -
> -static void
> -block_handler(void *data, OSTimePtr pTimeout, void *pRead)
> +xwl_dispatch_events (struct xwl_screen *xwl_screen)
> {
> - struct xwl_screen *xwl_screen = data;
> int ret;
>
> - xwl_screen_post_damage(xwl_screen);
> -
> while (xwl_screen->prepare_read == 0 &&
> wl_display_prepare_read(xwl_screen->display) == -1) {
> ret = wl_display_dispatch_pending(xwl_screen->display);
> @@ -504,6 +495,35 @@ block_handler(void *data, OSTimePtr pTimeout, void *pRead)
> FatalError("failed to write to XWayland fd: %s\n", strerror(errno));
> }
>
> +static void
> +socket_handler(int fd, int ready, void *data)
> +{
> + struct xwl_screen *xwl_screen = data;
> +
> + xwl_read_events (xwl_screen);
> +}
> +
> +static void
> +wakeup_handler(void *data, int err, void *pRead)
> +{
> +}
> +
> +static void
> +block_handler(void *data, OSTimePtr pTimeout, void *pRead)
> +{
> + struct xwl_screen *xwl_screen = data;
> +
> + xwl_screen_post_damage(xwl_screen);
> + xwl_dispatch_events (xwl_screen);
> +}
> +
> +void
> +xwl_sync_events (struct xwl_screen *xwl_screen)
> +{
> + xwl_dispatch_events (xwl_screen);
> + xwl_read_events (xwl_screen);
> +}
> +
shouldn't this be in another patch if you're just reworking stuff here?
Cheers,
Peter
> static CARD32
> add_client_fd(OsTimerPtr timer, CARD32 time, void *arg)
> {
> diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
> index 5c053d9..70a0492 100644
> --- a/hw/xwayland/xwayland.h
> +++ b/hw/xwayland/xwayland.h
> @@ -155,6 +155,8 @@ struct xwl_output {
>
> struct xwl_pixmap;
>
> +void xwl_sync_events (struct xwl_screen *xwl_screen);
> +
> Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
>
> struct xwl_screen *xwl_screen_get(ScreenPtr screen);
> --
> 2.7.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list