[M130 Migration][VD] Mouse cursor and select picker implementation 98/324798/2
authorrabarquez <r.abarquez@samsung.com>
Fri, 23 May 2025 13:29:29 +0000 (13:29 +0000)
committerBot Blink <blinkbot@samsung.com>
Wed, 28 May 2025 08:51:21 +0000 (08:51 +0000)
1. Create mouse cursor for popup windows
  With commit 568a72a, popups (JS dialogs, pickers etc.) are shown on
  new elm window. Since new elm window is created for every popup show,
  the cursor created for container window will not work on this new window.

2. Enable SelectPicker for Onscreen Rendering Mode.
  In Onscreen mode, Select picker is not seen on top window,
  so creating new window and adding layout on top of it.

Migrated from:
https://archive.tizen.org/gerrit/313283/
https://archive.tizen.org/gerrit/312107/

Change-Id: I0f5d66fa57b86c3eb4dc41cb429efe5c3024a567
Signed-off-by: rabarquez <r.abarquez@samsung.com>
tizen_src/chromium_impl/content/browser/browser_efl.gni
tizen_src/chromium_impl/content/browser/cursor/cursor_util.cc [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/cursor/cursor_util.h [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/input_picker/input_picker_base.cc
tizen_src/chromium_impl/content/browser/javascript_dialog/javascript_modal_dialog.cc
tizen_src/chromium_impl/content/browser/select_picker/select_picker_base.cc
tizen_src/chromium_impl/content/browser/select_picker/select_picker_base.h
tizen_src/chromium_impl/content/browser/select_picker/select_picker_tv_base.cc

index b0257962542f84bb048902356eb448a79a733aa5..659d4b1ed54db0fd480e136d4bd847e6c98513b4 100644 (file)
@@ -88,6 +88,8 @@ if (enable_wrt_js) {
 external_content_browser_efl_sources = [
   "//tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc",
   "//tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.h",
+  "//tizen_src/chromium_impl/content/browser/cursor/cursor_util.cc",
+  "//tizen_src/chromium_impl/content/browser/cursor/cursor_util.h",
   "//tizen_src/chromium_impl/content/browser/date_time_chooser_efl.cc",
   "//tizen_src/chromium_impl/content/browser/date_time_chooser_efl.h",
   "//tizen_src/chromium_impl/content/browser/input_picker/input_picker_base.cc",
diff --git a/tizen_src/chromium_impl/content/browser/cursor/cursor_util.cc b/tizen_src/chromium_impl/content/browser/cursor/cursor_util.cc
new file mode 100644 (file)
index 0000000..4ed5c02
--- /dev/null
@@ -0,0 +1,49 @@
+#include "cursor_util.h"
+
+#include "base/compiler_specific.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <cursor_module.h>
+#include "base/logging.h"
+#include "efl/ecore_x_wayland_wrapper.h"
+#endif
+
+namespace content {
+namespace cursor_util {
+
+void CreateMouseCursorForPopupWindow(Evas_Object* window) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << "Creating mouse cursor for elm window : " << window;
+  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!";
+      }
+    }
+  }
+  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!";
+  }
+  CursorModule_Finalize();
+#endif
+}
+
+}  // namespace cursor_util
+}  // namespace content
\ No newline at end of file
diff --git a/tizen_src/chromium_impl/content/browser/cursor/cursor_util.h b/tizen_src/chromium_impl/content/browser/cursor/cursor_util.h
new file mode 100644 (file)
index 0000000..c4569a2
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef CURSOR_UTIL_H
+#define CURSOR_UTIL_H
+
+#include <Evas.h>
+
+namespace content {
+namespace cursor_util {
+
+void CreateMouseCursorForPopupWindow(Evas_Object* window);
+
+}  // namespace cursor_util
+}  // namespace content
+
+#endif
\ No newline at end of file
index 9b1a68e18829a9638608eea9e0f35fb30b528805..aa89eaea6ebe2657ee7d877236b6a71691f3cb75 100644 (file)
@@ -12,6 +12,7 @@
 #include "base/files/file_path.h"
 #include "base/logging.h"
 #include "base/path_service.h"
+#include "content/browser/cursor/cursor_util.h"
 #include "content/browser/date_time_chooser_efl.h"
 #include "content/public/browser/web_contents.h"
 #include "tizen/system_info.h"
@@ -92,6 +93,7 @@ InputPickerBase::Layout::CreateAndShowColorPickerLayout(InputPickerBase* parent,
 
   picker_layout->AddColorPickerCallbacks();
   evas_object_show(picker_layout->popup_);
+  cursor_util::CreateMouseCursorForPopupWindow(picker_layout->window_);
   return picker_layout.release();
 }
 
index 6e7558390addbf47faa76da4eb382270750f26b0..fb0aab265a8cafb66b230f0b5fba16f968211ba8 100644 (file)
@@ -11,6 +11,7 @@
 #include "base/files/file_path.h"
 #include "base/path_service.h"
 #include "base/strings/utf_string_conversions.h"
+#include "content/browser/cursor/cursor_util.h"
 #include "content/public/browser/web_contents.h"
 #include "tizen_src/chromium_impl/tizen/system_info.h"
 #include "ui/display/device_display_info_efl.h"
@@ -124,7 +125,7 @@ bool JavaScriptModalDialog::ShowJavaScriptDialog() {
   evas_object_show(popup_);
 
   is_showing_ = true;
-
+  cursor_util::CreateMouseCursorForPopupWindow(window_);
   return true;
 }
 
index b963ee5d5ec1962eeea6a76ea6ed9573e6b366d5..4db67fe0316ab971d945c70a68f16540e48ef6fe 100644 (file)
@@ -4,10 +4,14 @@
 
 #include "content/browser/select_picker/select_picker_base.h"
 
+#include "base/base_switches.h"
+#include "base/command_line.h"
 #include "base/strings/utf_string_conversions.h"
+#include "content/browser/cursor/cursor_util.h"
 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
 #include "content/browser/select_picker/select_picker_util.h"
 #include "content/browser/web_contents/web_contents_view_aura.h"
+#include "ui/display/device_display_info_efl.h"
 #if BUILDFLAG(IS_TIZEN)
 #include "tizen/system_info.h"
 #endif
@@ -55,10 +59,13 @@ SelectPickerBase::SelectPickerBase(Evas_Object* ewk_view,
       item_class_(nullptr),
       scrollto_type_(scrollto_type),
       group_class_(nullptr) {
-  auto* parent = elm_object_parent_widget_get(ewk_view_);
-  window_ = elm_object_top_widget_get(parent ? parent : ewk_view_);
-  layout_ = elm_layout_add(window_);
-  evas_object_layer_set(layout_, evas_object_layer_get(ewk_view_));
+  Evas_Object* parent = elm_object_parent_widget_get(ewk_view_);
+  top_window_ = parent ? elm_object_top_widget_get(parent)
+                       : elm_object_top_widget_get(ewk_view_);
+
+  // For onscreen, the popup has to be created on new elm window.
+  // Whereas for offscreen, its added on top of current elm window.
+  layout_ = elm_layout_add(GetContainerWindow());
 }
 
 SelectPickerBase::~SelectPickerBase() {
@@ -66,6 +73,54 @@ SelectPickerBase::~SelectPickerBase() {
   elm_genlist_item_class_free(group_class_);
   elm_genlist_item_class_free(item_class_);
   evas_object_del(layout_);
+  if (window_) {
+    evas_object_del(window_);
+    window_ = nullptr;
+  }
+}
+
+Evas_Object* SelectPickerBase::GetContainerWindow() {
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering)) {
+    return top_window_;
+  } else {
+    window_ = CreateNewWindow();
+    return window_;
+  }
+}
+
+Evas_Object* SelectPickerBase::CreateNewWindow() {
+  Evas_Object* window =
+      elm_win_add(top_window_, "SelectPicker", ELM_WIN_UTILITY);
+  if (!window) {
+    return nullptr;
+  }
+
+  elm_win_alpha_set(window, EINA_TRUE);
+
+  if (elm_win_indicator_mode_get(top_window_) == ELM_WIN_INDICATOR_SHOW) {
+    elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+  }
+
+  if (elm_win_indicator_opacity_get(top_window_) ==
+      ELM_WIN_INDICATOR_TRANSPARENT) {
+    elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_TRANSPARENT);
+  }
+
+  if (elm_win_wm_rotation_supported_get(top_window_)) {
+    int rots[] = {0, 90, 180, 270};
+    elm_win_wm_rotation_available_rotations_set(window, rots, 4);
+  }
+
+  display::DeviceDisplayInfoEfl display_info;
+  evas_object_resize(window, display_info.GetDisplayWidth(),
+                     display_info.GetDisplayHeight());
+
+  elm_win_conformant_set(window, EINA_TRUE);
+  evas_object_show(window);
+  content::cursor_util::CreateMouseCursorForPopupWindow(window);
+
+  return window;
 }
 
 void SelectPickerBase::InitializeItemClass() {
index 7598ae25ff774a90d972a2923be477d910ca33a8..99b5c177d16f1928e83ef37524bdb1c5c5caa27e 100644 (file)
@@ -72,9 +72,10 @@ class SelectPickerBase {
 #endif
 
   Evas_Object* ewk_view_;
+  Evas_Object* top_window_ = nullptr;
   Evas_Object* popup_list_;
   Evas_Object* layout_;
-  Evas_Object* window_;
+  Evas_Object* window_ = nullptr;
   int selected_index_;
   bool is_multiple_selection_;
   Elm_Genlist_Item_Class* item_class_ = nullptr;
@@ -86,6 +87,8 @@ class SelectPickerBase {
   static void MenuItemDeactivatedCallback(void*, Evas_Object*, void*);
   static void Resize(void* data, Evas* e, Evas_Object* obj, void* event_info);
 
+  Evas_Object* GetContainerWindow();
+  Evas_Object* CreateNewWindow();
   void DestroyPopupList();
 
   Elm_Genlist_Item_Class* group_class_ = nullptr;
index 2d8459f58d0b6802baa50dd7d6105f04af0cf280..7b2b709570a600ffc5c09e7d1fedf8676da1b54e 100644 (file)
@@ -7,6 +7,8 @@
 #include <Elementary.h>
 #include "efl/ecore_x_wayland_wrapper.h"
 
+#include "base/base_switches.h"
+#include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/path_service.h"
 #include "base/base_paths_efl.h"
@@ -250,7 +252,14 @@ void SelectPickerTvBase::CoordinatePopupPositionAndSize(const gfx::Rect& bounds,
     }
   }
 
-  evas_object_move(layout_, target_x, target_y);
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering)) {
+    evas_object_move(layout_, target_x, target_y);
+  } else {
+    evas_object_resize(window_, select_width, select_height);
+    evas_object_move(window_, target_x, target_y);
+  }
+
 #if BUILDFLAG(IS_TIZEN_TV)
   SetPopupMenuBounds(
       gfx::Rect(target_x, target_y, select_width, select_height));