desktop_shell: Avoid redundant settings by caching previous values 13/323913/2
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 8 May 2025 12:06:43 +0000 (21:06 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 9 May 2025 04:31:27 +0000 (04:31 +0000)
If the same value is attempted to be set again, the functions will skip
the actual operation.

Change-Id: I18380c0828e2b98dc18930aca3c25f0ddad36945

src/bin/server/e_desktop_shell.c
src/bin/server/e_desktop_shell_private.h

index 4d88cc95f41e4932a9a11f90142d71d103bed09e..2239639b567fa24afe413eb34436a8e97b9940ab 100644 (file)
@@ -158,6 +158,11 @@ static void
 _surface_init(E_Desktop_Surface *surface, E_Surface *e_surface, E_Desktop_Surface_Interface *iface)
 {
    surface->iface = iface;
+   surface->x = 0;
+   surface->y = 0;
+   surface->width = 0;
+   surface->height = 0;
+   surface->mapped = false;
 
    surface->ec = e_surface_ec_get(e_surface);
    assert(surface->ec);
@@ -212,13 +217,26 @@ e_desktop_surface_configure_send(E_Desktop_Surface *surface, uint32_t edges, int
 EINTERN void
 e_desktop_surface_configure(E_Desktop_Surface *surface, int32_t x, int32_t y, int32_t width, int32_t height)
 {
+   if (surface->x == x && surface->y == y &&
+       surface->width == width && surface->height == height)
+     return;
+
    ELOGF("SURFACE", "Configure: %d,%d %dx%d", surface->ec, x, y, width, height);
+
+   surface->x = x;
+   surface->y = y;
+   surface->width = width;
+   surface->height = height;
+
    e_client_util_move_resize_without_frame(surface->ec, x, y, width, height);
 }
 
 EINTERN void
 e_desktop_surface_map(E_Desktop_Surface *surface)
 {
+   if (surface->mapped)
+     return;
+
    ELOGF("SURFACE", "Map", surface->ec);
    e_shell_e_client_map(surface->ec);
 }
@@ -226,6 +244,9 @@ e_desktop_surface_map(E_Desktop_Surface *surface)
 EINTERN void
 e_desktop_surface_unmap(E_Desktop_Surface *surface)
 {
+   if (!surface->mapped)
+     return;
+
    ELOGF("SURFACE", "Unmap", surface->ec);
    e_shell_e_client_unmap(surface->ec);
 }
index ea8e5d801d895a32dec1ae1d922f2a44dcb1ee1d..6e9ea8e5ea8c2e9387db3bf22f26154c4e4819e1 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef E_DESKTOP_SHELL_PRIVATE_H
 #define E_DESKTOP_SHELL_PRIVATE_H
 
+#include <stdbool.h>
+
 #include "e_desktop_shell_intern.h"
 
 typedef struct _E_Desktop_Surface_Interface E_Desktop_Surface_Interface;
@@ -16,7 +18,11 @@ struct _E_Desktop_Surface
    E_Desktop_Surface_Interface *iface;
    E_Client *ec;
 
+   int32_t x, y, width, height;
+
    struct wl_listener surface_destroy;
+
+   bool mapped;
 };
 
 struct _E_Desktop_Toplevel