[M67 Dev][Product TV] Enable Cursor with ecore-wl2 13/187413/1
authorss440 <ss440.han@samsung.com>
Thu, 23 Aug 2018 04:28:40 +0000 (21:28 -0700)
committerss440 <ss440.han@samsung.com>
Thu, 23 Aug 2018 04:44:46 +0000 (21:44 -0700)
Enable VD Cursor for simple browsers

reference:
https://review.tizen.org/gerrit/#/c/180842

Change-Id: I5fa2f692b52930d58a784454fea888c494a8a0f1
Signed-off-by: ss440 <ss440.han@samsung.com>
tizen_src/ewk/efl_webview_app/app.c
tizen_src/ewk/efl_webview_app/mini_browser.c
tizen_src/ewk/ubrowser/window.cc

index e6343cb..c9c9ce9 100644 (file)
@@ -363,6 +363,59 @@ static void _evas_close_cb(Ecore_Evas* ee)
   ecore_main_loop_quit();
 }
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+static void _create_mouse_cursor(Evas_Object* window) {
+#if TIZEN_VERSION_AT_LEAST(5, 0, 0)
+  Ecore_Wl2_Display* wl2_display = ecore_wl2_connected_display_get(NULL);
+  struct wl_display* display = ecore_wl2_display_get(wl2_display);
+  Eina_Iterator* globals = ecore_wl2_display_globals_get(wl2_display);
+  struct wl_registry* registry = ecore_wl2_display_registry_get(wl2_display);
+  struct wl_seat* seat =
+      ecore_wl2_input_seat_get(ecore_wl2_input_default_input_get(wl2_display));
+
+  Ecore_Wl2_Global* global;
+  EINA_ITERATOR_FOREACH(globals, global) {
+    if (!strcmp(global->interface, "tizen_cursor"))
+      if (!CursorModule_Initialize(display, registry, seat, global->id))
+        fprintf(stderr, "CursorModule_Initialize() Failed!\n");
+  }
+  eina_iterator_free(globals);
+
+  struct wl_surface* const surface =
+      ecore_wl2_window_surface_get(ecore_evas_wayland2_window_get(
+          ecore_evas_ecore_evas_get(evas_object_evas_get(window))));
+  ecore_wl2_sync();
+
+  if (!Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL))
+    fprintf(stderr, "Cursor_Set_Config() Failed!\n");
+  CursorModule_Finalize();
+#else
+  const char* t_cursor = "tizen_cursor";
+  Ecore_Wl_Global* global_data = NULL;
+  unsigned int cursormgr_id = 0;
+
+  EINA_INLIST_FOREACH(ecore_wl_globals_get(), global_data) {
+    if (0 == strncmp(global_data->interface, t_cursor, strlen(t_cursor))) {
+      cursormgr_id = global_data->id;  // to get the id of cursormgr object
+      break;
+    }
+  }
+
+  struct wl_surface* const surface =
+      ecore_wl_window_surface_get(elm_win_wl_window_get(window));
+  ecore_wl_sync();
+
+  const int ret_cursormod = CursorModule_Initialize(
+      ecore_wl_display_get(), ecore_wl_registry_get(),
+      ecore_wl_input_seat_get(ecore_wl_input_get()), cursormgr_id);
+  if (ret_cursormod) {
+    Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL);
+  }
+  CursorModule_Finalize();
+#endif  // TIZEN_VERSION_AT_LEAST(5, 0, 0)
+}
+#endif
+
 int main(int argc, char** argv)
 {
   // Make sure this happens just once.
index fe6a958..5f68429 100644 (file)
@@ -295,6 +295,59 @@ static void set_url_from_user_input(Evas_Object* webview, const char* url)
   eina_strbuf_free(full_url);
 }
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+static void _create_mouse_cursor(Evas_Object* window) {
+#if TIZEN_VERSION_AT_LEAST(5, 0, 0)
+  Ecore_Wl2_Display* wl2_display = ecore_wl2_connected_display_get(NULL);
+  struct wl_display* display = ecore_wl2_display_get(wl2_display);
+  Eina_Iterator* globals = ecore_wl2_display_globals_get(wl2_display);
+  struct wl_registry* registry = ecore_wl2_display_registry_get(wl2_display);
+  struct wl_seat* seat =
+      ecore_wl2_input_seat_get(ecore_wl2_input_default_input_get(wl2_display));
+
+  Ecore_Wl2_Global* global;
+  EINA_ITERATOR_FOREACH(globals, global) {
+    if (!strcmp(global->interface, "tizen_cursor"))
+      if (!CursorModule_Initialize(display, registry, seat, global->id))
+        LOGE("CursorModule_Initialize() Failed!\n");
+  }
+  eina_iterator_free(globals);
+
+  struct wl_surface* const surface =
+      ecore_wl2_window_surface_get(ecore_evas_wayland2_window_get(
+          ecore_evas_ecore_evas_get(evas_object_evas_get(window))));
+  ecore_wl2_sync();
+
+  if (!Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL))
+    LOGE("Cursor_Set_Config() Failed!\n");
+  CursorModule_Finalize();
+#else
+  const char* t_cursor = "tizen_cursor";
+  unsigned int cursormgr_id = 0;
+  Ecore_Wl_Global* global_data = NULL;
+
+  EINA_INLIST_FOREACH(ecore_wl_globals_get(), global_data) {
+    if (0 == strncmp(global_data->interface, t_cursor, strlen(t_cursor))) {
+      cursormgr_id = global_data->id;  // to get the id of cursormgr object
+      break;
+    }
+  }
+
+  struct wl_surface* const surface =
+      ecore_wl_window_surface_get(elm_win_wl_window_get(window));
+  ecore_wl_sync();
+
+  const int ret_cursormod = CursorModule_Initialize(
+      ecore_wl_display_get(), ecore_wl_registry_get(),
+      ecore_wl_input_seat_get(ecore_wl_input_get()), cursormgr_id);
+  if (ret_cursormod) {
+    Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL);
+  }
+  CursorModule_Finalize();
+#endif
+}
+#endif
+
 static Evas_Object* _create_main_window(void *data)
 {
   Evas_Object *window = elm_win_add(NULL, "ChromiumEfl", ELM_WIN_BASIC);
index c8b76e0..375d242 100644 (file)
@@ -277,6 +277,59 @@ void Window::OnExitFullScreenRequest(void* data, Evas_Object*,
   thiz->is_fullscreen_ = false;
 }
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+void Window::CreateMouseCursor() {
+  log_trace("%s", __PRETTY_FUNCTION__);
+#if TIZEN_VERSION_AT_LEAST(5, 0, 0)
+  Ecore_Wl2_Display* wl2_display = ecore_wl2_connected_display_get(NULL);
+  struct wl_display* display = ecore_wl2_display_get(wl2_display);
+  Eina_Iterator* globals = ecore_wl2_display_globals_get(wl2_display);
+  struct wl_registry* registry = ecore_wl2_display_registry_get(wl2_display);
+  struct wl_seat* seat =
+      ecore_wl2_input_seat_get(ecore_wl2_input_default_input_get(wl2_display));
+
+  Ecore_Wl2_Global* global;
+  EINA_ITERATOR_FOREACH(globals, global) {
+    if (!strcmp(global->interface, "tizen_cursor"))
+      if (!CursorModule_Initialize(display, registry, seat, global->id))
+        log_error("CursorModule_Initialize() Failed!\n");
+  }
+  eina_iterator_free(globals);
+
+  struct wl_surface* const surface =
+      ecore_wl2_window_surface_get(ecore_evas_wayland2_window_get(
+          ecore_evas_ecore_evas_get(evas_object_evas_get(window_))));
+  ecore_wl2_sync();
+
+  if (!Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL))
+    log_error("Cursor_Set_Config() Failed!\n");
+  CursorModule_Finalize();
+#else
+  Ecore_Wl_Global* global_data = NULL;
+  unsigned int cursormgr_id = 0;
+
+  EINA_INLIST_FOREACH(ecore_wl_globals_get(), global_data) {
+    if (0 == strcmp(global_data->interface, "tizen_cursor")) {
+      cursormgr_id = global_data->id;  // to get the id of cursormgr object
+      break;
+    }
+  }
+
+  wl_surface* surface =
+      ecore_wl_window_surface_get(elm_win_wl_window_get(window_));
+  ecore_wl_sync();
+
+  int ret_cursormod = CursorModule_Initialize(
+      ecore_wl_display_get(), ecore_wl_registry_get(),
+      ecore_wl_input_seat_get(ecore_wl_input_get()), cursormgr_id);
+  if (ret_cursormod) {
+    Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE, NULL);
+  }
+  CursorModule_Finalize();
+#endif  // TIZEN_VERSION_AT_LEAST(5, 0, 0)
+}
+#endif
+
 void Window::OnUserMediaPermissionRequest(void* data, Evas_Object*,
                                           void* event_info) {
   log_trace("%s", __PRETTY_FUNCTION__);