ecore_wl2_window: add code to handle pending min/max size 77/302777/1 accepted/tizen/unified/20231214.164940
authorDoyoun Kang <doyoun.kang@samsung.com>
Wed, 13 Dec 2023 09:33:51 +0000 (18:33 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 13 Dec 2023 09:34:03 +0000 (18:34 +0900)
There was a bug that the minimum or maximum size didn't work when the user calls
ecore_wl2_window_minimum_size_set() before calling ecore_wl2_window_show().

So, we add a pending min/max size to resolve this issue.
If the xdg_toplevel or zxdg_toplevel is not created, then we save the min/max size.
And then, after creating zxdg_toplevel, we apply the pended min/max size to the window.

Change-Id: I2c9404db18f13afabd7c51e6d15935bd230e27a9

src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index cdb8e87..28167c4 100644 (file)
@@ -381,6 +381,14 @@ struct _Ecore_Wl2_Window
      {
         int configure_event;
         int user_w, user_h;
+        struct
+          {
+             int w, h;
+          } min_size;
+        struct
+          {
+             int w, h;
+          } max_size;
         Eina_Bool configure : 1;
         Eina_Bool min : 1;
         Eina_Bool max : 1;
index 66108ac..b651d9b 100644 (file)
@@ -2425,15 +2425,23 @@ ecore_wl2_window_minimum_size_set(Ecore_Wl2_Window *window, int w, int h)
    if (window->zxdg_set_min_size && window->zxdg_toplevel)
      {
         window->zxdg_set_min_size(window->zxdg_toplevel, w, h);
+        window->pending.min_size.w = 0;
+        window->pending.min_size.h = 0;
         window->pending.min = 0;
         return;
      }
    if (window->xdg_set_min_size && window->xdg_toplevel)
      {
         window->xdg_set_min_size(window->xdg_toplevel, w, h);
+        window->pending.min_size.w = 0;
+        window->pending.min_size.h = 0;
         window->pending.min = 0;
         return;
      }
+
+   window->pending.min_size.w = w;
+   window->pending.min_size.h = h;
+   window->pending.min = EINA_TRUE;
 }
 
 EAPI void
@@ -2444,15 +2452,23 @@ ecore_wl2_window_maximum_size_set(Ecore_Wl2_Window *window, int w, int h)
    if (window->zxdg_set_max_size && window->zxdg_toplevel)
      {
         window->zxdg_set_max_size(window->zxdg_toplevel, w, h);
+        window->pending.max_size.w = 0;
+        window->pending.max_size.h = 0;
         window->pending.max = 0;
         return;
      }
    if (window->xdg_set_max_size && window->xdg_toplevel)
      {
         window->xdg_set_max_size(window->xdg_toplevel, w, h);
+        window->pending.max_size.w = 0;
+        window->pending.max_size.h = 0;
         window->pending.max = 0;
         return;
      }
+
+   window->pending.max_size.w = w;
+   window->pending.max_size.h = h;
+   window->pending.max = EINA_TRUE;
 }
 //
 
@@ -3892,6 +3908,13 @@ ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush)
              window->callback = wl_surface_frame(window->surface);
              wl_callback_add_listener(window->callback, &_frame_listener, window);
           }
+
+        if (window->pending.min)
+          ecore_wl2_window_minimum_size_set(window, window->pending.min_size.w, window->pending.min_size.h);
+
+        if (window->pending.max)
+          ecore_wl2_window_minimum_size_set(window, window->pending.max_size.w, window->pending.max_size.h);
+
         /* Dispatch any state we've been saving along the way */
         if (window->pending.geom)
           {