e_policy_wl: calculate aspect ratio including header and footer height 26/283726/1
authorJunseok Kim <juns.kim@samsung.com>
Thu, 6 Oct 2022 03:10:45 +0000 (12:10 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 2 Nov 2022 07:53:58 +0000 (16:53 +0900)
There is a windows that have their own decorator that header and footer.
And the window need to resize using aspect ratio to the content except the fixed decorator size.

for those windows, added aux hint to set their header and footer height and adjusted to calculate aspect ratio resize.
When the client sets the aux hint, then the enlightenment calculates aspect ratio without header and footer height.

aux hint keys:
wm.policy.win.resize.header_height
wm.policy.win.resize.footer_height

aux hint values:
unsigned integer

Change-Id: I033c73197951c975145d2ecaa00bdc96e4e8f798

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_policy_wl.c

index 8ec0f4bf9a92967e84719738d1efa5095245d669..b8902a6e74b52ffed231cbba546202d02cd9a528 100644 (file)
@@ -1917,6 +1917,8 @@ _e_client_resize_handle(E_Client *ec)
           {
              new_w = (int) ec->manage_resize.aw / ec->manage_resize.ah * new_h;
           }
+          new_h += ec->manage_resize.header_h;
+          new_h += ec->manage_resize.footer_h;
      }
 
    if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
@@ -4707,6 +4709,8 @@ e_client_new(E_Pixmap *cp, int first_map, int internal)
    ec->manage_resize.x = ec->manage_resize.y = ec->manage_resize.w = ec->manage_resize.h = 0;
    ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
    ec->manage_resize.aw = ec->manage_resize.ah = 0;
+   ec->manage_resize.header_h = 0;
+   ec->manage_resize.footer_h = 0;
 
    return ec;
 }
@@ -7021,7 +7025,7 @@ e_client_resize_begin(E_Client *ec)
      {
         ELOGF("RESIZE", "Set resize aspect ratio.. ratio(%dx%d)", ec, ec->w, ec->h);
         ec->manage_resize.aw = ec->w;
-        ec->manage_resize.ah = ec->h;
+        ec->manage_resize.ah = ec->h - ec->manage_resize.header_h - ec->manage_resize.footer_h;
      }
    _e_client_hook_call(E_CLIENT_HOOK_RESIZE_BEGIN, ec);
    if (ec->transformed)
index 425604ee2930dd2ffc468042c8b78cb732168258..80e6eec03f6ebf18d1211d65c18d5e5490db4d60 100644 (file)
@@ -1044,6 +1044,7 @@ struct E_Client
       Eina_Bool enable_aspect_ratio;
       Evas_Object *resize_obj;
       float aw, ah;
+      int header_h, footer_h;
    } manage_resize;
 
    Eina_Bool move_after_resize;
index 0638491cc62b66e322046a600fecb4085a70f1b2..5d5de3ca7296e241c40e79cf1c908bed7ec8f1f6 100644 (file)
@@ -276,6 +276,8 @@ enum _E_Policy_Hint_Type
    E_POLICY_HINT_TRANSIENT_FOR_ALWAYS_ON_TOP = 12,
    E_POLICY_HINT_BELONG_TO_PARENT = 13,
    E_POLICY_HINT_RESIZE_ASPECT_RATIO = 14,
+   E_POLICY_HINT_RESIZE_HEADER_HEIGHT = 15,
+   E_POLICY_HINT_RESIZE_FOOTER_HEIGHT = 16,
 };
 
 static const char *hint_names[] =
@@ -295,6 +297,8 @@ static const char *hint_names[] =
    "wm.policy.win.transient_for.always_on_top",
    "wm.policy.win.belong_to_parent",
    "wm.policy.win.resize_aspect_ratio",
+   "wm.policy.win.resize.header_height",
+   "wm.policy.win.resize.footer_height",
 };
 
 static void                _e_policy_wl_surf_del(E_Policy_Wl_Surface *psurf);
@@ -2549,6 +2553,34 @@ _e_policy_wl_aux_hint_apply(E_Client *ec)
                   ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
                }
           }
+        else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_HEADER_HEIGHT], strlen(hint->hint)))
+          {
+             int height = atoi(hint->val);
+             if (height > 0)
+               {
+                  ELOGF("RESIZE", "Set resize HEADER height.. h(%d)", ec, height);
+                  ec->manage_resize.header_h = height;
+               }
+             else
+               {
+                  ELOGF("RESIZE", "Unset resize HEADER height", ec);
+                  ec->manage_resize.header_h = 0;
+               }
+          }
+        else if (!strncmp(hint->hint, hint_names[E_POLICY_HINT_RESIZE_FOOTER_HEIGHT], strlen(hint->hint)))
+          {
+             int height = atoi(hint->val);
+             if (height > 0)
+               {
+                  ELOGF("RESIZE", "Set resize FOOTER height.. h(%d)", ec, height);
+                  ec->manage_resize.footer_h = height;
+               }
+             else
+               {
+                  ELOGF("RESIZE", "Unset resize FOOTER height", ec);
+                  ec->manage_resize.footer_h = 0;
+               }
+          }
      }
 
    e_policy_hook_call(E_POLICY_HOOK_CLIENT_AUX_HINT_CHANGED, ec);