[PATCH weston-ivi-shell 15/15] Modify example clients to support ivi-application.xml
Nobuhiko Tanibata
NOBUHIKO_TANIBATA at xddp.denso.co.jp
Thu Mar 6 02:07:10 PST 2014
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>
---
clients/.gitignore | 5 ++++
clients/Makefile.am | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++
clients/simple-egl.c | 67 ++++++++++++++++++++++++++++++++++++++++++++--------
clients/simple-shm.c | 50 ++++++++++++++++++++++++++++++++++-----
clients/window.c | 42 ++++++++++++++++++++++++++++++--
5 files changed, 211 insertions(+), 18 deletions(-)
diff --git a/clients/.gitignore b/clients/.gitignore
index d23027c..41b3be3 100644
--- a/clients/.gitignore
+++ b/clients/.gitignore
@@ -20,6 +20,11 @@ weston-stacking
weston-subsurfaces
weston-transformed
weston-view
+weston-clickdot-ivi
+weston-flower-ivi
+weston-simple-egl-ivi
+weston-simple-shm-ivi
+weston-smoke-ivi
desktop-shell-client-protocol.h
desktop-shell-protocol.c
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f8d4a6..4bbacb3 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -7,6 +7,11 @@ demo_clients = \
$(simple_clients_programs) \
$(simple_egl_clients_programs)
+if ENABLE_IVI_SHELL
+demo_clients += \
+ $(ivi_shell_clients_programs)
+endif
+
if INSTALL_DEMO_CLIENTS
bin_PROGRAMS += $(demo_clients)
else
@@ -246,6 +251,66 @@ endif
endif
+if ENABLE_IVI_SHELL
+noinst_LTLIBRARIES = libivitoytoolkit.la
+
+libivitoytoolkit_la_SOURCES = \
+ window.c \
+ window.h \
+ text-cursor-position-protocol.c \
+ text-cursor-position-client-protocol.h \
+ scaler-protocol.c \
+ scaler-client-protocol.h \
+ workspaces-protocol.c \
+ workspaces-client-protocol.h
+
+libivitoytoolkit_la_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_IVI_CLIENT
+
+libivitoytoolkit_la_LIBADD = \
+ $(CLIENT_LIBS) \
+ $(CAIRO_EGL_LIBS) \
+ ../shared/libshared-cairo.la -lrt -lm
+
+ivi_shell_clients_programs = \
+ weston-simple-egl-ivi \
+ weston-simple-shm-ivi \
+ weston-flower-ivi \
+ weston-smoke-ivi \
+ weston-clickdot-ivi
+
+weston_simple_egl_ivi_SOURCES = simple-egl.c \
+ ../ivi-shell/ivi-application-protocol.c \
+ ../ivi-shell/ivi-application-client-protocol.h
+weston_simple_egl_ivi_CPPFLAGS = $(SIMPLE_EGL_CLIENT_CFLAGS) -DENABLE_IVI_CLIENT
+weston_simple_egl_ivi_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
+
+weston_simple_shm_ivi_SOURCES = simple-shm.c \
+ ../shared/os-compatibility.c \
+ ../shared/os-compatibility.h \
+ ../ivi-shell/ivi-application-protocol.c \
+ ../ivi-shell/ivi-application-client-protocol.h
+weston_simple_shm_ivi_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) -DENABLE_IVI_CLIENT
+weston_simple_shm_ivi_LDADD = $(SIMPLE_CLIENT_LIBS)
+
+weston_flower_ivi_SOURCES = flower.c \
+ ../ivi-shell/ivi-application-protocol.c \
+ ../ivi-shell/ivi-application-client-protocol.h
+weston_flower_ivi_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_IVI_CLIENT
+weston_flower_ivi_LDADD = libivitoytoolkit.la
+
+weston_smoke_ivi_SOURCES = smoke.c \
+ ../ivi-shell/ivi-application-protocol.c \
+ ../ivi-shell/ivi-application-client-protocol.h
+weston_smoke_ivi_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_IVI_CLIENT
+weston_smoke_ivi_LDADD = libivitoytoolkit.la
+
+weston_clickdot_ivi_SOURCES = clickdot.c \
+ ../ivi-shell/ivi-application-protocol.c \
+ ../ivi-shell/ivi-application-client-protocol.h
+weston_clickdot_ivi_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_IVI_CLIENT
+weston_clickdot_ivi_LDADD = libivitoytoolkit.la
+endif
+
wayland_protocoldir = $(top_srcdir)/protocol
include $(top_srcdir)/wayland-scanner.mk
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 2c009ee..b06742f 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -38,6 +38,13 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#ifdef ENABLE_IVI_CLIENT
+#include <sys/types.h>
+#include <unistd.h>
+#include "../ivi-shell/ivi-application-client-protocol.h"
+#define IVI_SURFACE_ID 9000
+#endif
+
#ifndef EGL_EXT_swap_buffers_with_damage
#define EGL_EXT_swap_buffers_with_damage 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
@@ -70,6 +77,9 @@ struct display {
EGLConfig conf;
} egl;
struct window *window;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_application *ivi_application;
+#endif
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
};
@@ -91,6 +101,9 @@ struct window {
struct wl_egl_window *native;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_surface *ivi_surface;
+#endif
EGLSurface egl_surface;
struct wl_callback *callback;
int fullscreen, configured, opaque, buffer_size, frame_sync;
@@ -250,7 +263,7 @@ init_gl(struct window *window)
}
glUseProgram(program);
-
+
window->gl.pos = 0;
window->gl.col = 1;
@@ -318,6 +331,12 @@ set_fullscreen(struct window *window, int fullscreen)
window->fullscreen = fullscreen;
window->configured = 0;
+ if (!window->shell_surface) {
+ handle_configure(window, NULL, 0, 250, 250);
+ window->configured = 1;
+ return;
+ }
+
if (fullscreen) {
wl_shell_surface_set_fullscreen(window->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
@@ -341,13 +360,15 @@ create_surface(struct window *window)
{
struct display *display = window->display;
EGLBoolean ret;
-
+
window->surface = wl_compositor_create_surface(display->compositor);
- window->shell_surface = wl_shell_get_shell_surface(display->shell,
- window->surface);
+ if (display->shell)
+ window->shell_surface = wl_shell_get_shell_surface(display->shell,
+ window->surface);
- wl_shell_surface_add_listener(window->shell_surface,
- &shell_surface_listener, window);
+ if (window->shell_surface)
+ wl_shell_surface_add_listener(window->shell_surface,
+ &shell_surface_listener, window);
window->native =
wl_egl_window_create(window->surface,
@@ -357,8 +378,18 @@ create_surface(struct window *window)
eglCreateWindowSurface(display->egl.dpy,
display->egl.conf,
window->native, NULL);
+#ifdef ENABLE_IVI_CLIENT
+ uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
+ window->ivi_surface = ivi_application_surface_create(display->ivi_application,
+ id_ivisurf, window->surface);
+ if (window->ivi_surface == NULL) {
+ fprintf(stderr, "Failed to create ivi_client_surface\n");
+ abort();
+ }
+#endif
- wl_shell_surface_set_title(window->shell_surface, "simple-egl");
+ if (window->shell_surface)
+ wl_shell_surface_set_title(window->shell_surface, "simple-egl");
ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
window->egl_surface, window->display->egl.ctx);
@@ -381,7 +412,8 @@ destroy_surface(struct window *window)
eglDestroySurface(window->display->egl.dpy, window->egl_surface);
wl_egl_window_destroy(window->native);
- wl_shell_surface_destroy(window->shell_surface);
+ if (window->shell_surface)
+ wl_shell_surface_destroy(window->shell_surface);
wl_surface_destroy(window->surface);
if (window->callback)
@@ -542,7 +574,8 @@ pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
{
struct display *display = data;
- if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED)
+ if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED &&
+ display->window->shell_surface)
wl_shell_surface_move(display->window->shell_surface,
display->seat, serial);
}
@@ -568,7 +601,8 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
{
struct display *d = (struct display *)data;
- wl_shell_surface_move(d->window->shell_surface, d->seat, serial);
+ if (d->window->shell_surface)
+ wl_shell_surface_move(d->window->shell_surface, d->seat, serial);
}
static void
@@ -709,6 +743,11 @@ registry_handle_global(void *data, struct wl_registry *registry,
d->default_cursor =
wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
}
+#ifdef ENABLE_IVI_CLIENT
+ else if (strcmp(interface, "ivi_application") == 0) {
+ d->ivi_application = wl_registry_bind(registry, name, &ivi_application_interface, 1);
+ }
+#endif
}
static void
@@ -805,6 +844,11 @@ main(int argc, char **argv)
fprintf(stderr, "simple-egl exiting\n");
+#ifdef ENABLE_IVI_CLIENT
+ ivi_surface_destroy(window.ivi_surface);
+ ivi_application_destroy(window.display->ivi_application);
+#endif
+
destroy_surface(&window);
fini_egl(&display);
@@ -819,6 +863,9 @@ main(int argc, char **argv)
wl_compositor_destroy(display.compositor);
wl_registry_destroy(display.registry);
+#ifdef ENABLE_IVI_CLIENT
+ wl_display_roundtrip(display.display);
+#endif
wl_display_flush(display.display);
wl_display_disconnect(display.display);
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 81bb54e..10acf5d 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -35,6 +35,12 @@
#include <wayland-client.h>
#include "../shared/os-compatibility.h"
+#ifdef ENABLE_IVI_CLIENT
+#include <sys/types.h>
+#include "../ivi-shell/ivi-application-client-protocol.h"
+#define IVI_SURFACE_ID 9000
+#endif
+
struct display {
struct wl_display *display;
struct wl_registry *registry;
@@ -42,6 +48,9 @@ struct display {
struct wl_shell *shell;
struct wl_shm *shm;
uint32_t formats;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_application *ivi_application;
+#endif
};
struct buffer {
@@ -55,6 +64,9 @@ struct window {
int width, height;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_surface *ivi_surface;
+#endif
struct buffer buffers[2];
struct buffer *prev_buffer;
struct wl_callback *callback;
@@ -148,16 +160,29 @@ create_window(struct display *display, int width, int height)
window->width = width;
window->height = height;
window->surface = wl_compositor_create_surface(display->compositor);
- window->shell_surface = wl_shell_get_shell_surface(display->shell,
- window->surface);
+ if (display->shell)
+ window->shell_surface = wl_shell_get_shell_surface(display->shell,
+ window->surface);
if (window->shell_surface)
wl_shell_surface_add_listener(window->shell_surface,
&shell_surface_listener, window);
- wl_shell_surface_set_title(window->shell_surface, "simple-shm");
+#ifdef ENABLE_IVI_CLIENT
+ uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
+ window->ivi_surface = ivi_application_surface_create(display->ivi_application,
+ id_ivisurf, window->surface);
+ if (window->ivi_surface == NULL) {
+ fprintf(stderr, "Failed to create ivi_client_surface\n");
+ abort();
+ }
+#endif
- wl_shell_surface_set_toplevel(window->shell_surface);
+ if (window->shell_surface) {
+ wl_shell_surface_set_title(window->shell_surface, "simple-shm");
+
+ wl_shell_surface_set_toplevel(window->shell_surface);
+ }
return window;
}
@@ -173,7 +198,8 @@ destroy_window(struct window *window)
if (window->buffers[1].buffer)
wl_buffer_destroy(window->buffers[1].buffer);
- wl_shell_surface_destroy(window->shell_surface);
+ if (window->shell_surface)
+ wl_shell_surface_destroy(window->shell_surface);
wl_surface_destroy(window->surface);
free(window);
}
@@ -318,6 +344,11 @@ registry_handle_global(void *data, struct wl_registry *registry,
id, &wl_shm_interface, 1);
wl_shm_add_listener(d->shm, &shm_listener, d);
}
+#ifdef ENABLE_IVI_CLIENT
+ else if (strcmp(interface, "ivi_application") == 0) {
+ d->ivi_application = wl_registry_bind(registry, id, &ivi_application_interface, 1);
+ }
+#endif
}
static void
@@ -362,7 +393,7 @@ create_display(void)
}
wl_display_get_fd(display->display);
-
+
return display;
}
@@ -379,6 +410,9 @@ destroy_display(struct display *display)
wl_compositor_destroy(display->compositor);
wl_registry_destroy(display->registry);
+#ifdef ENABLE_IVI_CLIENT
+ wl_display_roundtrip(display->display);
+#endif
wl_display_flush(display->display);
wl_display_disconnect(display->display);
free(display);
@@ -420,6 +454,10 @@ main(int argc, char **argv)
ret = wl_display_dispatch(display->display);
fprintf(stderr, "simple-shm exiting\n");
+#ifdef ENABLE_IVI_CLIENT
+ ivi_surface_destroy(window->ivi_surface);
+ ivi_application_destroy(window->display->ivi_application);
+#endif
destroy_window(window);
destroy_display(display);
diff --git a/clients/window.c b/clients/window.c
index d8d79d0..928e405 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -71,6 +71,12 @@ typedef void *EGLContext;
#include "window.h"
+#ifdef ENABLE_IVI_CLIENT
+#include <sys/types.h>
+#include "../ivi-shell/ivi-application-client-protocol.h"
+#define IVI_SURFACE_ID 9000
+#endif
+
struct shm_pool;
struct global {
@@ -132,6 +138,9 @@ struct display {
int has_rgb565;
int seat_version;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_application *ivi_application;
+#endif
};
enum {
@@ -252,6 +261,9 @@ struct window {
struct surface *main_surface;
struct wl_shell_surface *shell_surface;
+#ifdef ENABLE_IVI_CLIENT
+ struct ivi_surface *ivi_surface;
+#endif
struct window_frame *frame;
@@ -1403,6 +1415,18 @@ surface_create_surface(struct surface *surface, int dx, int dy, uint32_t flags)
struct display *display = surface->window->display;
struct rectangle allocation = surface->allocation;
+#ifdef ENABLE_IVI_CLIENT
+ if (!surface->toysurface) {
+ uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
+ surface->window->ivi_surface = ivi_application_surface_create(display->ivi_application,
+ id_ivisurf, surface->surface);
+ if (surface->window->ivi_surface == NULL) {
+ fprintf(stderr, "Failed to create ivi_client_surface\n");
+ abort();
+ }
+ }
+#endif
+
if (!surface->toysurface && display->dpy &&
surface->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW) {
surface->toysurface =
@@ -1518,6 +1542,11 @@ surface_destroy(struct surface *surface)
if (surface->toysurface)
surface->toysurface->destroy(surface->toysurface);
+#ifdef ENABLE_IVI_CLIENT
+ ivi_surface_destroy(surface->window->ivi_surface);
+ ivi_application_destroy(surface->window->display->ivi_application);
+#endif
+
wl_list_remove(&surface->link);
free(surface);
}
@@ -1532,7 +1561,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)
@@ -3039,7 +3068,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);
@@ -5017,6 +5046,11 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
wl_registry_bind(registry, id,
&wl_subcompositor_interface, 1);
}
+#ifdef ENABLE_IVI_CLIENT
+ else if (strcmp(interface, "ivi_application") == 0) {
+ d->ivi_application = wl_registry_bind(registry, id, &ivi_application_interface, 1);
+ }
+#endif
if (d->global_handler)
d->global_handler(d, id, interface, version, d->user_data);
@@ -5326,6 +5360,10 @@ display_destroy(struct display *display)
close(display->epoll_fd);
+#ifdef ENABLE_IVI_CLIENT
+ wl_display_roundtrip(display->display);
+#endif
+
if (!(display->display_fd_events & EPOLLERR) &&
!(display->display_fd_events & EPOLLHUP))
wl_display_flush(display->display);
--
1.8.3.1
More information about the wayland-devel
mailing list