From 31ff5ce755d00cf12ea2ffc96c33ed9acd36358f Mon Sep 17 00:00:00 2001 From: wang_zhiqiang Date: Wed, 21 Nov 2018 16:32:29 +0800 Subject: update doc add new sequence and update doxygen files. Change-Id: I6737939eb2628577d58b2d1d65086e46e7cb14a4 Signed-off-by: wang_zhiqiang --- doc/api-ref/html/de/da4/simple-egl_8cpp.html | 1253 ++++++++++++++++++++ .../html/de/da4/simple-egl_8cpp_source.html | 179 +++ doc/api-ref/html/de/dca/hs-clientmanager_8h.html | 136 +++ .../html/de/dca/hs-clientmanager_8h_source.html | 117 ++ doc/api-ref/html/de/dd0/class_lib_home_screen.html | 595 +++++++--- 5 files changed, 2132 insertions(+), 148 deletions(-) create mode 100644 doc/api-ref/html/de/da4/simple-egl_8cpp.html create mode 100644 doc/api-ref/html/de/da4/simple-egl_8cpp_source.html create mode 100644 doc/api-ref/html/de/dca/hs-clientmanager_8h.html create mode 100644 doc/api-ref/html/de/dca/hs-clientmanager_8h_source.html (limited to 'doc/api-ref/html/de') diff --git a/doc/api-ref/html/de/da4/simple-egl_8cpp.html b/doc/api-ref/html/de/da4/simple-egl_8cpp.html new file mode 100644 index 0000000..30fe5cc --- /dev/null +++ b/doc/api-ref/html/de/da4/simple-egl_8cpp.html @@ -0,0 +1,1253 @@ + + + + + + +HomeScreenBinding: libhomescreen/simple-egl.cpp File Reference + + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
simple-egl.cpp File Reference
+
+
+
#include <mutex>
+#include <chrono>
+#include <iostream>
+#include <string>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <thread>
+#include <exception>
+#include <vector>
+#include <sstream>
+#include <assert.h>
+#include <signal.h>
+#include <wayland-client.h>
+#include <wayland-egl.h>
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <unistd.h>
+#include <time.h>
+#include <libwindowmanager.h>
+#include <libhomescreen.hpp>
+#include <ilm/ivi-application-client-protocol.h>
+#include "hmi-debug.h"
+#include "platform.h"
+
+

Go to the source code of this file.

+ + + + + + + + +

+Classes

struct  display
 
struct  geometry
 
struct  window
 
+ + + + + + + +

+Macros

#define EGL_EXT_swap_buffers_with_damage   1
 
#define EGL_EXT_buffer_age   1
 
#define EGL_BUFFER_AGE_EXT   0x313D
 
+ + + + + + + +

+Typedefs

typedef EGLSurface surface
 
typedef EGLSurface EGLint * rects
 
typedef EGLSurface EGLint EGLint n_rects
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy
 
static void init_egl (struct display *display, struct window *window)
 
static void fini_egl (struct display *display)
 
static GLuint create_shader (struct window *window, const char *source, GLenum shader_type)
 
static void init_gl (struct window *window)
 
static void create_ivi_surface (struct window *window, struct display *display)
 
static void create_surface (struct window *window)
 
static void destroy_surface (struct window *window)
 
static void redraw (void *data, struct wl_callback *callback, uint32_t time)
 
static void registry_handle_global (void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
 
static void registry_handle_global_remove (void *data, struct wl_registry *registry, uint32_t name)
 
static void signal_int (int signum)
 
int init_wm (LibWindowmanager *wm, struct window *window)
 
int init_hs (LibHomeScreen *hs)
 
int main (int argc, char **argv)
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Variables

const char * log_prefix = "simple-egl"
 
uint32_t g_id_ivisurf = 9009
 
long port = 1700
 
string token = string("wm")
 
string app_name = string("Navigation")
 
const char * main_role = "navigation"
 
LibHomeScreenhs
 
LibWindowmanager * wm
 
static const struct wl_interface * types []
 
static const struct wl_message ivi_surface_requests []
 
static const struct wl_message ivi_surface_events []
 
const struct wl_interface ivi_surface_interface
 
static const struct wl_message ivi_application_requests []
 
const struct wl_interface ivi_application_interface
 
static const char * vert_shader_text
 
static const char * frag_shader_text
 
static int running = 1
 
static const struct wl_registry_listener registry_listener
 
+

Macro Definition Documentation

+ +
+
+ + + + +
#define EGL_BUFFER_AGE_EXT   0x313D
+
+ +

Definition at line 110 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
#define EGL_EXT_buffer_age   1
+
+ +

Definition at line 109 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
#define EGL_EXT_swap_buffers_with_damage   1
+
+ +

Definition at line 104 of file simple-egl.cpp.

+ +
+
+

Typedef Documentation

+ +
+
+ + + + +
typedef EGLSurface EGLint EGLint n_rects
+
+ +

Definition at line 105 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
typedef EGLSurface EGLint* rects
+
+ +

Definition at line 105 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
typedef EGLSurface surface
+
+ +

Definition at line 105 of file simple-egl.cpp.

+ +
+
+

Function Documentation

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static void create_ivi_surface (struct windowwindow,
struct displaydisplay 
)
+
+static
+
+ +

Definition at line 322 of file simple-egl.cpp.

+
323 {
324  uint32_t id_ivisurf = g_id_ivisurf;
325  window->ivi_surface =
326  ivi_application_surface_create(display->ivi_application,
327  id_ivisurf, window->surface);
328 
329  if (window->ivi_surface == NULL) {
330  HMI_ERROR(log_prefix,"Failed to create ivi_client_surface");
331  abort();
332  }
333 
334 }
uint32_t g_id_ivisurf
Definition: simple-egl.cpp:59
+
struct wl_surface * surface
Definition: simple-egl.cpp:147
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
struct ivi_surface * ivi_surface
Definition: simple-egl.cpp:148
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static GLuint create_shader (struct windowwindow,
const char * source,
GLenum shader_type 
)
+
+static
+
+ +

Definition at line 259 of file simple-egl.cpp.

+
260 {
261  GLuint shader;
262  GLint status;
263 
264  shader = glCreateShader(shader_type);
265  assert(shader != 0);
266 
267  glShaderSource(shader, 1, (const char **) &source, NULL);
268  glCompileShader(shader);
269 
270  glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
271  if (!status) {
272  char log[1000];
273  GLsizei len;
274  glGetShaderInfoLog(shader, 1000, &len, log);
275  HMI_ERROR(log_prefix,"Error: compiling %s: %*s",
276  shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
277  len, log);
278  exit(1);
279  }
280 
281  return shader;
282 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + +
static void create_surface (struct windowwindow)
+
+static
+
+ +

Definition at line 337 of file simple-egl.cpp.

+
338 {
339  struct display *display = window->display;
340  EGLBoolean ret;
341 
342  window->surface = wl_compositor_create_surface(display->compositor);
343 
344  window->native =
345  wl_egl_window_create(window->surface,
346  window->geometry.width,
347  window->geometry.height);
348  window->egl_surface =
349  weston_platform_create_egl_surface(display->egl.dpy,
350  display->egl.conf,
351  window->native, NULL);
352 
353 
354  if (display->ivi_application ) {
355  create_ivi_surface(window, display);
356  } else {
357  assert(0);
358  }
359 
360  ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
361  window->egl_surface, window->display->egl.ctx);
362  assert(ret == EGL_TRUE);
363 
364  if (!window->frame_sync)
365  eglSwapInterval(display->egl.dpy, 0);
366 
367 }
+
typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy
+
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLSurface egl_surface
Definition: simple-egl.cpp:149
+
EGLConfig conf
Definition: simple-egl.cpp:124
+
struct wl_egl_window * native
Definition: simple-egl.cpp:146
+
struct wl_surface * surface
Definition: simple-egl.cpp:147
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
struct display::@0 egl
+
struct display * display
Definition: simple-egl.cpp:137
+
EGLContext ctx
Definition: simple-egl.cpp:123
+
static void create_ivi_surface(struct window *window, struct display *display)
Definition: simple-egl.cpp:322
+
int frame_sync
Definition: simple-egl.cpp:151
+
struct wl_compositor * compositor
Definition: simple-egl.cpp:119
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + +
static void destroy_surface (struct windowwindow)
+
+static
+
+ +

Definition at line 370 of file simple-egl.cpp.

+
371 {
372  /* Required, otherwise segfault in egl_dri2.c: dri2_make_current()
373  * on eglReleaseThread(). */
374  eglMakeCurrent(window->display->egl.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
375  EGL_NO_CONTEXT);
376 
377  eglDestroySurface(window->display->egl.dpy, window->egl_surface);
378  wl_egl_window_destroy(window->native);
379 
380  if (window->display->ivi_application)
381  ivi_surface_destroy(window->ivi_surface);
382  wl_surface_destroy(window->surface);
383 
384  if (window->callback)
385  wl_callback_destroy(window->callback);
386 }
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLSurface egl_surface
Definition: simple-egl.cpp:149
+
struct wl_egl_window * native
Definition: simple-egl.cpp:146
+
struct wl_surface * surface
Definition: simple-egl.cpp:147
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
struct display::@0 egl
+
struct wl_callback * callback
Definition: simple-egl.cpp:150
+
struct display * display
Definition: simple-egl.cpp:137
+
struct ivi_surface * ivi_surface
Definition: simple-egl.cpp:148
+
+
+
+ +
+
+ + + + + + + + +
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)
+
+ +
+
+ +
+
+ + + + + +
+ + + + + + + + +
static void fini_egl (struct displaydisplay)
+
+static
+
+ +

Definition at line 252 of file simple-egl.cpp.

+
253 {
254  eglTerminate(display->egl.dpy);
255  eglReleaseThread();
256 }
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
struct display::@0 egl
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static void init_egl (struct displaydisplay,
struct windowwindow 
)
+
+static
+
+ +

Definition at line 174 of file simple-egl.cpp.

+
175 {
176  static const EGLint context_attribs[] = {
177  EGL_CONTEXT_CLIENT_VERSION, 2,
178  EGL_NONE
179  };
180  const char *extensions;
181 
182  EGLint config_attribs[] = {
183  EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
184  EGL_RED_SIZE, 1,
185  EGL_GREEN_SIZE, 1,
186  EGL_BLUE_SIZE, 1,
187  EGL_ALPHA_SIZE, 1,
188  EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
189  EGL_NONE
190  };
191 
192  EGLint major, minor, n, count, i, size;
193  EGLConfig *configs;
194  EGLBoolean ret;
195 
196  if (window->opaque || window->buffer_size == 16)
197  config_attribs[9] = 0;
198 
199  display->egl.dpy = weston_platform_get_egl_display(EGL_PLATFORM_WAYLAND_KHR, display->display, NULL);
200  assert(display->egl.dpy);
201 
202  ret = eglInitialize(display->egl.dpy, &major, &minor);
203  assert(ret == EGL_TRUE);
204  ret = eglBindAPI(EGL_OPENGL_ES_API);
205  assert(ret == EGL_TRUE);
206 
207  if (!eglGetConfigs(display->egl.dpy, NULL, 0, &count) || count < 1)
208  assert(0);
209 
210  configs = calloc(count, sizeof *configs);
211  assert(configs);
212 
213  ret = eglChooseConfig(display->egl.dpy, config_attribs,
214  configs, count, &n);
215  assert(ret && n >= 1);
216 
217  for (i = 0; i < n; i++) {
218  eglGetConfigAttrib(display->egl.dpy,
219  configs[i], EGL_BUFFER_SIZE, &size);
220  if (window->buffer_size == size) {
221  display->egl.conf = configs[i];
222  break;
223  }
224  }
225  free(configs);
226  if (display->egl.conf == NULL) {
227  HMI_ERROR(log_prefix,"did not find config with buffer size %d",
228  window->buffer_size);
229  exit(EXIT_FAILURE);
230  }
231 
232  display->egl.ctx = eglCreateContext(display->egl.dpy,
233  display->egl.conf,
234  EGL_NO_CONTEXT, context_attribs);
235  assert(display->egl.ctx);
236 
237  display->swap_buffers_with_damage = NULL;
238  extensions = eglQueryString(display->egl.dpy, EGL_EXTENSIONS);
239  if (extensions &&
240  strstr(extensions, "EGL_EXT_swap_buffers_with_damage") &&
241  strstr(extensions, "EGL_EXT_buffer_age"))
242  display->swap_buffers_with_damage =
243  (PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)
244  eglGetProcAddress("eglSwapBuffersWithDamageEXT");
245 
246  if (display->swap_buffers_with_damage)
247  HMI_DEBUG(log_prefix,"has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage");
248 
249 }
int opaque
Definition: simple-egl.cpp:151
+
typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy
+
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLConfig conf
Definition: simple-egl.cpp:124
+
struct display::@0 egl
+
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage
Definition: simple-egl.cpp:129
+
EGLContext ctx
Definition: simple-egl.cpp:123
+
struct wl_display * display
Definition: simple-egl.cpp:117
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
int buffer_size
Definition: simple-egl.cpp:151
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + +
static void init_gl (struct windowwindow)
+
+static
+
+ +

Definition at line 285 of file simple-egl.cpp.

+
286 {
287  GLuint frag, vert;
288  GLuint program;
289  GLint status;
290 
291  frag = create_shader(window, frag_shader_text, GL_FRAGMENT_SHADER);
292  vert = create_shader(window, vert_shader_text, GL_VERTEX_SHADER);
293 
294  program = glCreateProgram();
295  glAttachShader(program, frag);
296  glAttachShader(program, vert);
297  glLinkProgram(program);
298 
299  glGetProgramiv(program, GL_LINK_STATUS, &status);
300  if (!status) {
301  char log[1000];
302  GLsizei len;
303  glGetProgramInfoLog(program, 1000, &len, log);
304  HMI_ERROR(log_prefix,"Error: linking:%*s", len, log);
305  exit(1);
306  }
307 
308  glUseProgram(program);
309 
310  window->gl.pos = 0;
311  window->gl.col = 1;
312 
313  glBindAttribLocation(program, window->gl.pos, "pos");
314  glBindAttribLocation(program, window->gl.col, "color");
315  glLinkProgram(program);
316 
317  window->gl.rotation_uniform =
318  glGetUniformLocation(program, "rotation");
319 }
GLuint rotation_uniform
Definition: simple-egl.cpp:140
+
struct window::@1 gl
+
static GLuint create_shader(struct window *window, const char *source, GLenum shader_type)
Definition: simple-egl.cpp:259
+
GLuint pos
Definition: simple-egl.cpp:141
+
static const char * frag_shader_text
Definition: simple-egl.cpp:164
+
static const char * vert_shader_text
Definition: simple-egl.cpp:154
+
GLuint col
Definition: simple-egl.cpp:142
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
+
+
+ +
+
+ + + + + + + + +
int init_hs (LibHomeScreenhs)
+
+ +

Definition at line 565 of file simple-egl.cpp.

+
565  {
566  if(hs->init(port, token)!=0)
567  {
568  HMI_ERROR(log_prefix,"homescreen init failed. ");
569  return -1;
570  }
571 
572  hs->set_event_handler(LibHomeScreen::Event_ShowWindow, [hs](json_object *object){
573  HMI_DEBUG("simple-egl","try to activeWindow %s ", app_name.c_str());
574 
575  struct json_object *param_obj = json_object_object_get(object, hs->_keyParameter);
576  const char *area = json_object_get_string(
577  json_object_object_get(param_obj, hs->_keyArea));
578  // Application should call LibWindowmanager::activateWindow() in showWindow handler
579  if(area == nullptr)
580  wm->activateWindow(main_role, hs->_areaNormal);
581  else
582  wm->activateWindow(main_role, area);
583  });
584 
585  return 0;
586 }
LibWindowmanager * wm
Definition: simple-egl.cpp:67
+
const char * main_role
Definition: simple-egl.cpp:64
+
const char * _keyParameter
+
string app_name
Definition: simple-egl.cpp:63
+ +
string token
Definition: simple-egl.cpp:61
+
const char * _keyArea
+
long port
Definition: simple-egl.cpp:60
+
int init(const int port, const std::string &token)
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
const char * _areaNormal
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
void set_event_handler(enum EventType et, handler_func f)
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
int init_wm (LibWindowmanager * wm,
struct windowwindow 
)
+
+ +

Definition at line 527 of file simple-egl.cpp.

+
528 {
529  HMI_DEBUG(log_prefix,"called");
530 
531  if (wm->init(port, token) != 0) {
532  HMI_ERROR(log_prefix,"wm init failed. ");
533  return -1;
534  }
535 
536  g_id_ivisurf = wm->requestSurface(main_role);
537  if (g_id_ivisurf < 0) {
538  HMI_ERROR(log_prefix,"wm request surface failed ");
539  return -1;
540  }
541  HMI_DEBUG(log_prefix,"IVI_SURFACE_ID: %d ", g_id_ivisurf);
542 
543  WMHandler wmh;
544  wmh.on_visible = [](const char* role, bool visible){
545  // Sample code if user uses visible event
546  HMI_DEBUG(log_prefix, "role: %s, visible: %s", role, visible ? "true" : "false");
547  };
548  wmh.on_sync_draw = [wm, window](const char* role, const char* area, Rect rect) {
549 
550  HMI_DEBUG(log_prefix,"Surface %s got syncDraw! Area: %s. w:%d, h:%d", role, area, rect.width(), rect.height());
551 
552  wl_egl_window_resize(window->native, rect.width(), rect.height(), 0, 0);
553  window->geometry.width = rect.width();
554  window->geometry.height = rect.height();
555 
556  wm->endDraw(role);
557  };
558 
559  wm->setEventHandler(wmh);
560 
561  return 0;
562 }
LibWindowmanager * wm
Definition: simple-egl.cpp:67
+
uint32_t g_id_ivisurf
Definition: simple-egl.cpp:59
+
const char * main_role
Definition: simple-egl.cpp:64
+
struct wl_egl_window * native
Definition: simple-egl.cpp:146
+
string token
Definition: simple-egl.cpp:61
+
long port
Definition: simple-egl.cpp:60
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

Definition at line 589 of file simple-egl.cpp.

+
590 {
591  struct sigaction sigint;
592  struct window window = { 0 };
593  struct display display = { 0 };
594 
595  window.display = &display;
596  display.window = &window;
597  window.geometry.width = 1080;
598  window.geometry.height = 1488;
599  window.window_size = window.geometry;
600  window.buffer_size = 32;
601  window.frame_sync = 1;
602 
603  if(argc > 2){
604  port = strtol(argv[1], NULL, 10);
605  token = argv[2];
606  }
607 
608  HMI_DEBUG(log_prefix,"main_role: %s, port: %d, token: %s. ", main_role, port, token.c_str());
609 
610  display.display = wl_display_connect(NULL);
611  assert(display.display);
612 
613  display.registry = wl_display_get_registry(display.display);
614  wl_registry_add_listener(display.registry,
615  &registry_listener, &display);
616 
617  wl_display_roundtrip(display.display);
618 
619  init_egl(&display, &window);
620 
621  wm = new LibWindowmanager();
622  if(init_wm(wm, &window)!=0){
623  fini_egl(&display);
624  if (display.ivi_application)
625  ivi_application_destroy(display.ivi_application);
626  if (display.compositor)
627  wl_compositor_destroy(display.compositor);
628  wl_registry_destroy(display.registry);
629  wl_display_flush(display.display);
630  return -1;
631  }
632 
633  hs = new LibHomeScreen();
634  if(init_hs(hs)!=0){
635  fini_egl(&display);
636  if (display.ivi_application)
637  ivi_application_destroy(display.ivi_application);
638  if (display.compositor)
639  wl_compositor_destroy(display.compositor);
640  wl_registry_destroy(display.registry);
641  wl_display_flush(display.display);
642  return -1;
643  }
644 
645  create_surface(&window);
646  init_gl(&window);
647 
648  //Ctrl+C
649  sigint.sa_handler = signal_int;
650  sigemptyset(&sigint.sa_mask);
651  sigint.sa_flags = SA_RESETHAND;
652  sigaction(SIGINT, &sigint, NULL);
653 
654  eglSwapBuffers(window.display->egl.dpy, window.egl_surface);
655 
656  wm->activateWindow(main_role);
657 
658  /* The mainloop here is a little subtle. Redrawing will cause
659  * EGL to read events so we can just call
660  * wl_display_dispatch_pending() to handle any events that got
661  * queued up as a side effect. */
662  while (running) {
663  wl_display_dispatch_pending(display.display);
664  redraw(&window, NULL, 0);
665  }
666 
667  HMI_DEBUG(log_prefix,"simple-egl exiting! ");
668 
669  destroy_surface(&window);
670  fini_egl(&display);
671 
672  if (display.ivi_application)
673  ivi_application_destroy(display.ivi_application);
674 
675  if (display.compositor)
676  wl_compositor_destroy(display.compositor);
677 
678  wl_registry_destroy(display.registry);
679  wl_display_flush(display.display);
680  wl_display_disconnect(display.display);
681 
682  return 0;
683 }
struct window * window
Definition: simple-egl.cpp:126
+ +
LibWindowmanager * wm
Definition: simple-egl.cpp:67
+
static void init_gl(struct window *window)
Definition: simple-egl.cpp:285
+
int init_wm(LibWindowmanager *wm, struct window *window)
Definition: simple-egl.cpp:527
+
const char * main_role
Definition: simple-egl.cpp:64
+
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLSurface egl_surface
Definition: simple-egl.cpp:149
+
static void signal_int(int signum)
Definition: simple-egl.cpp:521
+
static void create_surface(struct window *window)
Definition: simple-egl.cpp:337
+
static void redraw(void *data, struct wl_callback *callback, uint32_t time)
Definition: simple-egl.cpp:389
+
string token
Definition: simple-egl.cpp:61
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
LibHomeScreen * hs
Definition: simple-egl.cpp:66
+
struct display::@0 egl
+
struct wl_registry * registry
Definition: simple-egl.cpp:118
+
static int running
Definition: simple-egl.cpp:171
+
struct display * display
Definition: simple-egl.cpp:137
+ +
long port
Definition: simple-egl.cpp:60
+
static const struct wl_registry_listener registry_listener
Definition: simple-egl.cpp:515
+
struct geometry geometry window_size
Definition: simple-egl.cpp:138
+
int frame_sync
Definition: simple-egl.cpp:151
+
struct wl_display * display
Definition: simple-egl.cpp:117
+
static void fini_egl(struct display *display)
Definition: simple-egl.cpp:252
+
static void init_egl(struct display *display, struct window *window)
Definition: simple-egl.cpp:174
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
struct wl_compositor * compositor
Definition: simple-egl.cpp:119
+
int buffer_size
Definition: simple-egl.cpp:151
+
const char * log_prefix
Definition: simple-egl.cpp:58
+ +
static void destroy_surface(struct window *window)
Definition: simple-egl.cpp:370
+
int init_hs(LibHomeScreen *hs)
Definition: simple-egl.cpp:565
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static void redraw (void * data,
struct wl_callback * callback,
uint32_t time 
)
+
+static
+
+ +

Definition at line 389 of file simple-egl.cpp.

+
390 {
391  struct window *window = data;
392  struct display *display = window->display;
393  static const GLfloat verts[3][2] = {
394  { -0.5, -0.5 },
395  { 0.5, -0.5 },
396  { 0, 0.5 }
397  };
398 
399  static const GLfloat colors[3][3] = {
400  { 1, 0, 0 },
401  { 0, 1, 0 },
402  { 0, 0, 1 }
403  };
404 
405  GLfloat angle;
406  GLfloat rotation[4][4] = {
407  { 1, 0, 0, 0 },
408  { 0, 1, 0, 0 },
409  { 0, 0, 1, 0 },
410  { 0, 0, 0, 1 }
411  };
412  static const uint32_t speed_div = 5, benchmark_interval = 5;
413  struct wl_region *region;
414  EGLint rect[4];
415  EGLint buffer_age = 0;
416  struct timeval tv;
417 
418  assert(window->callback == callback);
419  window->callback = NULL;
420 
421  if (callback)
422  wl_callback_destroy(callback);
423 
424  gettimeofday(&tv, NULL);
425  time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
426  if (window->frames == 0)
427  window->benchmark_time = time;
428 
429  if (time - window->benchmark_time > (benchmark_interval * 1000)) {
430  HMI_DEBUG(log_prefix,"%d frames in %d seconds: %f fps",
431  window->frames,
432  benchmark_interval,
433  (float) window->frames / benchmark_interval);
434  window->benchmark_time = time;
435  window->frames = 0;
436  }
437 
438  angle = (time / speed_div) % 360 * M_PI / 180.0;
439  rotation[0][0] = cos(angle);
440  rotation[0][2] = sin(angle);
441  rotation[2][0] = -sin(angle);
442  rotation[2][2] = cos(angle);
443 
444  if (display->swap_buffers_with_damage)
445  eglQuerySurface(display->egl.dpy, window->egl_surface,
446  EGL_BUFFER_AGE_EXT, &buffer_age);
447 
448  glViewport(0, 0, window->geometry.width, window->geometry.height);
449 
450  glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
451  (GLfloat *) rotation);
452 
453  glClearColor(0.0, 0.0, 0.0, 0.5);
454  glClear(GL_COLOR_BUFFER_BIT);
455 
456  glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
457  glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
458  glEnableVertexAttribArray(window->gl.pos);
459  glEnableVertexAttribArray(window->gl.col);
460 
461  glDrawArrays(GL_TRIANGLES, 0, 3);
462 
463  glDisableVertexAttribArray(window->gl.pos);
464  glDisableVertexAttribArray(window->gl.col);
465 
466  if (window->opaque || window->fullscreen) {
467  region = wl_compositor_create_region(window->display->compositor);
468  wl_region_add(region, 0, 0,
469  window->geometry.width,
470  window->geometry.height);
471  wl_surface_set_opaque_region(window->surface, region);
472  wl_region_destroy(region);
473  } else {
474  wl_surface_set_opaque_region(window->surface, NULL);
475  }
476 
477  if (display->swap_buffers_with_damage && buffer_age > 0) {
478  rect[0] = window->geometry.width / 4 - 1;
479  rect[1] = window->geometry.height / 4 - 1;
480  rect[2] = window->geometry.width / 2 + 2;
481  rect[3] = window->geometry.height / 2 + 2;
482  display->swap_buffers_with_damage(display->egl.dpy,
483  window->egl_surface,
484  rect, 1);
485  } else {
486  eglSwapBuffers(display->egl.dpy, window->egl_surface);
487  }
488 
489  window->frames++;
490 }
+
GLuint rotation_uniform
Definition: simple-egl.cpp:140
+
struct window::@1 gl
+
uint32_t benchmark_time
Definition: simple-egl.cpp:145
+
int opaque
Definition: simple-egl.cpp:151
+
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLSurface egl_surface
Definition: simple-egl.cpp:149
+
GLuint pos
Definition: simple-egl.cpp:141
+
#define EGL_BUFFER_AGE_EXT
Definition: simple-egl.cpp:110
+
struct wl_surface * surface
Definition: simple-egl.cpp:147
+
struct display::@0 egl
+
GLuint col
Definition: simple-egl.cpp:142
+
struct wl_callback * callback
Definition: simple-egl.cpp:150
+
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage
Definition: simple-egl.cpp:129
+
struct display * display
Definition: simple-egl.cpp:137
+ +
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
struct wl_compositor * compositor
Definition: simple-egl.cpp:119
+
const char * log_prefix
Definition: simple-egl.cpp:58
+
int fullscreen
Definition: simple-egl.cpp:151
+
uint32_t frames
Definition: simple-egl.cpp:145
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
static void registry_handle_global (void * data,
struct wl_registry * registry,
uint32_t name,
const char * interface,
uint32_t version 
)
+
+static
+
+ +

Definition at line 493 of file simple-egl.cpp.

+
495 {
496  struct display *d = data;
497 
498  if (strcmp(interface, "wl_compositor") == 0) {
499  d->compositor =
500  wl_registry_bind(registry, name,
501  &wl_compositor_interface, 1);
502  } else if (strcmp(interface, "ivi_application") == 0) {
503  d->ivi_application =
504  wl_registry_bind(registry, name,
506  }
507 }
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
const struct wl_interface ivi_application_interface
Definition: simple-egl.cpp:95
+
struct wl_registry * registry
Definition: simple-egl.cpp:118
+
struct wl_compositor * compositor
Definition: simple-egl.cpp:119
+
+
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static void registry_handle_global_remove (void * data,
struct wl_registry * registry,
uint32_t name 
)
+
+static
+
+ +

Definition at line 510 of file simple-egl.cpp.

+
512 {
513 }
+
+
+ +
+
+ + + + + +
+ + + + + + + + +
static void signal_int (int signum)
+
+static
+
+ +

Definition at line 521 of file simple-egl.cpp.

+
522 {
523  running = 0;
524 }
static int running
Definition: simple-egl.cpp:171
+
+
+
+

Variable Documentation

+ +
+
+ + + + +
string app_name = string("Navigation")
+
+ +

Definition at line 63 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const char* frag_shader_text
+
+static
+
+Initial value:
=
"precision mediump float;\n"
"varying vec4 v_color;\n"
"void main() {\n"
" gl_FragColor = v_color;\n"
"}\n"
+

Definition at line 164 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
uint32_t g_id_ivisurf = 9009
+
+ +

Definition at line 59 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
LibHomeScreen* hs
+
+ +

Definition at line 66 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
const struct wl_interface ivi_application_interface
+
+Initial value:
= {
"ivi_application", 1,
0, NULL,
}
static const struct wl_message ivi_application_requests[]
Definition: simple-egl.cpp:91
+
+

Definition at line 95 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const struct wl_message ivi_application_requests[]
+
+static
+
+Initial value:
= {
{ "surface_create", "uon", types + 2 },
}
static const struct wl_interface * types[]
Definition: simple-egl.cpp:69
+
+

Definition at line 91 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const struct wl_message ivi_surface_events[]
+
+static
+
+Initial value:
= {
{ "configure", "ii", types + 0 },
}
static const struct wl_interface * types[]
Definition: simple-egl.cpp:69
+
+

Definition at line 81 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
const struct wl_interface ivi_surface_interface
+
+Initial value:
= {
"ivi_surface", 1,
}
static const struct wl_message ivi_surface_events[]
Definition: simple-egl.cpp:81
+
static const struct wl_message ivi_surface_requests[]
Definition: simple-egl.cpp:77
+
+

Definition at line 85 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const struct wl_message ivi_surface_requests[]
+
+static
+
+Initial value:
= {
{ "destroy", "", types + 0 },
}
static const struct wl_interface * types[]
Definition: simple-egl.cpp:69
+
+

Definition at line 77 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
const char* log_prefix = "simple-egl"
+
+ +

Definition at line 58 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
const char* main_role = "navigation"
+
+ +

Definition at line 64 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
long port = 1700
+
+ +

Definition at line 60 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const struct wl_registry_listener registry_listener
+
+static
+
+Initial value:
= {
}
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
Definition: simple-egl.cpp:493
+
static void registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
Definition: simple-egl.cpp:510
+
+

Definition at line 515 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
int running = 1
+
+static
+
+ +

Definition at line 171 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
string token = string("wm")
+
+ +

Definition at line 61 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const struct wl_interface* types[]
+
+static
+
+Initial value:
= {
NULL,
NULL,
NULL,
&wl_surface_interface,
}
const struct wl_interface ivi_surface_interface
Definition: simple-egl.cpp:85
+
+

Definition at line 69 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + +
const char* vert_shader_text
+
+static
+
+Initial value:
=
"uniform mat4 rotation;\n"
"attribute vec4 pos;\n"
"attribute vec4 color;\n"
"varying vec4 v_color;\n"
"void main() {\n"
" gl_Position = rotation * pos;\n"
" v_color = color;\n"
"}\n"
+

Definition at line 154 of file simple-egl.cpp.

+ +
+
+ +
+
+ + + + +
LibWindowmanager* wm
+
+ +

Definition at line 67 of file simple-egl.cpp.

+ +
+
+
+ + + + diff --git a/doc/api-ref/html/de/da4/simple-egl_8cpp_source.html b/doc/api-ref/html/de/da4/simple-egl_8cpp_source.html new file mode 100644 index 0000000..f87e538 --- /dev/null +++ b/doc/api-ref/html/de/da4/simple-egl_8cpp_source.html @@ -0,0 +1,179 @@ + + + + + + +HomeScreenBinding: libhomescreen/simple-egl.cpp Source File + + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
simple-egl.cpp
+
+
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  * Copyright © 2011 Benjamin Franzke
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #include <mutex>
26 #include <chrono>
27 
28 #include <iostream>
29 #include <string>
30 #include <stdarg.h>
31 #include <sys/types.h>
32 #include <thread>
33 #include <exception>
34 #include <vector>
35 #include <sstream>
36 
37 #include <assert.h>
38 #include <signal.h>
39 
40 #include <wayland-client.h>
41 #include <wayland-egl.h>
42 
43 #include <GLES2/gl2.h>
44 #include <EGL/egl.h>
45 #include <EGL/eglext.h>
46 
47 #include <unistd.h>
48 #include <time.h>
49 
50 #include <libwindowmanager.h>
51 #include <libhomescreen.hpp>
52 
53 #include <ilm/ivi-application-client-protocol.h>
54 #include "hmi-debug.h"
55 
56 using namespace std;
57 
58 const char* log_prefix = "simple-egl";
59 uint32_t g_id_ivisurf = 9009;
60 long port = 1700;
61 string token = string("wm");
62 
63 string app_name = string("Navigation");
64 const char* main_role = "navigation";
65 
67 LibWindowmanager *wm;
68 
69 static const struct wl_interface *types[] = {
70  NULL,
71  NULL,
72  NULL,
73  &wl_surface_interface,
75 };
76 
77 static const struct wl_message ivi_surface_requests[] = {
78  { "destroy", "", types + 0 },
79 };
80 
81 static const struct wl_message ivi_surface_events[] = {
82  { "configure", "ii", types + 0 },
83 };
84 
85 const struct wl_interface ivi_surface_interface = {
86  "ivi_surface", 1,
89 };
90 
91 static const struct wl_message ivi_application_requests[] = {
92  { "surface_create", "uon", types + 2 },
93 };
94 
95 const struct wl_interface ivi_application_interface = {
96  "ivi_application", 1,
98  0, NULL,
99 };
100 
101 #include "platform.h"
102 
103 #ifndef EGL_EXT_swap_buffers_with_damage
104 #define EGL_EXT_swap_buffers_with_damage 1
105 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
106 #endif
107 
108 #ifndef EGL_EXT_buffer_age
109 #define EGL_EXT_buffer_age 1
110 #define EGL_BUFFER_AGE_EXT 0x313D
111 #endif
112 
113 struct window;
114 struct seat;
115 
116 struct display {
117  struct wl_display *display;
118  struct wl_registry *registry;
119  struct wl_compositor *compositor;
120  struct wl_seat *seat;
121  struct {
122  EGLDisplay dpy;
123  EGLContext ctx;
124  EGLConfig conf;
125  } egl;
126  struct window *window;
127  struct ivi_application *ivi_application;
128 
129  PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
130 };
131 
132 struct geometry {
133  int width, height;
134 };
135 
136 struct window {
137  struct display *display;
138  struct geometry geometry, window_size;
139  struct {
141  GLuint pos;
142  GLuint col;
143  } gl;
144 
145  uint32_t benchmark_time, frames;
146  struct wl_egl_window *native;
147  struct wl_surface *surface;
148  struct ivi_surface *ivi_surface;
149  EGLSurface egl_surface;
150  struct wl_callback *callback;
151  int fullscreen, opaque, buffer_size, frame_sync;
152 };
153 
154 static const char *vert_shader_text =
155  "uniform mat4 rotation;\n"
156  "attribute vec4 pos;\n"
157  "attribute vec4 color;\n"
158  "varying vec4 v_color;\n"
159  "void main() {\n"
160  " gl_Position = rotation * pos;\n"
161  " v_color = color;\n"
162  "}\n";
163 
164 static const char *frag_shader_text =
165  "precision mediump float;\n"
166  "varying vec4 v_color;\n"
167  "void main() {\n"
168  " gl_FragColor = v_color;\n"
169  "}\n";
170 
171 static int running = 1;
172 
173 static void
175 {
176  static const EGLint context_attribs[] = {
177  EGL_CONTEXT_CLIENT_VERSION, 2,
178  EGL_NONE
179  };
180  const char *extensions;
181 
182  EGLint config_attribs[] = {
183  EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
184  EGL_RED_SIZE, 1,
185  EGL_GREEN_SIZE, 1,
186  EGL_BLUE_SIZE, 1,
187  EGL_ALPHA_SIZE, 1,
188  EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
189  EGL_NONE
190  };
191 
192  EGLint major, minor, n, count, i, size;
193  EGLConfig *configs;
194  EGLBoolean ret;
195 
196  if (window->opaque || window->buffer_size == 16)
197  config_attribs[9] = 0;
198 
199  display->egl.dpy = weston_platform_get_egl_display(EGL_PLATFORM_WAYLAND_KHR, display->display, NULL);
200  assert(display->egl.dpy);
201 
202  ret = eglInitialize(display->egl.dpy, &major, &minor);
203  assert(ret == EGL_TRUE);
204  ret = eglBindAPI(EGL_OPENGL_ES_API);
205  assert(ret == EGL_TRUE);
206 
207  if (!eglGetConfigs(display->egl.dpy, NULL, 0, &count) || count < 1)
208  assert(0);
209 
210  configs = calloc(count, sizeof *configs);
211  assert(configs);
212 
213  ret = eglChooseConfig(display->egl.dpy, config_attribs,
214  configs, count, &n);
215  assert(ret && n >= 1);
216 
217  for (i = 0; i < n; i++) {
218  eglGetConfigAttrib(display->egl.dpy,
219  configs[i], EGL_BUFFER_SIZE, &size);
220  if (window->buffer_size == size) {
221  display->egl.conf = configs[i];
222  break;
223  }
224  }
225  free(configs);
226  if (display->egl.conf == NULL) {
227  HMI_ERROR(log_prefix,"did not find config with buffer size %d",
228  window->buffer_size);
229  exit(EXIT_FAILURE);
230  }
231 
232  display->egl.ctx = eglCreateContext(display->egl.dpy,
233  display->egl.conf,
234  EGL_NO_CONTEXT, context_attribs);
235  assert(display->egl.ctx);
236 
237  display->swap_buffers_with_damage = NULL;
238  extensions = eglQueryString(display->egl.dpy, EGL_EXTENSIONS);
239  if (extensions &&
240  strstr(extensions, "EGL_EXT_swap_buffers_with_damage") &&
241  strstr(extensions, "EGL_EXT_buffer_age"))
242  display->swap_buffers_with_damage =
243  (PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)
244  eglGetProcAddress("eglSwapBuffersWithDamageEXT");
245 
246  if (display->swap_buffers_with_damage)
247  HMI_DEBUG(log_prefix,"has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage");
248 
249 }
250 
251 static void
253 {
254  eglTerminate(display->egl.dpy);
255  eglReleaseThread();
256 }
257 
258 static GLuint
259 create_shader(struct window *window, const char *source, GLenum shader_type)
260 {
261  GLuint shader;
262  GLint status;
263 
264  shader = glCreateShader(shader_type);
265  assert(shader != 0);
266 
267  glShaderSource(shader, 1, (const char **) &source, NULL);
268  glCompileShader(shader);
269 
270  glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
271  if (!status) {
272  char log[1000];
273  GLsizei len;
274  glGetShaderInfoLog(shader, 1000, &len, log);
275  HMI_ERROR(log_prefix,"Error: compiling %s: %*s",
276  shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
277  len, log);
278  exit(1);
279  }
280 
281  return shader;
282 }
283 
284 static void
286 {
287  GLuint frag, vert;
288  GLuint program;
289  GLint status;
290 
291  frag = create_shader(window, frag_shader_text, GL_FRAGMENT_SHADER);
292  vert = create_shader(window, vert_shader_text, GL_VERTEX_SHADER);
293 
294  program = glCreateProgram();
295  glAttachShader(program, frag);
296  glAttachShader(program, vert);
297  glLinkProgram(program);
298 
299  glGetProgramiv(program, GL_LINK_STATUS, &status);
300  if (!status) {
301  char log[1000];
302  GLsizei len;
303  glGetProgramInfoLog(program, 1000, &len, log);
304  HMI_ERROR(log_prefix,"Error: linking:%*s", len, log);
305  exit(1);
306  }
307 
308  glUseProgram(program);
309 
310  window->gl.pos = 0;
311  window->gl.col = 1;
312 
313  glBindAttribLocation(program, window->gl.pos, "pos");
314  glBindAttribLocation(program, window->gl.col, "color");
315  glLinkProgram(program);
316 
317  window->gl.rotation_uniform =
318  glGetUniformLocation(program, "rotation");
319 }
320 
321 static void
323 {
324  uint32_t id_ivisurf = g_id_ivisurf;
325  window->ivi_surface =
326  ivi_application_surface_create(display->ivi_application,
327  id_ivisurf, window->surface);
328 
329  if (window->ivi_surface == NULL) {
330  HMI_ERROR(log_prefix,"Failed to create ivi_client_surface");
331  abort();
332  }
333 
334 }
335 
336 static void
338 {
339  struct display *display = window->display;
340  EGLBoolean ret;
341 
342  window->surface = wl_compositor_create_surface(display->compositor);
343 
344  window->native =
345  wl_egl_window_create(window->surface,
346  window->geometry.width,
347  window->geometry.height);
348  window->egl_surface =
349  weston_platform_create_egl_surface(display->egl.dpy,
350  display->egl.conf,
351  window->native, NULL);
352 
353 
354  if (display->ivi_application ) {
355  create_ivi_surface(window, display);
356  } else {
357  assert(0);
358  }
359 
360  ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
361  window->egl_surface, window->display->egl.ctx);
362  assert(ret == EGL_TRUE);
363 
364  if (!window->frame_sync)
365  eglSwapInterval(display->egl.dpy, 0);
366 
367 }
368 
369 static void
371 {
372  /* Required, otherwise segfault in egl_dri2.c: dri2_make_current()
373  * on eglReleaseThread(). */
374  eglMakeCurrent(window->display->egl.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
375  EGL_NO_CONTEXT);
376 
377  eglDestroySurface(window->display->egl.dpy, window->egl_surface);
378  wl_egl_window_destroy(window->native);
379 
380  if (window->display->ivi_application)
381  ivi_surface_destroy(window->ivi_surface);
382  wl_surface_destroy(window->surface);
383 
384  if (window->callback)
385  wl_callback_destroy(window->callback);
386 }
387 
388 static void
389 redraw(void *data, struct wl_callback *callback, uint32_t time)
390 {
391  struct window *window = data;
392  struct display *display = window->display;
393  static const GLfloat verts[3][2] = {
394  { -0.5, -0.5 },
395  { 0.5, -0.5 },
396  { 0, 0.5 }
397  };
398 
399  static const GLfloat colors[3][3] = {
400  { 1, 0, 0 },
401  { 0, 1, 0 },
402  { 0, 0, 1 }
403  };
404 
405  GLfloat angle;
406  GLfloat rotation[4][4] = {
407  { 1, 0, 0, 0 },
408  { 0, 1, 0, 0 },
409  { 0, 0, 1, 0 },
410  { 0, 0, 0, 1 }
411  };
412  static const uint32_t speed_div = 5, benchmark_interval = 5;
413  struct wl_region *region;
414  EGLint rect[4];
415  EGLint buffer_age = 0;
416  struct timeval tv;
417 
418  assert(window->callback == callback);
419  window->callback = NULL;
420 
421  if (callback)
422  wl_callback_destroy(callback);
423 
424  gettimeofday(&tv, NULL);
425  time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
426  if (window->frames == 0)
427  window->benchmark_time = time;
428 
429  if (time - window->benchmark_time > (benchmark_interval * 1000)) {
430  HMI_DEBUG(log_prefix,"%d frames in %d seconds: %f fps",
431  window->frames,
432  benchmark_interval,
433  (float) window->frames / benchmark_interval);
434  window->benchmark_time = time;
435  window->frames = 0;
436  }
437 
438  angle = (time / speed_div) % 360 * M_PI / 180.0;
439  rotation[0][0] = cos(angle);
440  rotation[0][2] = sin(angle);
441  rotation[2][0] = -sin(angle);
442  rotation[2][2] = cos(angle);
443 
444  if (display->swap_buffers_with_damage)
445  eglQuerySurface(display->egl.dpy, window->egl_surface,
446  EGL_BUFFER_AGE_EXT, &buffer_age);
447 
448  glViewport(0, 0, window->geometry.width, window->geometry.height);
449 
450  glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
451  (GLfloat *) rotation);
452 
453  glClearColor(0.0, 0.0, 0.0, 0.5);
454  glClear(GL_COLOR_BUFFER_BIT);
455 
456  glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
457  glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
458  glEnableVertexAttribArray(window->gl.pos);
459  glEnableVertexAttribArray(window->gl.col);
460 
461  glDrawArrays(GL_TRIANGLES, 0, 3);
462 
463  glDisableVertexAttribArray(window->gl.pos);
464  glDisableVertexAttribArray(window->gl.col);
465 
466  if (window->opaque || window->fullscreen) {
467  region = wl_compositor_create_region(window->display->compositor);
468  wl_region_add(region, 0, 0,
469  window->geometry.width,
470  window->geometry.height);
471  wl_surface_set_opaque_region(window->surface, region);
472  wl_region_destroy(region);
473  } else {
474  wl_surface_set_opaque_region(window->surface, NULL);
475  }
476 
477  if (display->swap_buffers_with_damage && buffer_age > 0) {
478  rect[0] = window->geometry.width / 4 - 1;
479  rect[1] = window->geometry.height / 4 - 1;
480  rect[2] = window->geometry.width / 2 + 2;
481  rect[3] = window->geometry.height / 2 + 2;
482  display->swap_buffers_with_damage(display->egl.dpy,
483  window->egl_surface,
484  rect, 1);
485  } else {
486  eglSwapBuffers(display->egl.dpy, window->egl_surface);
487  }
488 
489  window->frames++;
490 }
491 
492 static void
493 registry_handle_global(void *data, struct wl_registry *registry,
494  uint32_t name, const char *interface, uint32_t version)
495 {
496  struct display *d = data;
497 
498  if (strcmp(interface, "wl_compositor") == 0) {
499  d->compositor =
500  wl_registry_bind(registry, name,
501  &wl_compositor_interface, 1);
502  } else if (strcmp(interface, "ivi_application") == 0) {
503  d->ivi_application =
504  wl_registry_bind(registry, name,
506  }
507 }
508 
509 static void
510 registry_handle_global_remove(void *data, struct wl_registry *registry,
511  uint32_t name)
512 {
513 }
514 
515 static const struct wl_registry_listener registry_listener = {
518 };
519 
520 static void
521 signal_int(int signum)
522 {
523  running = 0;
524 }
525 
526 int
527 init_wm(LibWindowmanager *wm, struct window *window)
528 {
529  HMI_DEBUG(log_prefix,"called");
530 
531  if (wm->init(port, token) != 0) {
532  HMI_ERROR(log_prefix,"wm init failed. ");
533  return -1;
534  }
535 
536  g_id_ivisurf = wm->requestSurface(main_role);
537  if (g_id_ivisurf < 0) {
538  HMI_ERROR(log_prefix,"wm request surface failed ");
539  return -1;
540  }
541  HMI_DEBUG(log_prefix,"IVI_SURFACE_ID: %d ", g_id_ivisurf);
542 
543  WMHandler wmh;
544  wmh.on_visible = [](const char* role, bool visible){
545  // Sample code if user uses visible event
546  HMI_DEBUG(log_prefix, "role: %s, visible: %s", role, visible ? "true" : "false");
547  };
548  wmh.on_sync_draw = [wm, window](const char* role, const char* area, Rect rect) {
549 
550  HMI_DEBUG(log_prefix,"Surface %s got syncDraw! Area: %s. w:%d, h:%d", role, area, rect.width(), rect.height());
551 
552  wl_egl_window_resize(window->native, rect.width(), rect.height(), 0, 0);
553  window->geometry.width = rect.width();
554  window->geometry.height = rect.height();
555 
556  wm->endDraw(role);
557  };
558 
559  wm->setEventHandler(wmh);
560 
561  return 0;
562 }
563 
564 int
566  if(hs->init(port, token)!=0)
567  {
568  HMI_ERROR(log_prefix,"homescreen init failed. ");
569  return -1;
570  }
571 
572  hs->set_event_handler(LibHomeScreen::Event_ShowWindow, [hs](json_object *object){
573  HMI_DEBUG("simple-egl","try to activeWindow %s ", app_name.c_str());
574 
575  struct json_object *param_obj = json_object_object_get(object, hs->_keyParameter);
576  const char *area = json_object_get_string(
577  json_object_object_get(param_obj, hs->_keyArea));
578  // Application should call LibWindowmanager::activateWindow() in showWindow handler
579  if(area == nullptr)
580  wm->activateWindow(main_role, hs->_areaNormal);
581  else
582  wm->activateWindow(main_role, area);
583  });
584 
585  return 0;
586 }
587 
588 int
589 main(int argc, char **argv)
590 {
591  struct sigaction sigint;
592  struct window window = { 0 };
593  struct display display = { 0 };
594 
595  window.display = &display;
596  display.window = &window;
597  window.geometry.width = 1080;
598  window.geometry.height = 1488;
599  window.window_size = window.geometry;
600  window.buffer_size = 32;
601  window.frame_sync = 1;
602 
603  if(argc > 2){
604  port = strtol(argv[1], NULL, 10);
605  token = argv[2];
606  }
607 
608  HMI_DEBUG(log_prefix,"main_role: %s, port: %d, token: %s. ", main_role, port, token.c_str());
609 
610  display.display = wl_display_connect(NULL);
611  assert(display.display);
612 
613  display.registry = wl_display_get_registry(display.display);
614  wl_registry_add_listener(display.registry,
615  &registry_listener, &display);
616 
617  wl_display_roundtrip(display.display);
618 
619  init_egl(&display, &window);
620 
621  wm = new LibWindowmanager();
622  if(init_wm(wm, &window)!=0){
623  fini_egl(&display);
624  if (display.ivi_application)
625  ivi_application_destroy(display.ivi_application);
626  if (display.compositor)
627  wl_compositor_destroy(display.compositor);
628  wl_registry_destroy(display.registry);
629  wl_display_flush(display.display);
630  return -1;
631  }
632 
633  hs = new LibHomeScreen();
634  if(init_hs(hs)!=0){
635  fini_egl(&display);
636  if (display.ivi_application)
637  ivi_application_destroy(display.ivi_application);
638  if (display.compositor)
639  wl_compositor_destroy(display.compositor);
640  wl_registry_destroy(display.registry);
641  wl_display_flush(display.display);
642  return -1;
643  }
644 
645  create_surface(&window);
646  init_gl(&window);
647 
648  //Ctrl+C
649  sigint.sa_handler = signal_int;
650  sigemptyset(&sigint.sa_mask);
651  sigint.sa_flags = SA_RESETHAND;
652  sigaction(SIGINT, &sigint, NULL);
653 
654  eglSwapBuffers(window.display->egl.dpy, window.egl_surface);
655 
656  wm->activateWindow(main_role);
657 
658  /* The mainloop here is a little subtle. Redrawing will cause
659  * EGL to read events so we can just call
660  * wl_display_dispatch_pending() to handle any events that got
661  * queued up as a side effect. */
662  while (running) {
663  wl_display_dispatch_pending(display.display);
664  redraw(&window, NULL, 0);
665  }
666 
667  HMI_DEBUG(log_prefix,"simple-egl exiting! ");
668 
669  destroy_surface(&window);
670  fini_egl(&display);
671 
672  if (display.ivi_application)
673  ivi_application_destroy(display.ivi_application);
674 
675  if (display.compositor)
676  wl_compositor_destroy(display.compositor);
677 
678  wl_registry_destroy(display.registry);
679  wl_display_flush(display.display);
680  wl_display_disconnect(display.display);
681 
682  return 0;
683 }
static const struct wl_message ivi_surface_events[]
Definition: simple-egl.cpp:81
+
struct window * window
Definition: simple-egl.cpp:126
+ +
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
Definition: simple-egl.cpp:493
+
GLuint rotation_uniform
Definition: simple-egl.cpp:140
+
LibWindowmanager * wm
Definition: simple-egl.cpp:67
+
struct wl_seat * seat
Definition: simple-egl.cpp:120
+
static void init_gl(struct window *window)
Definition: simple-egl.cpp:285
+
uint32_t g_id_ivisurf
Definition: simple-egl.cpp:59
+
int init_wm(LibWindowmanager *wm, struct window *window)
Definition: simple-egl.cpp:527
+
EGLSurface surface
Definition: simple-egl.cpp:105
+
struct window::@1 gl
+
const struct wl_interface ivi_surface_interface
Definition: simple-egl.cpp:85
+
const char * main_role
Definition: simple-egl.cpp:64
+
uint32_t benchmark_time
Definition: simple-egl.cpp:145
+ +
int opaque
Definition: simple-egl.cpp:151
+
typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy
+
EGLSurface EGLint * rects
Definition: simple-egl.cpp:105
+ +
static const struct wl_interface * types[]
Definition: simple-egl.cpp:69
+
static const struct wl_message ivi_application_requests[]
Definition: simple-egl.cpp:91
+
const char * _keyParameter
+
EGLDisplay dpy
Definition: simple-egl.cpp:122
+
EGLSurface egl_surface
Definition: simple-egl.cpp:149
+
string app_name
Definition: simple-egl.cpp:63
+
static GLuint create_shader(struct window *window, const char *source, GLenum shader_type)
Definition: simple-egl.cpp:259
+
GLuint pos
Definition: simple-egl.cpp:141
+
#define EGL_BUFFER_AGE_EXT
Definition: simple-egl.cpp:110
+
static void signal_int(int signum)
Definition: simple-egl.cpp:521
+
static const char * frag_shader_text
Definition: simple-egl.cpp:164
+
static void create_surface(struct window *window)
Definition: simple-egl.cpp:337
+
static void redraw(void *data, struct wl_callback *callback, uint32_t time)
Definition: simple-egl.cpp:389
+
EGLConfig conf
Definition: simple-egl.cpp:124
+ +
struct wl_egl_window * native
Definition: simple-egl.cpp:146
+
EGLSurface EGLint EGLint n_rects
Definition: simple-egl.cpp:105
+
string token
Definition: simple-egl.cpp:61
+
struct wl_surface * surface
Definition: simple-egl.cpp:147
+
static const char * vert_shader_text
Definition: simple-egl.cpp:154
+
struct ivi_application * ivi_application
Definition: simple-egl.cpp:127
+
LibHomeScreen * hs
Definition: simple-egl.cpp:66
+
struct display::@0 egl
+
GLuint col
Definition: simple-egl.cpp:142
+
struct wl_callback * callback
Definition: simple-egl.cpp:150
+
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage
Definition: simple-egl.cpp:129
+
const struct wl_interface ivi_application_interface
Definition: simple-egl.cpp:95
+
struct wl_registry * registry
Definition: simple-egl.cpp:118
+
static int running
Definition: simple-egl.cpp:171
+
struct display * display
Definition: simple-egl.cpp:137
+
const char * _keyArea
+ +
EGLContext ctx
Definition: simple-egl.cpp:123
+
long port
Definition: simple-egl.cpp:60
+
static const struct wl_registry_listener registry_listener
Definition: simple-egl.cpp:515
+
static void create_ivi_surface(struct window *window, struct display *display)
Definition: simple-egl.cpp:322
+
struct ivi_surface * ivi_surface
Definition: simple-egl.cpp:148
+
struct geometry geometry window_size
Definition: simple-egl.cpp:138
+ +
int init(const int port, const std::string &token)
+ +
int frame_sync
Definition: simple-egl.cpp:151
+
struct wl_display * display
Definition: simple-egl.cpp:117
+
static void fini_egl(struct display *display)
Definition: simple-egl.cpp:252
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
static void init_egl(struct display *display, struct window *window)
Definition: simple-egl.cpp:174
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+
const char * _areaNormal
+
static void registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
Definition: simple-egl.cpp:510
+
int main(int argc, char **argv)
Definition: simple-egl.cpp:589
+
struct wl_compositor * compositor
Definition: simple-egl.cpp:119
+
int buffer_size
Definition: simple-egl.cpp:151
+
const char * log_prefix
Definition: simple-egl.cpp:58
+ +
static void destroy_surface(struct window *window)
Definition: simple-egl.cpp:370
+
int fullscreen
Definition: simple-egl.cpp:151
+
int init_hs(LibHomeScreen *hs)
Definition: simple-egl.cpp:565
+
static const struct wl_message ivi_surface_requests[]
Definition: simple-egl.cpp:77
+
uint32_t frames
Definition: simple-egl.cpp:145
+
void set_event_handler(enum EventType et, handler_func f)
+
+ + + + diff --git a/doc/api-ref/html/de/dca/hs-clientmanager_8h.html b/doc/api-ref/html/de/dca/hs-clientmanager_8h.html new file mode 100644 index 0000000..81b17ae --- /dev/null +++ b/doc/api-ref/html/de/dca/hs-clientmanager_8h.html @@ -0,0 +1,136 @@ + + + + + + +HomeScreenBinding: src/hs-clientmanager.h File Reference + + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
hs-clientmanager.h File Reference
+
+
+
#include <string>
+#include <mutex>
+#include <memory>
+#include <unordered_map>
+#include "hs-helper.h"
+#include "hs-client.h"
+
+

Go to the source code of this file.

+ + + + + + +

+Classes

struct  HS_ClientCtxt
 
class  HS_ClientManager
 
+ + + +

+Typedefs

typedef struct HS_ClientCtxt HS_ClientCtxt
 
+

Typedef Documentation

+ +
+
+ + + + +
typedef struct HS_ClientCtxt HS_ClientCtxt
+
+ +
+
+
+ + + + diff --git a/doc/api-ref/html/de/dca/hs-clientmanager_8h_source.html b/doc/api-ref/html/de/dca/hs-clientmanager_8h_source.html new file mode 100644 index 0000000..349281b --- /dev/null +++ b/doc/api-ref/html/de/dca/hs-clientmanager_8h_source.html @@ -0,0 +1,117 @@ + + + + + + +HomeScreenBinding: src/hs-clientmanager.h Source File + + + + + + + + + + +
+
+ + + + + + +
+
HomeScreenBinding +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
hs-clientmanager.h
+
+
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef HOMESCREEN_CLIENTMANAGER_H
18 #define HOMESCREEN_CLIENTMANAGER_H
19 
20 #include <string>
21 #include <mutex>
22 #include <memory>
23 #include <unordered_map>
24 #include "hs-helper.h"
25 #include "hs-client.h"
26 
27 typedef struct HS_ClientCtxt
28 {
29  std::string id;
30  HS_ClientCtxt(const char *appid)
31  {
32  id = appid;
33  }
35 
36 
38 public:
40  ~HS_ClientManager() = default;
41  HS_ClientManager(HS_ClientManager const &) = delete;
42  HS_ClientManager &operator=(HS_ClientManager const &) = delete;
44  HS_ClientManager &operator=(HS_ClientManager &&) = delete;
45 
46  static HS_ClientManager* instance(void);
47  int init(void);
48  void removeClientCtxt(void *data);
49 
50  int tap_shortcut(afb_req_t request);
51  int showWindow(afb_req_t request);
52  int hideWindow(afb_req_t request);
53  int replyShowWindow(afb_req_t request);
54  int on_screen_message(afb_req_t request);
55  int on_screen_reply(afb_req_t request);
56  int subscribe(afb_req_t request);
57  int unsubscribe(afb_req_t request);
58  int showNotification(afb_req_t request);
59  int showInformation(afb_req_t request);
60 
61 private:
62  HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
63  HS_Client* addClient(afb_req_t req, std::string appid);
64  void removeClient(std::string appid);
65 
66 private:
67  static HS_ClientManager* me;
68  std::unordered_map<std::string, HS_Client*> client_list;
69  std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
70  std::mutex mtx;
71 };
72 
73 #endif // HOMESCREEN_CLIENTMANAGER_H
HS_ClientCtxt(const char *appid)
+
static void showWindow(afb_req_t request)
Definition: homescreen.cpp:194
+
static void on_screen_reply(afb_req_t request)
Definition: homescreen.cpp:113
+
static void on_screen_message(afb_req_t request)
Definition: homescreen.cpp:85
+
static void subscribe(afb_req_t request)
Definition: homescreen.cpp:140
+ + +
static void unsubscribe(afb_req_t request)
Definition: homescreen.cpp:167
+ +
static void showInformation(afb_req_t request)
Definition: homescreen.cpp:306
+ + +
static void hideWindow(afb_req_t request)
Definition: homescreen.cpp:221
+
std::string id
+
static void replyShowWindow(afb_req_t request)
Definition: homescreen.cpp:248
+
static void showNotification(afb_req_t request)
Definition: homescreen.cpp:277
+
static void tap_shortcut(afb_req_t request)
Definition: homescreen.cpp:58
+
static int init(afb_api_t api)
Definition: homescreen.cpp:368
+
+ + + + diff --git a/doc/api-ref/html/de/dd0/class_lib_home_screen.html b/doc/api-ref/html/de/dd0/class_lib_home_screen.html index 2181e10..66e6319 100644 --- a/doc/api-ref/html/de/dd0/class_lib_home_screen.html +++ b/doc/api-ref/html/de/dd0/class_lib_home_screen.html @@ -3,8 +3,7 @@ - - + HomeScreenBinding: LibHomeScreen Class Reference @@ -12,6 +11,9 @@ + @@ -29,19 +31,40 @@ - + - - - - + +
@@ -72,9 +96,17 @@ $(function() { - @@ -90,17 +122,17 @@ Public Member Functions - + - - + + - + @@ -110,15 +142,40 @@ Public Member Functions + + + + + + + + + + - +

Public Types

enum  EventType { Event_TapShortcut = 1, +
enum  EventType {
+  Event_ShowWindow = 1, +Event_TapShortcut = 1, Event_OnScreenMessage, -Event_OnScreenReply +Event_OnScreenReply, +
+  Event_HideWindow, +Event_ReplyShowWindow, +Event_ShowNotification, +Event_ShowInformation +
}
 
using handler_func = std::function< void(json_object *)>
 
LibHomeScreenoperator= (const LibHomeScreen &)=delete
 
int init (const int port, const std::string &token)
int init (const int port, const std::string &token)
 
int tapShortcut (const char *application_name)
 
int tapShortcut (const char *application_id)
 
int onScreenMessage (const char *display_message)
 
int onScreenReply (const char *reply_message)
 
void set_event_handler (enum EventType et, handler_func f)
 
void registerCallback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
void registerCallback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
 
int call (const std::string &verb, struct json_object *arg)
 
 
int unsubscribe (const std::string &event_name)
 
int showWindow (const char *application_id, json_object *json)
 
int hideWindow (const char *application_id)
 
int replyShowWindow (const char *application_id, json_object *json)
 
int showNotification (json_object *json)
 
int showInformation (json_object *json)
 
void on_hangup (void *closure, struct afb_wsj1 *wsj)
 
void on_call (void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
 
void on_event (void *closure, const char *event, struct afb_wsj1_msg *msg)
void on_event (void *closure, const char *event, struct afb_wsj1_msg *msg)
 
void on_reply (void *closure, struct afb_wsj1_msg *msg)
 
+ + + + + + + + + + + + + +

+Public Attributes

const char * _keyParameter = "parameter"
 
const char * _keyArea = "area"
 
const char * _areaNormal = "normal"
 
const char * _areaFullScreen = "fullscreen"
 
const char * _areaSplitMain = "split.main"
 
const char * _areaSplitSub = "split.sub"
 
@@ -128,11 +185,9 @@ Static Public Attributes

Static Public Attributes

static const std::vector< std::string > api_list

Detailed Description

-

Definition at line 32 of file libhomescreen.hpp.

+

Definition at line 31 of file libhomescreen.hpp.

Member Typedef Documentation

- -

◆ handler_func

- +
@@ -142,14 +197,12 @@ Static Public Attributes
-

Definition at line 42 of file libhomescreen.hpp.

+

Definition at line 40 of file libhomescreen.hpp.

Member Enumeration Documentation

- -

◆ EventType

- +
@@ -159,22 +212,38 @@ Static Public Attributes
- - - + + + + + + + +
Enumerator
Event_TapShortcut 
Event_OnScreenMessage 
Event_OnScreenReply 
Enumerator
Event_ShowWindow  +
Event_TapShortcut  +
Event_OnScreenMessage  +
Event_OnScreenReply  +
Event_HideWindow  +
Event_ReplyShowWindow  +
Event_ShowNotification  +
Event_ShowInformation  +
-

Definition at line 44 of file libhomescreen.hpp.

-

Constructor & Destructor Documentation

- -

◆ LibHomeScreen() [1/2]

- +
@@ -188,13 +257,11 @@ Static Public Attributes

constructor

-

Definition at line 83 of file libhomescreen.cpp.

-
84 {
85 }
+

Definition at line 93 of file libhomescreen.cpp.

+
94 {
95 }
- -

◆ ~LibHomeScreen()

- +
@@ -208,13 +275,11 @@ Static Public Attributes

destructor

-

Definition at line 90 of file libhomescreen.cpp.

-
91 {
92  if(mploop)
93  {
94  sd_event_unref(mploop);
95  }
96  if(sp_websock != NULL)
97  {
98  afb_wsj1_unref(sp_websock);
99  }
100 }
+

Definition at line 100 of file libhomescreen.cpp.

+
101 {
102  if(mploop)
103  {
104  sd_event_unref(mploop);
105  }
106  if(sp_websock != NULL)
107  {
108  afb_wsj1_unref(sp_websock);
109  }
110 }
- -

◆ LibHomeScreen() [2/2]

- +
@@ -239,9 +304,7 @@ Static Public Attributes

Member Function Documentation

- -

◆ call() [1/2]

- +
@@ -267,9 +330,7 @@ Static Public Attributes - -

◆ call() [2/2]

- +
@@ -305,17 +366,45 @@ Static Public Attributes

Note

To call HomeScreen's APIs, the application should set its function name, arguments to JSON format.

-

Definition at line 360 of file libhomescreen.cpp.

-
361 {
362  int ret;
363  if(!sp_websock)
364  {
365  return -1;
366  }
367  if (!has_verb(string(verb)))
368  {
369  HMI_ERROR("libhomescreen","verb doesn't exit");
370  return -1;
371  }
372  ret = afb_wsj1_call_j(sp_websock, API, verb, arg, _on_reply_static, this);
373  if (ret < 0) {
374  HMI_ERROR("libhomescreen","Failed to call verb:%s",verb);
375  }
376  return ret;
377 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
-
static const char API[]
-
static bool has_verb(const string &verb)
-
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
+

Definition at line 377 of file libhomescreen.cpp.

+
378 {
379  int ret;
380  if(!sp_websock)
381  {
382  return -1;
383  }
384  if (!has_verb(string(verb)))
385  {
386  HMI_ERROR("libhomescreen","verb doesn't exit");
387  return -1;
388  }
389  ret = afb_wsj1_call_j(sp_websock, API, verb, arg, _on_reply_static, this);
390  if (ret < 0) {
391  HMI_ERROR("libhomescreen","Failed to call verb:%s",verb);
392  }
393  return ret;
394 }
static const char API[]
+
static bool has_verb(const string &verb)
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
- -

◆ init()

+ +
+
+
+ + + + + + + +
int LibHomeScreen::hideWindow (const char * application_id)
+
+

Sending hide window event

+

Call HomeScreen Service's hideWindow verb to release id's screen.

+

Parameters

+
    +
  • application_id [in] : This argument should be specified to the application's id.
  • +
+

Return

+
    +
  • Returns 0 on success or -1 in case of error.
  • +
+

Definition at line 503 of file libhomescreen.cpp.

+
504 {
505  if(!sp_websock)
506  {
507  return -1;
508  }
509 
510  struct json_object* j_obj = json_object_new_object();
511  struct json_object* val = json_object_new_string(application_id);
512  json_object_object_add(j_obj, ApplicationId, val);
513 
514  return this->call("hideWindow", j_obj);
515 }
static const char ApplicationId[]
+
int call(const std::string &verb, struct json_object *arg)
+
+
+
+
@@ -349,15 +438,15 @@ Static Public Attributes

Note

Use this constructor

-

Definition at line 116 of file libhomescreen.cpp.

-
117 {
118  int ret = 0;
119  if(port > 0 && token.size() > 0)
120  {
121  mport = port;
122  mtoken = token;
123  }
124  else
125  {
126  HMI_ERROR("libhomescreen","port and token should be > 0, Initial port and token uses.");
127  }
128 
129  ret = initialize_websocket();
130  if(ret != 0 )
131  {
132  HMI_ERROR("libhomescreen","Failed to initialize websocket");
133  }
134  else{
135  HMI_DEBUG("libhomescreen","Initialized");
136  }
137 
138  return ret;
139 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
-
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
+

Definition at line 126 of file libhomescreen.cpp.

+
127 {
128  int ret = 0;
129  if(port > 0 && token.size() > 0)
130  {
131  mport = port;
132  mtoken = token;
133  }
134  else
135  {
136  HMI_ERROR("libhomescreen","port and token should be > 0, Initial port and token uses.");
137  }
138 
139  ret = initialize_websocket();
140  if(ret != 0 )
141  {
142  HMI_ERROR("libhomescreen","Failed to initialize websocket");
143  }
144  else{
145  HMI_DEBUG("libhomescreen","Initialized");
146  }
147 
148  return ret;
149 }
string token
Definition: simple-egl.cpp:61
+
long port
Definition: simple-egl.cpp:60
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
- -

◆ on_call()

- +
@@ -393,13 +482,11 @@ Static Public Attributes
-

Definition at line 448 of file libhomescreen.cpp.

-
449 {
450 }
+

Definition at line 606 of file libhomescreen.cpp.

+
607 {
608 }
- -

◆ on_event()

- +
@@ -429,20 +516,23 @@ Static Public Attributes
-

Definition at line 458 of file libhomescreen.cpp.

-
459 {
460  HMI_DEBUG("libhomescreen","event: (%s) msg: (%s).", event, afb_wsj1_msg_object_s(msg));
461 
462  if (strstr(event, API) == NULL) {
463  return;
464  }
465 
466  struct json_object* ev_contents = afb_wsj1_msg_object_j(msg);
467  struct json_object *json_data = json_object_object_get(ev_contents, "data");
468 
469  if(onEvent != nullptr)
470  {
471  const string ev(event);
472  onEvent(ev, ev_contents);
473  }
474 
475  const char* event_only = strchr(event, '/');
476  if (event_only != nullptr) {
477  event_only = event_only + 1;
478  }
479 
480  if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
481  auto i = this->handlers.find(Event_TapShortcut);
482  if ( i != this->handlers.end() ) {
483  i->second(json_data);
484  }
485  }
486  else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {
487  auto i = this->handlers.find(Event_OnScreenMessage);
488  if ( i != this->handlers.end() ) {
489  i->second(json_data);
490  }
491  }
492  else if (strcasecmp(event_only, LibHomeScreen::event_list[2].c_str()) == 0) {
493  auto i = this->handlers.find(Event_OnScreenReply);
494  if ( i != this->handlers.end() ) {
495  i->second(json_data);
496  }
497  }
498 
499  json_object_put(ev_contents);
500 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
- -
static const char API[]
- - -
static const std::vector< std::string > event_list
- +

Definition at line 616 of file libhomescreen.cpp.

+
617 {
618  HMI_DEBUG("libhomescreen","event: (%s) msg: (%s).", event, afb_wsj1_msg_object_s(msg));
619 
620  if (strstr(event, API) == NULL) {
621  return;
622  }
623 
624  struct json_object* ev_contents = afb_wsj1_msg_object_j(msg);
625  struct json_object *json_data;
626  if(!json_object_object_get_ex(ev_contents, "data", &json_data)) {
627  HMI_ERROR("libhomescreen", "got ev_contents error.");
628  return;
629  }
630 
631  if(onEvent != nullptr)
632  {
633  const string ev(event);
634  onEvent(ev, ev_contents);
635  }
636 
637  const char* event_type = nullptr;
638  struct json_object *json_event_type;
639  if(json_object_object_get_ex(json_data, "type", &json_event_type)) {
640  event_type = json_object_get_string(json_event_type);
641  }
642  else {
643  HMI_WARNING("libhomescreen","event_type is null.");
644  return;
645  }
646 
647  if (strcasecmp(event_type, LibHomeScreen::event_list[0].c_str()) == 0) {
648  auto i = this->handlers.find(Event_ShowWindow);
649  if ( i != this->handlers.end() ) {
650  i->second(json_data);
651  }
652  }
653  else if (strcasecmp(event_type, LibHomeScreen::event_list[1].c_str()) == 0) {
654  auto i = this->handlers.find(Event_OnScreenMessage);
655  if ( i != this->handlers.end() ) {
656  i->second(json_data);
657  }
658  }
659  else if (strcasecmp(event_type, LibHomeScreen::event_list[2].c_str()) == 0) {
660  auto i = this->handlers.find(Event_OnScreenReply);
661  if ( i != this->handlers.end() ) {
662  i->second(json_data);
663  }
664  }
665  else if (strcasecmp(event_type, LibHomeScreen::event_list[3].c_str()) == 0) {
666  auto i = this->handlers.find(Event_HideWindow);
667  if ( i != this->handlers.end() ) {
668  i->second(json_data);
669  }
670  }
671  else if (strcasecmp(event_type, LibHomeScreen::event_list[4].c_str()) == 0) {
672  auto i = this->handlers.find(Event_ReplyShowWindow);
673  if ( i != this->handlers.end() ) {
674  i->second(json_data);
675  }
676  }
677  else if (strcasecmp(event_type, LibHomeScreen::event_list[5].c_str()) == 0) {
678  auto i = this->handlers.find(Event_ShowNotification);
679  if ( i != this->handlers.end() ) {
680  i->second(json_data);
681  }
682  }
683  else if (strcasecmp(event_type, LibHomeScreen::event_list[6].c_str()) == 0) {
684  auto i = this->handlers.find(Event_ShowInformation);
685  if ( i != this->handlers.end() ) {
686  i->second(json_data);
687  }
688  }
689 }
static const char API[]
+ + + + + + +
#define HMI_WARNING(prefix, args,...)
Definition: hmi-debug.h:39
+ +
static const std::vector< std::string > event_list
+
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:38
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
- -

◆ on_hangup()

- +
@@ -466,14 +556,12 @@ Static Public Attributes
-

Definition at line 439 of file libhomescreen.cpp.

-
440 {
441  HMI_DEBUG("libhomescreen","%s called", __FUNCTION__);
442  if(onHangup != nullptr)
443  {
444  onHangup();
445  }
446 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
+

Definition at line 597 of file libhomescreen.cpp.

+
598 {
599  HMI_DEBUG("libhomescreen","called");
600  if(onHangup != nullptr)
601  {
602  onHangup();
603  }
604 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
- -

◆ on_reply()

- +
@@ -498,14 +586,12 @@ Static Public Attributes

msg is like ({"response":{"verb":"subscribe","error":0},"jtype":"afb-reply","request":{"status":"success","info":"homescreen binder subscribe event name [on_screen_message]"}}) msg is like ({"response":{"verb":"tap_shortcut","error":0},"jtype":"afb-reply","request":{"status":"success","info":"afb_event_push event [tap_shortcut]"}})

-

Definition at line 506 of file libhomescreen.cpp.

-
507 {
508  HMI_DEBUG("libhomescreen","msg: (%s)", afb_wsj1_msg_object_s(msg));
509  if(onReply != nullptr)
510  {
511  struct json_object* reply = afb_wsj1_msg_object_j(msg);
512  onReply(reply);
513 
514  json_object_put(reply);
515  }
516 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
+

Definition at line 695 of file libhomescreen.cpp.

+
696 {
697  HMI_DEBUG("libhomescreen","msg: (%s)", afb_wsj1_msg_object_s(msg));
698  if(onReply != nullptr)
699  {
700  struct json_object* reply = afb_wsj1_msg_object_j(msg);
701  onReply(reply);
702  }
703 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
- -

◆ onScreenMessage()

- +
@@ -529,14 +615,12 @@ Static Public Attributes
  • Returns 0 on success or -1 in case of error.
  • -

    Definition at line 244 of file libhomescreen.cpp.

    -
    245 {
    246  if(!sp_websock)
    247  {
    248  return -1;
    249  }
    250 
    251  struct json_object* j_obj = json_object_new_object();
    252  struct json_object* val = json_object_new_string(display_message);
    253  json_object_object_add(j_obj, "display_message", val);
    254  return this->call("on_screen_message", j_obj);
    255 }
    int call(const std::string &verb, struct json_object *arg)
    +

    Definition at line 242 of file libhomescreen.cpp.

    +
    243 {
    244  if(!sp_websock)
    245  {
    246  return -1;
    247  }
    248 
    249  struct json_object* j_obj = json_object_new_object();
    250  struct json_object* val = json_object_new_string(display_message);
    251  json_object_object_add(j_obj, "display_message", val);
    252  return this->call("on_screen_message", j_obj);
    253 }
    int call(const std::string &verb, struct json_object *arg)
    - -

    ◆ onScreenReply()

    - +
    @@ -560,14 +644,12 @@ Static Public Attributes
  • Returns 0 on success or -1 in case of error.
  • -

    Definition at line 268 of file libhomescreen.cpp.

    -
    269 {
    270  if(!sp_websock)
    271  {
    272  return -1;
    273  }
    274 
    275  struct json_object* j_obj = json_object_new_object();
    276  struct json_object* val = json_object_new_string(reply_message);
    277  json_object_object_add(j_obj, "reply_message", val);
    278  return this->call("on_screen_reply", j_obj);
    279 }
    int call(const std::string &verb, struct json_object *arg)
    +

    Definition at line 266 of file libhomescreen.cpp.

    +
    267 {
    268  if(!sp_websock)
    269  {
    270  return -1;
    271  }
    272 
    273  struct json_object* j_obj = json_object_new_object();
    274  struct json_object* val = json_object_new_string(reply_message);
    275  json_object_object_add(j_obj, "reply_message", val);
    276  return this->call("on_screen_reply", j_obj);
    277 }
    int call(const std::string &verb, struct json_object *arg)
    - -

    ◆ operator=()

    - +
    @@ -591,16 +673,14 @@ Static Public Attributes - -

    ◆ registerCallback()

    - +
    - + @@ -633,13 +713,53 @@ Static Public Attributes

    Note

    Event callback is invoked by home screen for event you subscribed. If you would like to get event, please call subscribe function before/after this function

    -

    Definition at line 155 of file libhomescreen.cpp.

    -
    159 {
    160  onEvent = event_cb;
    161  onReply = reply_cb;
    162  onHangup = hangup_cb;
    163 }
    +

    Definition at line 165 of file libhomescreen.cpp.

    +
    169 {
    170  onEvent = event_cb;
    171  onReply = reply_cb;
    172  onHangup = hangup_cb;
    173 }
    - -

    ◆ set_event_handler()

    + +
    +
    +
    void LibHomeScreen::registerCallback (void(*)(const std::string &event, struct json_object *event_contents) void(*)(const std::string &event, struct json_object *event_contents)  event_cb,
    + + + + + + + + + + + + + + + + + +
    int LibHomeScreen::replyShowWindow (const char * application_id,
    json_object * json 
    )
    +
    +

    Sending reply onscreen message event

    +

    Call HomeScreen Service's replyShowWindow verb to reply onscreen message.

    +

    Parameters

    +
      +
    • application_id [in] : This argument should be specified to the onscreen reply to applilcation id.
    • +
    • json [in] : This argument should be specified to the json parameters.
    • +
    +

    Return

    +
      +
    • Returns 0 on success or -1 in case of error.
    • +
    +

    Definition at line 530 of file libhomescreen.cpp.

    +
    531 {
    532  if(!sp_websock)
    533  {
    534  return -1;
    535  }
    536 
    537  if (json == nullptr) {
    538  HMI_WARNING("libhomescreen", "replyShowWindow`s parameter is null");
    539  return -1;
    540  }
    541 
    542  struct json_object* j_obj = json_object_new_object();
    543  struct json_object* val = json_object_new_string(application_id);
    544  json_object_object_add(j_obj, ApplicationId, val);
    545  json_object_object_add(j_obj, "parameter", json);
    546 
    547  return this->call("replyShowWindow", j_obj);
    548 }
    static const char ApplicationId[]
    +
    int call(const std::string &verb, struct json_object *arg)
    +
    #define HMI_WARNING(prefix, args,...)
    Definition: hmi-debug.h:39
    +
    +
    +
    +
    @@ -670,20 +790,123 @@ Static Public Attributes
  • f [in] : event handler
  • Return

    -

    Nothing

    - -

    Definition at line 293 of file libhomescreen.cpp.

    -
    294 {
    295  if (et >= 1 && et <= 3) {
    296  switch (et) {
    297  case Event_TapShortcut:
    299  break;
    302  break;
    303  case Event_OnScreenReply:
    305  break;
    306  }
    307 
    308  this->handlers[et] = std::move(f);
    309  }
    310 }
    - -
    int subscribe(const std::string &event_name)
    -
    static const std::vector< std::string > event_list
    - +

    Nothing

    +

    Note

    +

    Don't release json_object by json_object_put in handler_func. The resource is released by libafbwsc library.

    + +

    Definition at line 295 of file libhomescreen.cpp.

    +
    296 {
    297  if (et >= 1 && et <= 7) {
    298  switch (et) {
    299 /* case Event_TapShortcut:
    300  this->subscribe(LibHomeScreen::event_list[0]);
    301  break;*/
    302  case Event_ShowWindow:
    304  break;
    307  break;
    308  case Event_OnScreenReply:
    310  break;
    311  case Event_HideWindow:
    313  break;
    316  break;
    319  break;
    322  break;
    323  }
    324 
    325  this->handlers[et] = std::move(f);
    326  }
    327 }
    + + + + +
    int subscribe(const std::string &event_name)
    + + +
    static const std::vector< std::string > event_list
    - -

    ◆ subscribe()

    + +
    +
    +
    + + + + + + + +
    int LibHomeScreen::showInformation (json_object * json)
    +
    +

    Sending show information event

    +

    Call HomeScreen Service's information verb to show notification on Information Bar.

    +

    Parameters

    +
      +
    • json [in] : This argument should be specified to the json parameters.
    • +
    +

    Return

    +
      +
    • Returns 0 on success or -1 in case of error.
    • +
    +

    Definition at line 584 of file libhomescreen.cpp.

    +
    585 {
    586  if(!sp_websock)
    587  {
    588  return -1;
    589  }
    590 
    591  return this->call("showInformation", json);
    592 }
    int call(const std::string &verb, struct json_object *arg)
    +
    +
    +
    + +
    +
    + + + + + + + + +
    int LibHomeScreen::showNotification (json_object * json)
    +
    +

    Sending show notification event

    +

    Call HomeScreen Service's notification verb to show notification on Status Bar.

    +

    Parameters

    +
      +
    • json [in] : This argument should be specified to the json parameters.
    • +
    +

    Return

    +
      +
    • Returns 0 on success or -1 in case of error.
    • +
    + +

    Definition at line 562 of file libhomescreen.cpp.

    +
    563 {
    564  if(!sp_websock)
    565  {
    566  return -1;
    567  }
    568 
    569  return this->call("showNotification", json);
    570 }
    int call(const std::string &verb, struct json_object *arg)
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    int LibHomeScreen::showWindow (const char * application_id,
    json_object * json 
    )
    +
    +

    Sending show window event

    +

    Call HomeScreen Service's showWindow verb to request display id's screen.

    +

    Parameters

    +
      +
    • application_id [in] : This argument should be specified to the application's id.
    • +
    • json [in] : This argument should be specified to the json parameters.
    • +
    +

    Return

    +
      +
    • Returns 0 on success or -1 in case of error.
    • +
    + +

    Definition at line 467 of file libhomescreen.cpp.

    +
    468 {
    469  if(!sp_websock)
    470  {
    471  return -1;
    472  }
    473 
    474  struct json_object* j_obj = json_object_new_object();
    475  struct json_object* val = json_object_new_string(application_id);
    476  json_object_object_add(j_obj, ApplicationId, val);
    477 
    478  if (json == nullptr) {
    479  struct json_object* j_json = json_object_new_object();
    480  struct json_object* value = json_object_new_string("normal");
    481  json_object_object_add(j_json, "area", value);
    482  json_object_object_add(j_obj, "parameter", j_json);
    483  }
    484  else {
    485  json_object_object_add(j_obj, "parameter", json);
    486  }
    487 
    488  return this->call("showWindow", j_obj);
    489 }
    static const char ApplicationId[]
    +
    int call(const std::string &verb, struct json_object *arg)
    +
    +
    +
    +
    @@ -708,16 +931,14 @@ Static Public Attributes

    Note

    This function enables to get an event to your callback function.

    -

    Definition at line 392 of file libhomescreen.cpp.

    -
    393 {
    394  if(!sp_websock)
    395  {
    396  return -1;
    397  }
    398  struct json_object* j_obj = json_object_new_object();
    399  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
    400 
    401  int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", j_obj, _on_reply_static, this);
    402  if (ret < 0) {
    403  HMI_ERROR("libhomescreen","Failed to call verb:%s",__FUNCTION__);
    404  }
    405  return ret;
    406 }
    #define HMI_ERROR(prefix, args,...)
    Definition: hmi-debug.h:18
    -
    static const char API[]
    -
    static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
    +

    Definition at line 409 of file libhomescreen.cpp.

    +
    410 {
    411  if(!sp_websock)
    412  {
    413  return -1;
    414  }
    415  struct json_object* j_obj = json_object_new_object();
    416  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
    417 
    418  int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", j_obj, _on_reply_static, this);
    419  if (ret < 0) {
    420  HMI_ERROR("libhomescreen","Failed to call verb");
    421  }
    422  return ret;
    423 }
    static const char API[]
    +
    #define HMI_ERROR(prefix, args,...)
    Definition: hmi-debug.h:38
    +
    static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
    - -

    ◆ tapShortcut()

    - +
    @@ -725,7 +946,7 @@ Static Public Attributes - +
    int LibHomeScreen::tapShortcut ( const char * application_name)application_id)
    @@ -734,21 +955,19 @@ Static Public Attributes

    When HomeScreen shortcut area is tapped, sending a event

    Parameters

      -
    • application_name [in] : Tapped application name (label)
    • +
    • application_id [in] : Tapped application id (label)

    Return

    • Returns 0 on success or -1 in case of error.
    -

    Definition at line 220 of file libhomescreen.cpp.

    -
    221 {
    222  if(!sp_websock)
    223  {
    224  return -1;
    225  }
    226 
    227  struct json_object* j_obj = json_object_new_object();
    228  struct json_object* val = json_object_new_string(application_name);
    229  json_object_object_add(j_obj, "application_name", val);
    230  return this->call("tap_shortcut", j_obj);
    231 }
    int call(const std::string &verb, struct json_object *arg)
    +

    Definition at line 222 of file libhomescreen.cpp.

    +
    223 {
    224  struct json_object* obj = json_object_new_object();
    225  struct json_object* val = json_object_new_string("normal");
    226  json_object_object_add(obj, "area", val);
    227 
    228  return showWindow(application_id, obj);
    229 }
    int showWindow(const char *application_id, json_object *json)
    - -

    ◆ unsubscribe()

    - +
    @@ -773,17 +992,99 @@ Static Public Attributes

    Note

    This function disables to get an event to your callback function.

    -

    Definition at line 421 of file libhomescreen.cpp.

    -
    422 {
    423  if(!sp_websock)
    424  {
    425  return -1;
    426  }
    427  struct json_object* j_obj = json_object_new_object();
    428  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
    429 
    430  int ret = afb_wsj1_call_j(sp_websock, API, "unsubscribe", j_obj, _on_reply_static, this);
    431  if (ret < 0) {
    432  HMI_ERROR("libhomescreen","Failed to call verb:%s",__FUNCTION__);
    433  }
    434  return ret;
    435 }
    #define HMI_ERROR(prefix, args,...)
    Definition: hmi-debug.h:18
    -
    static const char API[]
    -
    static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
    +

    Definition at line 438 of file libhomescreen.cpp.

    +
    439 {
    440  if(!sp_websock)
    441  {
    442  return -1;
    443  }
    444  struct json_object* j_obj = json_object_new_object();
    445  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
    446 
    447  int ret = afb_wsj1_call_j(sp_websock, API, "unsubscribe", j_obj, _on_reply_static, this);
    448  if (ret < 0) {
    449  HMI_ERROR("libhomescreen","Failed to call verb");
    450  }
    451  return ret;
    452 }
    static const char API[]
    +
    #define HMI_ERROR(prefix, args,...)
    Definition: hmi-debug.h:38
    +
    static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)

    Member Data Documentation

    - -

    ◆ api_list

    + +
    +
    +
    + + + +
    const char* LibHomeScreen::_areaFullScreen = "fullscreen"
    +
    + +

    Definition at line 59 of file libhomescreen.hpp.

    + +
    +
    + +
    +
    + + + + +
    const char* LibHomeScreen::_areaNormal = "normal"
    +
    + +

    Definition at line 58 of file libhomescreen.hpp.

    + +
    +
    + +
    +
    + + + + +
    const char* LibHomeScreen::_areaSplitMain = "split.main"
    +
    + +

    Definition at line 60 of file libhomescreen.hpp.

    + +
    +
    + +
    +
    + + + + +
    const char* LibHomeScreen::_areaSplitSub = "split.sub"
    +
    +

    Definition at line 61 of file libhomescreen.hpp.

    + +
    +
    + +
    +
    + + + + +
    const char* LibHomeScreen::_keyArea = "area"
    +
    + +

    Definition at line 55 of file libhomescreen.hpp.

    + +
    +
    + +
    +
    + + + + +
    const char* LibHomeScreen::_keyParameter = "parameter"
    +
    + +

    Definition at line 54 of file libhomescreen.hpp.

    + +
    +
    +
    @@ -800,14 +1101,12 @@ Static Public Attributes
    -Initial value:
    {
    std::string("ping"),
    std::string("tap_shortcut"),
    std::string("on_screen_message"),
    std::string("on_screen_reply"),
    std::string("subscribe"),
    std::string("unsubscribe")
    }
    -

    Definition at line 50 of file libhomescreen.hpp.

    +Initial value:
    {
    std::string("ping"),
    std::string("tap_shortcut"),
    std::string("on_screen_message"),
    std::string("on_screen_reply"),
    std::string("subscribe"),
    std::string("unsubscribe"),
    std::string("showWindow"),
    std::string("hideWindow"),
    std::string("replyShowWindow"),
    std::string("showNotification"),
    std::string("showInformation")
    }
    +

    Definition at line 63 of file libhomescreen.hpp.

    - -

    ◆ event_list

    - +
    @@ -824,8 +1123,8 @@ Static Public Attributes
    -Initial value:
    {
    std::string("tap_shortcut"),
    std::string("on_screen_message"),
    std::string("on_screen_reply"),
    std::string("none")
    }
    -

    Definition at line 51 of file libhomescreen.hpp.

    +Initial value:
    {
    std::string("showWindow"),
    std::string("on_screen_message"),
    std::string("on_screen_reply"),
    std::string("hideWindow"),
    std::string("replyShowWindow"),
    std::string("showNotification"),
    std::string("showInformation"),
    std::string("none")
    }
    +

    Definition at line 64 of file libhomescreen.hpp.

    @@ -838,7 +1137,7 @@ Static Public Attributes -- cgit 1.2.3-korg