e_client: support ppu for resizing window 70/286570/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 10 Jan 2023 01:48:23 +0000 (10:48 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 10 Jan 2023 04:17:48 +0000 (13:17 +0900)
We add a new feature that the window is resized based on the ppu.
If a user sets the ppu value to window and requests to resize window by display server,
e adjusts the window's size according to the ppu value.

Change-Id: Idb7c3d77b9760ca60c4a3d57028af7e53ddb15bd

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_info_client.c
src/bin/e_info_server.c

index 926c1978ef1e62e1e9ff7b7cd2cb25eb551f9cde..43d09c4628143e07503d582d950c8a36d3fda560 100644 (file)
@@ -1980,6 +1980,49 @@ _e_client_resize_handle(E_Client *ec)
      }
 }
 
+static int
+_e_client_adjust_size_by_ppu(int size, int start_size, unsigned int ppu)
+{
+   if (ppu <= 1) return size;
+
+   unsigned int remainder = size % ppu;
+   if (remainder == 0) return size;
+
+   int gap = size - start_size;
+   int new_size = size;
+   if (gap > 0)
+     new_size = size + remainder;
+   else
+     new_size = size - remainder;
+
+   return new_size;
+}
+
+static int
+_e_client_adjust_position_by_ppu(int pos, int size, int prev_pos, int prev_size)
+{
+   int new_pos = 0;
+
+   if (prev_pos == pos)
+     new_pos = pos;
+   else
+     new_pos = (prev_pos + prev_size) - size;
+
+   return new_pos;
+}
+
+static void
+_e_client_adjust_geometry_by_resize_ppu(E_Client *ec)
+{
+   if (ec->manage_resize.unit_size <= 1) return;
+
+   ec->manage_resize.w = _e_client_adjust_size_by_ppu(ec->manage_resize.w, ec->w, ec->manage_resize.unit_size);
+   ec->manage_resize.h = _e_client_adjust_size_by_ppu(ec->manage_resize.h, ec->h, ec->manage_resize.unit_size);
+
+   ec->manage_resize.x = _e_client_adjust_position_by_ppu(ec->manage_resize.x, ec->manage_resize.w, ec->x, ec->w);
+   ec->manage_resize.y = _e_client_adjust_position_by_ppu(ec->manage_resize.y, ec->manage_resize.h, ec->y, ec->h);
+}
+
 static int
 _e_client_resize_end(E_Client *ec)
 {
@@ -2006,6 +2049,9 @@ _e_client_resize_end(E_Client *ec)
      {
         if (ec->manage_resize.resize_obj)
           {
+             if (ec->manage_resize.unit_size > 1)
+               _e_client_adjust_geometry_by_resize_ppu(ec);
+
              e_client_frame_geometry_set(ec,
                                          ec->manage_resize.x,
                                          ec->manage_resize.y,
@@ -8962,6 +9008,15 @@ e_client_resize_object_create_cb_set(E_Client_Resize_Object_Create_Cb cb)
    _e_client_resize_object_create_cb = cb;
 }
 
+E_API void
+e_client_resize_unit_size_set(E_Client *ec, unsigned int unit_size)
+{
+   if (!ec) return;
+
+   // FYI, we consider 0 and 1 to be the same value as a default unit size.
+   ec->manage_resize.unit_size = unit_size;
+}
+
 EINTERN void
 e_client_desk_zoom_enable_set(E_Client *ec, Eina_Bool enable)
 {
index c21a11f9a59f6aea689510a627c8a04b4e94631d..bd442002ce335e0b133b838f6647de6858adb0a6 100644 (file)
@@ -1054,6 +1054,7 @@ struct E_Client
       Evas_Object *resize_obj;
       float aw, ah;
       int header_h, footer_h;
+      unsigned int unit_size;
    } manage_resize;
 
    Eina_Bool move_after_resize;
@@ -1332,6 +1333,7 @@ E_API void e_client_transient_policy_set(E_Client *ec, E_Transient policy);
 E_API E_Transient e_client_transient_policy_get(E_Client *ec);
 
 E_API void e_client_resize_object_create_cb_set(E_Client_Resize_Object_Create_Cb cb);
+E_API void e_client_resize_unit_size_set(E_Client *ec, unsigned int unit_size);
 
 EINTERN void e_client_desk_zoom_enable_set(E_Client *ec, Eina_Bool enable);
 EINTERN Eina_Bool e_client_desk_zoom_enable_get(E_Client *ec);
index 38a4aa3a4d1a2fe5aa7ce0e46f189ef32fe8f5b0..7ba0328937e98cee7a195c03b9ea1264685bf45e 100644 (file)
@@ -6668,6 +6668,26 @@ _e_info_client_proc_input_seat_set(int argc, char **argv)
      }
 }
 
+static void
+_e_info_client_proc_resize_ppu_set(int argc, char **argv)
+{
+   uint32_t ppu;
+
+   if (argc < 4)
+     {
+        printf("Error Check Args: enlightenment_info -resize_ppu window_ID value[0~32]\n");
+        return;
+     }
+
+   ppu = atoi(argv[3]);
+
+   if (!_e_info_client_eldbus_message_with_args("resize_ppu_set", NULL, "si", argv[2], ppu))
+     {
+        printf("_e_info_client_eldbus_message_with_args error");
+        return;
+     }
+}
+
 typedef struct _ProcInfo
 {
    const char *option;
@@ -7071,6 +7091,12 @@ static ProcInfo procs_to_execute[] =
       "Set input device's seat name",
       _e_info_client_proc_input_seat_set
    },
+   {
+      "resize_ppu",
+      "[windowID ppu_value]",
+      "Set resize ppu value",
+      _e_info_client_proc_resize_ppu_set
+   },
 };
 
 ProcInfo procs_to_input[] =
index 6149b390ef6a55f3d1fd90b9050d30ca42db6851..4f6166ab6b89f98a427476c52daba9449a2069c2 100644 (file)
@@ -7612,6 +7612,51 @@ _e_info_server_cb_input_seat_set(const Eldbus_Service_Interface *iface EINA_UNUS
    return reply;
 }
 
+static Eldbus_Message *
+e_info_server_cb_resize_ppu_set(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   unsigned long tmp = 0;
+   const char *win_id_str = NULL;
+   uint64_t win_id = 0;
+   Evas_Object *o = NULL;
+   E_Client *ec = NULL;
+   uint32_t ppu = 0;
+   Eina_Bool res = EINA_FALSE;
+
+   if (!eldbus_message_arguments_get(msg, "si", &win_id_str, &ppu))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (strlen(win_id_str) >= 2 && win_id_str[0] == '0' && win_id_str[1] == 'x')
+     res = e_util_string_to_ulong(win_id_str, &tmp, 16);
+   else
+     res = e_util_string_to_ulong(win_id_str, &tmp, 10);
+
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(res, reply);
+
+   win_id = (uint64_t)tmp;
+
+   for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+     {
+        ec = evas_object_data_get(o, "E_Client");
+        Ecore_Window win;
+
+        if (!ec) continue;
+
+        win = e_client_util_win_get(ec);
+        if (win != win_id) continue;
+
+        e_client_resize_unit_size_set(ec, ppu);
+
+        break;
+     }
+
+   return reply;
+}
+
 //{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
@@ -7715,6 +7760,7 @@ static const Eldbus_Method methods[] = {
    { "zone_set", ELDBUS_ARGS({"si", "zone set"}), NULL, _e_info_server_cb_zone_set, 0 },
    { "input_output_set", ELDBUS_ARGS({"ss", "set input device's output name"}), NULL, _e_info_server_cb_input_output_set, 0 },
    { "input_seat_set", ELDBUS_ARGS({"ss", "set input device's seat"}), NULL, _e_info_server_cb_input_seat_set, 0 },
+   { "resize_ppu_set", ELDBUS_ARGS({"si", "set resize ppu"}), NULL, e_info_server_cb_resize_ppu_set, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };