e_client/policy: add e_client_layout_set and change code to use this 65/315365/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 25 Jul 2024 06:44:35 +0000 (15:44 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 31 Jul 2024 02:20:02 +0000 (11:20 +0900)
Change-Id: Idd4f5deae80d883be68664ee9a3eea2db86672da

src/bin/core/e_client.c
src/bin/core/e_client_intern.h
src/bin/server/e_policy_wl.c

index be4f3a8..4311e79 100644 (file)
@@ -4183,6 +4183,58 @@ e_client_unmaximize(E_Client *ec, E_Maximize max)
 }
 
 EINTERN void
+e_client_layout_set(E_Client *ec, uint32_t num_cols, uint32_t num_rows, uint32_t column_id, uint32_t row_id, uint32_t col_span, uint32_t row_span)
+{
+   E_OBJECT_CHECK(ec);
+   E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
+
+   /*
+      num_cols:  total number of columns
+      num_rows:  total number of rows
+      column_id: column index to be placed
+      row_id:    row index to be placed
+      col_span:  the number of column span to be occupied
+      row_span:  the number of row span to be occupied
+   */
+
+   E_Desk *desk;
+   unsigned int unit_w, unit_h;
+   int x, y;
+   unsigned int w, h;
+
+   desk = e_comp_desk_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(desk);
+
+   unit_w = desk->geom.w / num_cols;
+   unit_h = desk->geom.h / num_rows;
+
+   x = unit_w * column_id;
+   y = unit_h * row_id;
+   w = unit_w * col_span;
+   h = unit_h * row_span;
+
+   // TODO: We may need to adjust the last size if the unit size is not divided exactly
+
+   ELOGF("TZPOL", "LAYOUT SET... total_layout(%d,%d) -> unit_size(%dx%d). request(%d,%d,%d,%d) -> geo(%d,%d,%dx%d)",
+         ec, num_cols, num_rows, unit_w, unit_h, column_id, row_id, col_span, row_span, x, y, w, h);
+
+   // Apply shadow size (left, right, top, bottom)
+   x -= ec->manage_resize.shadow.l;
+   y -= ec->manage_resize.shadow.t;
+   w = w + ec->manage_resize.shadow.l + ec->manage_resize.shadow.r;
+   h = h + ec->manage_resize.shadow.t + ec->manage_resize.shadow.b;
+
+   ELOGF("TZPOL", "Consider Shadow size(l:%d,r:%d,t:%d,b:%d). new (%d,%d,%dx%d)",
+         ec, ec->manage_resize.shadow.l, ec->manage_resize.shadow.r, ec->manage_resize.shadow.t, ec->manage_resize.shadow.b, x, y, w, h);
+
+   e_client_layout_apply(ec, EINA_TRUE);
+   e_client_frame_geometry_set(ec, x, y, w, h);
+
+   if (!ec->visible)
+     e_client_shell_configure_send(ec, 0, w, h);
+}
+
+EINTERN void
 e_client_fullscreen(E_Client *ec, E_Fullscreen policy)
 {
    E_OBJECT_CHECK(ec);
index b950e42..6024065 100644 (file)
@@ -35,6 +35,7 @@ EINTERN void          e_client_idler_before(Eina_Bool *check_focus);
 EINTERN unsigned int  e_clients_count(void);
 EINTERN void          e_client_activate(E_Client *ec);
 EINTERN Eina_List    *e_client_lost_windows_get(E_Zone *zone);
+EINTERN void          e_client_layout_set(E_Client *ec, uint32_t num_cols, uint32_t num_rows, uint32_t column_id, uint32_t row_id, uint32_t col_span, uint32_t row_span);
 EINTERN void          e_client_fullscreen(E_Client *ec, E_Fullscreen policy);
 EINTERN void          e_client_unfullscreen(E_Client *ec);
 EINTERN void          e_client_stick(E_Client *ec);
index f3c36aa..c5094a6 100644 (file)
@@ -3709,43 +3709,14 @@ static void
 _tzpol_iface_cb_set_layout(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf, uint32_t num_cols, uint32_t num_rows, uint32_t column, uint32_t row, uint32_t col_span, uint32_t row_span)
 {
    E_Client *ec;
-   E_Desk *desk;
 
-   int unit_w, unit_h;
-   int x, y, w, h;
    ec = e_client_from_surface_resource(surf);
    if (!ec) return;
 
-   desk = e_comp_desk_find_by_ec(ec);
-   EINA_SAFETY_ON_NULL_RETURN(desk);
-
-   unit_w = desk->geom.w / num_cols;
-   unit_h = desk->geom.h / num_rows;
-
-   x = unit_w * column;
-   y = unit_h * row;
-   w = unit_w * col_span;
-   h = unit_h * row_span;
-
-   // TODO: We may need to adjust the last size if the unit size is not devided exactly
-
-   ELOGF("TZPOL", "TIZEN_POLICY_SET_LAYOUT... total_layout(%d,%d) -> unit_size(%dx%d). request(%d,%d,%d,%d) -> geo(%d,%d,%dx%d)",
-         ec, num_cols, num_rows, unit_w, unit_h, column, row, col_span, row_span, x, y, w, h);
-
-   // Apply shadow size (left, right, top, bottom)
-   x -= ec->manage_resize.shadow.l;
-   y -= ec->manage_resize.shadow.t;
-   w = w + ec->manage_resize.shadow.l + ec->manage_resize.shadow.r;
-   h = h + ec->manage_resize.shadow.t + ec->manage_resize.shadow.b;
-
-   ELOGF("TZPOL", "Consider Shadow size(l:%d,r:%d,t:%d,b:%d). new (%d,%d,%dx%d)",
-         ec, ec->manage_resize.shadow.l, ec->manage_resize.shadow.r, ec->manage_resize.shadow.t, ec->manage_resize.shadow.b, x, y, w, h);
-
-   e_client_layout_apply(ec, EINA_TRUE);
-   e_client_frame_geometry_set(ec, x, y, w, h);
+   ELOGF("TZPOL", "TIZEN_POLICY_SET_LAYOUT... total_layout(%d,%d), index(%d,%d), span(%d,%d)",
+         ec, num_cols, num_rows, column, row, col_span, row_span);
 
-   if (!ec->visible)
-     e_client_shell_configure_send(ec, 0, w, h);
+   e_client_layout_set(ec, num_cols, num_rows, column, row, col_span, row_span);
 }
 
 static void