shell: Extract some common functions 92/27592/2
authorMarius Vlad <marius.vlad@collabora.com>
Tue, 31 May 2022 11:44:49 +0000 (14:44 +0300)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Fri, 10 Jun 2022 21:20:46 +0000 (21:20 +0000)
For instance this exports retreiving a ivi_seat from weston_seat, and
they are useful in other parts as well.

Bug-AGL: SPEC-4413
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I838823570792761dfb5ac4beea635e843dd5cd22

src/input.c
src/ivi-compositor.h
src/shell.c

index b6b104a..1a143ce 100644 (file)
@@ -32,7 +32,7 @@
 #include "ivi-compositor.h"
 #include "shared/helpers.h"
 
-static struct ivi_surface *
+struct ivi_surface *
 get_ivi_shell_surface(struct weston_surface *surface)
 {
        struct weston_desktop_surface *desktop_surface =
@@ -59,19 +59,37 @@ ivi_shell_seat_handle_destroy(struct wl_listener *listener, void *data)
        free(shseat);
 }
 
-static struct ivi_shell_seat *
+struct ivi_shell_seat *
 get_ivi_shell_seat(struct weston_seat *seat)
 {
        struct wl_listener *listener;
 
+       if (!seat)
+               return NULL;
+
+
        listener = wl_signal_get(&seat->destroy_signal,
                                 ivi_shell_seat_handle_destroy);
-       assert(listener != NULL);
+       if (!listener)
+               return NULL;
 
        return container_of(listener,
                            struct ivi_shell_seat, seat_destroy_listener);
 }
 
+struct weston_seat *
+get_ivi_shell_weston_first_seat(struct ivi_compositor *ivi)
+{
+       struct wl_list *node;
+       struct weston_compositor *compositor = ivi->compositor;
+
+       if (wl_list_empty(&compositor->seat_list))
+               return NULL;
+
+       node = compositor->seat_list.next;
+       return container_of(node, struct weston_seat, link);
+}
+
 static void
 ivi_shell_seat_handle_pointer_focus(struct wl_listener *listener, void *data)
 {
index fdf2bcb..6dbab99 100644 (file)
@@ -453,4 +453,13 @@ ivi_compositor_destroy_pending_surfaces(struct ivi_compositor *ivi);
 void
 ivi_shell_finalize(struct ivi_compositor *ivi);
 
+struct ivi_surface *
+get_ivi_shell_surface(struct weston_surface *surface);
+
+struct ivi_shell_seat *
+get_ivi_shell_seat(struct weston_seat *seat);
+
+struct weston_seat *
+get_ivi_shell_weston_first_seat(struct ivi_compositor *ivi);
+
 #endif
index c6cae10..09a9cb2 100644 (file)
 static void
 create_black_surface_view(struct ivi_output *output);
 
-static struct ivi_surface *
-get_ivi_shell_surface(struct weston_surface *wsurface)
-{
-       if (weston_surface_is_desktop_surface(wsurface)) {
-               struct weston_desktop_surface *dsurface =
-                       weston_surface_get_desktop_surface(wsurface);
-               return weston_desktop_surface_get_user_data(dsurface);
-       }
-
-       return NULL;
-}
-
 void
 agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                                           struct ivi_surface *surface)