[M108 Migration][WRTjs][VD] Apply Non Cursor Support logic for SmartMonitor 64/289664/2
authorzhaosy <shiyusy.zhao@samsung.com>
Mon, 13 Mar 2023 05:46:25 +0000 (13:46 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 14 Mar 2023 08:09:18 +0000 (08:09 +0000)
It's SmartMonitor requirment, the cursor in SmartMonitor is different
from TV, in SmartMonitor, window manager cannot disable cursor, just
can hide cursors, so follow the guide.
http://wiki.vd.sec.samsung.net/pages/viewpage.action?pageId=242867218

Besides set cursor name and transparent, WRT should call engine API to
disable mouse event.

Reference:
https://review.tizen.org/gerrit/287016/

Change-Id: I4f7d543c410fae4ea8ed305c3312797337da017f
Signed-off-by: zhaosy <shiyusy.zhao@samsung.com>
wrt/src/browser/tv/wrt_native_window_tv.cc

index 5ec48be..049173b 100644 (file)
@@ -364,7 +364,6 @@ void WRTNativeWindowTV::SetWebContents(content::WebContents* web_contents) {
     DecoratorWindow::GetInstance()->SetDecoratorWindow(top_window_);
   TvWindowManager::GetInstance()->Initialize(top_window_);
   SetDisplayRotatorCallback();
-  CreateMouseCursor(ewk_view);
   SetAppMetaDataInfo();
   SetRuntimeVariables();
   SetProxyInfo();
@@ -423,12 +422,25 @@ bool WRTNativeWindowTV::SetRotation() {
 }
 
 void WRTNativeWindowTV::CreateMouseCursor(Evas_Object* window) {
+  static bool mouse_initialize = false;
+  if (mouse_initialize)
+    return;
+
+  auto& setting_info = ApplicationData::GetInstance().setting_info();
+  std::string pointing_device_support = setting_info.pointing_device_option();
+  LOG(INFO) << "pointing_device_support = " << pointing_device_support;
+  if ((pointing_device_support == "" || pointing_device_support == "disable") &&
+      !IsSmartMonitor()) {
+    mouse_initialize = true;
+    return;
+  }
+
   Ecore_Wl2_Display* wl2_display = ecore_wl2_connected_display_get(nullptr);
   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_Input* input = ecore_wl2_input_default_input_get(wl2_display);
+  struct wl_seat* seat = ecore_wl2_input_seat_get(input);
 
   Ecore_Wl2_Global* global;
   EINA_ITERATOR_FOREACH(globals, global) {
@@ -443,15 +455,19 @@ void WRTNativeWindowTV::CreateMouseCursor(Evas_Object* window) {
           ecore_evas_ecore_evas_get(evas_object_evas_get(window))));
   ecore_wl2_sync();
 
-  auto& setting_info = ApplicationData::GetInstance().setting_info();
-  std::string pointing_device_support = setting_info.pointing_device_option();
-  LOG(INFO) << "pointing_device_support = " << pointing_device_support;
   if (pointing_device_support == "" || pointing_device_support == "disable") {
-    ecore_evas_aux_hint_add(GetPlatformCanvas(), kPointingDeviceSupport, "0");
-    if (!Cursor_UnSet_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE))
-      LOG(ERROR) << "unset cursor config failed";
+    // only smart monitor will execute this logic
+    elm_win_aux_hint_add(top_window_, kPointingDeviceSupport, "0");
+    ecore_wl2_input_cursor_theme_name_set(input, "vd-cursors");
+    ecore_wl2_input_cursor_from_name_set(input, "normal_transparent");
+#if !defined(WRT_JS_BRINGUP)
+    if (auto* rwhv = GetRenderWidgetHostView())
+      rwhv->SetMouseEventsEnabled(false);
+    else
+      LOG(WARNING) << "rwhv is null, cannot set cursor by client";
+#endif
   } else {
-    ecore_evas_aux_hint_add(GetPlatformCanvas(), kPointingDeviceSupport, "1");
+    elm_win_aux_hint_add(top_window_, kPointingDeviceSupport, "1");
     if (Cursor_Set_Config(surface, TIZEN_CURSOR_CONFIG_CURSOR_AVAILABLE,
                           nullptr)) {
       if (setting_info.pointing_device_option() == "mouse-no-hide") {
@@ -463,7 +479,9 @@ void WRTNativeWindowTV::CreateMouseCursor(Evas_Object* window) {
       LOG(ERROR) << "set cursor config avaiable failed";
     }
   }
+
   CursorModule_Finalize();
+  mouse_initialize = true;
 }
 
 // static
@@ -1568,6 +1586,7 @@ void WRTNativeWindowTV::LowerWindow() {
 }
 
 void WRTNativeWindowTV::Focus(bool focus) {
+  CreateMouseCursor(view_evas());
   if (!is_main_native_window_)
     return;