clients: support ivi-application.xml for clients/simple-egl.c

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Nobuhiko Tanibata 10 years ago committed by Pekka Paalanen
parent fba4ea3627
commit 4f01a0b1f7
  1. 4
      Makefile.am
  2. 95
      clients/simple-egl.c

@ -438,7 +438,9 @@ demo_clients += weston-simple-egl
weston_simple_egl_SOURCES = clients/simple-egl.c weston_simple_egl_SOURCES = clients/simple-egl.c
nodist_weston_simple_egl_SOURCES = \ nodist_weston_simple_egl_SOURCES = \
protocol/xdg-shell-protocol.c \ protocol/xdg-shell-protocol.c \
protocol/xdg-shell-client-protocol.h protocol/xdg-shell-client-protocol.h \
protocol/ivi-application-protocol.c \
protocol/ivi-application-client-protocol.h
weston_simple_egl_CFLAGS = $(AM_CFLAGS) $(SIMPLE_EGL_CLIENT_CFLAGS) weston_simple_egl_CFLAGS = $(AM_CFLAGS) $(SIMPLE_EGL_CLIENT_CFLAGS)
weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
endif endif

@ -41,6 +41,10 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include <sys/types.h>
#include <unistd.h>
#include "protocol/ivi-application-client-protocol.h"
#define IVI_SURFACE_ID 9000
#ifndef EGL_EXT_swap_buffers_with_damage #ifndef EGL_EXT_swap_buffers_with_damage
#define EGL_EXT_swap_buffers_with_damage 1 #define EGL_EXT_swap_buffers_with_damage 1
@ -74,6 +78,7 @@ struct display {
EGLConfig conf; EGLConfig conf;
} egl; } egl;
struct window *window; struct window *window;
struct ivi_application *ivi_application;
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage; PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
}; };
@ -95,6 +100,7 @@ struct window {
struct wl_egl_window *native; struct wl_egl_window *native;
struct wl_surface *surface; struct wl_surface *surface;
struct xdg_surface *xdg_surface; struct xdg_surface *xdg_surface;
struct ivi_surface *ivi_surface;
EGLSurface egl_surface; EGLSurface egl_surface;
struct wl_callback *callback; struct wl_callback *callback;
int fullscreen, opaque, buffer_size, frame_sync; int fullscreen, opaque, buffer_size, frame_sync;
@ -255,7 +261,7 @@ init_gl(struct window *window)
} }
glUseProgram(program); glUseProgram(program);
window->gl.pos = 0; window->gl.pos = 0;
window->gl.col = 1; window->gl.col = 1;
@ -316,18 +322,61 @@ static const struct xdg_surface_listener xdg_surface_listener = {
}; };
static void static void
create_surface(struct window *window) handle_ivi_surface_configure(void *data, struct ivi_surface *ivi_surface,
int32_t width, int32_t height)
{
struct window *window = data;
wl_egl_window_resize(window->native, width, height, 0, 0);
window->geometry.width = width;
window->geometry.height = height;
if (!window->fullscreen)
window->window_size = window->geometry;
}
static const struct ivi_surface_listener ivi_surface_listener = {
handle_ivi_surface_configure,
};
static void
create_xdg_surface(struct window *window, struct display *display)
{ {
struct display *display = window->display;
EGLBoolean ret;
window->surface = wl_compositor_create_surface(display->compositor);
window->xdg_surface = xdg_shell_get_xdg_surface(display->shell, window->xdg_surface = xdg_shell_get_xdg_surface(display->shell,
window->surface); window->surface);
xdg_surface_add_listener(window->xdg_surface, xdg_surface_add_listener(window->xdg_surface,
&xdg_surface_listener, window); &xdg_surface_listener, window);
xdg_surface_set_title(window->xdg_surface, "simple-egl");
}
static void
create_ivi_surface(struct window *window, struct display *display)
{
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();
}
ivi_surface_add_listener(window->ivi_surface,
&ivi_surface_listener, window);
}
static void
create_surface(struct window *window)
{
struct display *display = window->display;
EGLBoolean ret;
window->surface = wl_compositor_create_surface(display->compositor);
window->native = window->native =
wl_egl_window_create(window->surface, wl_egl_window_create(window->surface,
window->geometry.width, window->geometry.width,
@ -337,7 +386,13 @@ create_surface(struct window *window)
display->egl.conf, display->egl.conf,
window->native, NULL); window->native, NULL);
xdg_surface_set_title(window->xdg_surface, "simple-egl"); if (display->shell) {
create_xdg_surface(window, display);
} else if (display->ivi_application ) {
create_ivi_surface(window, display);
} else {
assert(0);
}
ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface, ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
window->egl_surface, window->display->egl.ctx); window->egl_surface, window->display->egl.ctx);
@ -346,6 +401,9 @@ create_surface(struct window *window)
if (!window->frame_sync) if (!window->frame_sync)
eglSwapInterval(display->egl.dpy, 0); eglSwapInterval(display->egl.dpy, 0);
if (!display->shell)
return;
if (window->fullscreen) if (window->fullscreen)
xdg_surface_set_fullscreen(window->xdg_surface, NULL); xdg_surface_set_fullscreen(window->xdg_surface, NULL);
} }
@ -361,7 +419,10 @@ destroy_surface(struct window *window)
eglDestroySurface(window->display->egl.dpy, window->egl_surface); eglDestroySurface(window->display->egl.dpy, window->egl_surface);
wl_egl_window_destroy(window->native); wl_egl_window_destroy(window->native);
xdg_surface_destroy(window->xdg_surface); if (window->xdg_surface)
xdg_surface_destroy(window->xdg_surface);
if (window->display->ivi_application)
ivi_surface_destroy(window->ivi_surface);
wl_surface_destroy(window->surface); wl_surface_destroy(window->surface);
if (window->callback) if (window->callback)
@ -515,9 +576,12 @@ pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
{ {
struct display *display = data; struct display *display = data;
if (!display->window->xdg_surface)
return;
if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED)
xdg_surface_move(display->window->xdg_surface, xdg_surface_move(display->window->xdg_surface,
display->seat, serial); display->seat, serial);
} }
static void static void
@ -541,6 +605,9 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
{ {
struct display *d = (struct display *)data; struct display *d = (struct display *)data;
if (!d->shell)
return;
xdg_surface_move(d->window->xdg_surface, d->seat, serial); xdg_surface_move(d->window->xdg_surface, d->seat, serial);
} }
@ -600,6 +667,9 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
{ {
struct display *d = data; struct display *d = data;
if (!d->shell)
return;
if (key == KEY_F11 && state) { if (key == KEY_F11 && state) {
if (d->window->fullscreen) if (d->window->fullscreen)
xdg_surface_unset_fullscreen(d->window->xdg_surface); xdg_surface_unset_fullscreen(d->window->xdg_surface);
@ -710,6 +780,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
fprintf(stderr, "unable to load default left pointer\n"); fprintf(stderr, "unable to load default left pointer\n");
// TODO: abort ? // TODO: abort ?
} }
} else if (strcmp(interface, "ivi_application") == 0) {
d->ivi_application =
wl_registry_bind(registry, name,
&ivi_application_interface, 1);
} }
} }
@ -816,6 +890,9 @@ main(int argc, char **argv)
if (display.shell) if (display.shell)
xdg_shell_destroy(display.shell); xdg_shell_destroy(display.shell);
if (display.ivi_application)
ivi_application_destroy(display.ivi_application);
if (display.compositor) if (display.compositor)
wl_compositor_destroy(display.compositor); wl_compositor_destroy(display.compositor);

Loading…
Cancel
Save