clients: support ivi-application.xml for clients/window.c
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Mon, 24 Nov 2014 05:28:33 +0000 (14:28 +0900)
committerJan Ekström <jan.ekstrom@intel.com>
Thu, 4 Dec 2014 11:34:18 +0000 (13:34 +0200)
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
clients/window.c

index e44d65c..ed850dd 100644 (file)
@@ -72,6 +72,10 @@ typedef void *EGLContext;
 
 #include "window.h"
 
+#include <sys/types.h>
+#include "ivi-application-client-protocol.h"
+#define IVI_SURFACE_ID 9000
+
 struct shm_pool;
 
 struct global {
@@ -91,6 +95,7 @@ struct display {
        struct text_cursor_position *text_cursor_position;
        struct workspace_manager *workspace_manager;
        struct xdg_shell *xdg_shell;
+       struct ivi_application *ivi_application; /* ivi style shell */
        EGLDisplay dpy;
        EGLConfig argb_config;
        EGLContext argb_ctx;
@@ -249,6 +254,8 @@ struct window {
        struct window *parent;
        struct wl_surface *last_parent_surface;
 
+       struct ivi_surface *ivi_surface;
+
        struct window_frame *frame;
 
        /* struct surface::link, contains also main_surface */
@@ -1379,6 +1386,19 @@ window_get_display(struct window *window)
 }
 
 static void
+handle_ivi_surface_configure(void *data, struct ivi_surface *ivi_surface,
+                             int32_t width, int32_t height)
+{
+       struct window *window = data;
+
+       window_schedule_resize(window, width, height);
+}
+
+static const struct ivi_surface_listener ivi_surface_listener = {
+        handle_ivi_surface_configure,
+};
+
+static void
 surface_create_surface(struct surface *surface, uint32_t flags)
 {
        struct display *display = surface->window->display;
@@ -1501,7 +1521,7 @@ window_destroy(struct window *window)
 
        wl_list_remove(&window->redraw_task.link);
 
-       wl_list_for_each(input, &display->input_list, link) {     
+       wl_list_for_each(input, &display->input_list, link) {
                if (input->touch_focus == window)
                        input->touch_focus = NULL;
                if (input->pointer_focus == window)
@@ -1526,6 +1546,9 @@ window_destroy(struct window *window)
        if (window->xdg_popup)
                xdg_popup_destroy(window->xdg_popup);
 
+       if (window->ivi_surface)
+               ivi_surface_destroy(window->ivi_surface);
+
        surface_destroy(window->main_surface);
 
        wl_list_remove(&window->link);
@@ -3051,7 +3074,7 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
                        wl_list_insert(&input->touch_point_list, &tp->link);
 
                        if (widget->touch_down_handler)
-                               (*widget->touch_down_handler)(widget, input, 
+                               (*widget->touch_down_handler)(widget, input,
                                                              serial, time, id,
                                                              sx, sy,
                                                              widget->user_data);
@@ -4489,7 +4512,7 @@ window_create_internal(struct display *display, int custom)
        surface = surface_create(window);
        window->main_surface = surface;
 
-       assert(custom || display->xdg_shell);
+       assert(custom || display->xdg_shell || display->ivi_application);
 
        window->custom = custom;
        window->preferred_format = WINDOW_PREFERRED_FORMAT_NONE;
@@ -4509,17 +4532,30 @@ struct window *
 window_create(struct display *display)
 {
        struct window *window;
+       uint32_t id_ivisurf;
 
        window = window_create_internal(display, 0);
 
-       window->xdg_surface =
-               xdg_shell_get_xdg_surface(window->display->xdg_shell,
-                                         window->main_surface->surface);
-       fail_on_null(window->xdg_surface);
+       if (window->display->xdg_shell) {
+               window->xdg_surface =
+                       xdg_shell_get_xdg_surface(window->display->xdg_shell,
+                                                 window->main_surface->surface);
+               fail_on_null(window->xdg_surface);
 
-       xdg_surface_set_user_data(window->xdg_surface, window);
-       xdg_surface_add_listener(window->xdg_surface,
-                                &xdg_surface_listener, window);
+               xdg_surface_set_user_data(window->xdg_surface, window);
+               xdg_surface_add_listener(window->xdg_surface,
+                                        &xdg_surface_listener, window);
+       } else if (display->ivi_application) {
+               /* auto generation of ivi_id based on process id + basement of id */
+               id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
+               window->ivi_surface =
+                       ivi_application_surface_create(display->ivi_application,
+                                                      id_ivisurf, window->main_surface->surface);
+               fail_on_null(window->ivi_surface);
+
+               ivi_surface_add_listener(window->ivi_surface,
+                                        &ivi_surface_listener, window);
+       }
 
        return window;
 }
@@ -4772,6 +4808,9 @@ window_show_menu(struct display *display,
 
        frame_interior(menu->frame, &ix, &iy, NULL, NULL);
 
+       if (!display->xdg_shell)
+               return;
+
        window->xdg_popup = xdg_shell_get_xdg_popup(display->xdg_shell,
                                                    window->main_surface->surface,
                                                    parent->main_surface->surface,
@@ -5231,6 +5270,11 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
                        wl_registry_bind(registry, id,
                                         &wl_subcompositor_interface, 1);
        }
+       else if (strcmp(interface, "ivi_application") == 0) {
+               d->ivi_application =
+                       wl_registry_bind(registry, id,
+                                        &ivi_application_interface, 1);
+       }
 
        if (d->global_handler)
                d->global_handler(d, id, interface, version, d->user_data);
@@ -5529,6 +5573,9 @@ display_destroy(struct display *display)
        if (display->xdg_shell)
                xdg_shell_destroy(display->xdg_shell);
 
+       if (display->ivi_application)
+               ivi_application_destroy(display->ivi_application);
+
        if (display->shm)
                wl_shm_destroy(display->shm);