[M67 Dev][Product TV] Enable Cursor with ecore-wl2
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / ubrowser / window.cc
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__);