aboutsummaryrefslogtreecommitdiffstats
path: root/meta-ivi/recipes-graphics/wayland/weston-1.6.0/0011-clients-support-ivi-application.xml-for-clients-simp.patch
blob: 7ff4a4d26143f07583b741967d6bcda054ab0bfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
From 072fc2e415ad7ba7e2737ee1a71c2ac1375a8f5f Mon Sep 17 00:00:00 2001
From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Date: Wed, 15 Oct 2014 12:13:14 +0900
Subject: [PATCH 11/15] clients: support ivi-application.xml for
 clients/simple-egl.c

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

remove NULL entry in listener

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, remove listener of visibility event

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, remove unnecesary roundtrip

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, remove useless commented code

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, Opening brace belongs on the previous line.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, Follow the style already in this file: 'else if

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl.c,Fix invalid function calling.

> Calling handle_surface_configure() is detrimental here, you are
> confusing
> xdg_shell code paths with ivi_application code paths, and needing to
> modify
> the xdg_shell code path to cope with a bogus call.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl.c, whitespace clean up

> Why this change? Broken indentation.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl.c,Rename variable name from fullscreen into maximized.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl,whitespace clean up

> Why these changes?

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl,clean up

> Instead of reindenting everything, just do
> at the top. c

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl,Separate a messy function to two functions.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl,whitespace clean up

> Broken indentation

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl, replace 8 spaces to tab

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl,Delete unnecessary if condition.

> You are still adding the 'if (states)' which was not there originally.
> What I meant was, you should not have done any modifications to this
> function. This is an xdg_shell event handler, not for ivi_application

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: simple-egl.c, clean up code

> You shouldn't have changed this in the first place.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

---------------------------------------------------------
clients: cimple-egl, Delete unnecessary function call.

> That's better, now the earlier original changes to
> handle_surface_configure() are not needed at all.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
---
 Makefile.am          |    4 +-
 clients/simple-egl.c |  114 ++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 96 insertions(+), 22 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index df67cbc..081c854 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -441,7 +441,9 @@ demo_clients += weston-simple-egl
 weston_simple_egl_SOURCES = clients/simple-egl.c
 nodist_weston_simple_egl_SOURCES =		\
 	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_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
 endif
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 33e711c..8e4433d 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -41,6 +41,10 @@
 #include <EGL/eglext.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
 #define EGL_EXT_swap_buffers_with_damage 1
@@ -74,6 +78,7 @@ struct display {
 		EGLConfig conf;
 	} egl;
 	struct window *window;
+	struct ivi_application *ivi_application;
 
 	PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
 };
@@ -95,9 +100,10 @@ struct window {
 	struct wl_egl_window *native;
 	struct wl_surface *surface;
 	struct xdg_surface *xdg_surface;
+	struct ivi_surface *ivi_surface;
 	EGLSurface egl_surface;
 	struct wl_callback *callback;
-	int fullscreen, opaque, buffer_size, frame_sync;
+	int maximized, opaque, buffer_size, frame_sync;
 };
 
 static const char *vert_shader_text =
@@ -255,7 +261,7 @@ init_gl(struct window *window)
 	}
 
 	glUseProgram(program);
-	
+
 	window->gl.pos = 0;
 	window->gl.col = 1;
 
@@ -275,24 +281,24 @@ handle_surface_configure(void *data, struct xdg_surface *surface,
 	struct window *window = data;
 	uint32_t *p;
 
-	window->fullscreen = 0;
+	window->maximized = 0;
 	wl_array_for_each(p, states) {
 		uint32_t state = *p;
 		switch (state) {
-		case XDG_SURFACE_STATE_FULLSCREEN:
-			window->fullscreen = 1;
-			break;
+			case XDG_SURFACE_STATE_FULLSCREEN:
+				window->maximized = 1;
+				break;
 		}
 	}
 
 	if (width > 0 && height > 0) {
-		if (!window->fullscreen) {
+		if (!window->maximized) {
 			window->window_size.width = width;
 			window->window_size.height = height;
 		}
 		window->geometry.width = width;
 		window->geometry.height = height;
-	} else if (!window->fullscreen) {
+	} else if (!window->maximized) {
 		window->geometry = window->window_size;
 	}
 
@@ -301,6 +307,9 @@ handle_surface_configure(void *data, struct xdg_surface *surface,
 				     window->geometry.width,
 				     window->geometry.height, 0, 0);
 
+	if (!window->display || !window->display->shell)
+		return;
+
 	xdg_surface_ack_configure(surface, serial);
 }
 
@@ -316,18 +325,61 @@ static const struct xdg_surface_listener xdg_surface_listener = {
 };
 
 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->maximized)
+		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->surface);
 
 	xdg_surface_add_listener(window->xdg_surface,
 				 &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 =
 		wl_egl_window_create(window->surface,
 				     window->geometry.width,
@@ -337,7 +389,13 @@ create_surface(struct window *window)
 				       display->egl.conf,
 				       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,
 			     window->egl_surface, window->display->egl.ctx);
@@ -346,7 +404,7 @@ create_surface(struct window *window)
 	if (!window->frame_sync)
 		eglSwapInterval(display->egl.dpy, 0);
 
-	if (window->fullscreen)
+	if (window->maximized)
 		xdg_surface_set_fullscreen(window->xdg_surface, NULL);
 }
 
@@ -443,7 +501,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
 	glDisableVertexAttribArray(window->gl.pos);
 	glDisableVertexAttribArray(window->gl.col);
 
-	if (window->opaque || window->fullscreen) {
+	if (window->opaque || window->maximized) {
 		region = wl_compositor_create_region(window->display->compositor);
 		wl_region_add(region, 0, 0,
 			      window->geometry.width,
@@ -478,7 +536,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
 	struct wl_cursor *cursor = display->default_cursor;
 	struct wl_cursor_image *image;
 
-	if (display->window->fullscreen)
+	if (display->window->maximized)
 		wl_pointer_set_cursor(pointer, serial, NULL, 0, 0);
 	else if (cursor) {
 		image = display->default_cursor->images[0];
@@ -516,8 +574,13 @@ 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 (!display->window->xdg_surface)
+			return;
+
 		xdg_surface_move(display->window->xdg_surface,
-				 display->seat, serial);
+						 display->seat, serial);
+	}
 }
 
 static void
@@ -601,7 +664,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
 	struct display *d = data;
 
 	if (key == KEY_F11 && state) {
-		if (d->window->fullscreen)
+		if (d->window->maximized)
 			xdg_surface_unset_fullscreen(d->window->xdg_surface);
 		else
 			xdg_surface_set_fullscreen(d->window->xdg_surface, NULL);
@@ -710,6 +773,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
 			fprintf(stderr, "unable to load default left pointer\n");
 			// TODO: abort ?
 		}
+	} else if (strcmp(interface, "ivi_application") == 0) {
+		d->ivi_application =
+			wl_registry_bind(registry, name,
+					 &ivi_application_interface, 1);
 	}
 }
 
@@ -734,7 +801,7 @@ static void
 usage(int error_code)
 {
 	fprintf(stderr, "Usage: simple-egl [OPTIONS]\n\n"
-		"  -f\tRun in fullscreen mode\n"
+		"  -f\tRun in maximized mode\n"
 		"  -o\tCreate an opaque surface\n"
 		"  -s\tUse a 16 bpp EGL config\n"
 		"  -b\tDon't sync to compositor redraw (eglSwapInterval 0)\n"
@@ -761,7 +828,7 @@ main(int argc, char **argv)
 
 	for (i = 1; i < argc; i++) {
 		if (strcmp("-f", argv[i]) == 0)
-			window.fullscreen = 1;
+			window.maximized = 1;
 		else if (strcmp("-o", argv[i]) == 0)
 			window.opaque = 1;
 		else if (strcmp("-s", argv[i]) == 0)
@@ -806,6 +873,11 @@ main(int argc, char **argv)
 
 	fprintf(stderr, "simple-egl exiting\n");
 
+	if (window.display->ivi_application) {
+		ivi_surface_destroy(window.ivi_surface);
+		ivi_application_destroy(window.display->ivi_application);
+	}
+
 	destroy_surface(&window);
 	fini_egl(&display);
 
-- 
1.7.9.5