[M67 Dev][Product TV] Enable Cursor with ecore-wl2
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_webview_app / app.c
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.