xdg_shell_v6: Do not send same-as-current configure 00/300400/1 accepted/tizen/unified/20231024.112216 accepted/tizen/unified/20231128.175116
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 19 Oct 2023 08:49:03 +0000 (17:49 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 24 Oct 2023 01:16:00 +0000 (10:16 +0900)
Sending same-as-current configure is unnecessary.

Change-Id: I0d3867c866f93e8320a22c774c36edbfd4620de3

src/xdg_shell_v6/xdg_shell_v6.h
src/xdg_shell_v6/xdg_surface_v6.c
src/xdg_shell_v6/xdg_toplevel_v6.c

index 51a0fe1..45c2770 100644 (file)
@@ -58,6 +58,11 @@ void reset_xdg_toplevel_v6(struct ds_xdg_toplevel_v6 *toplevel);
 
 void destroy_xdg_toplevel_v6(struct ds_xdg_toplevel_v6 *toplevel);
 
+bool xdg_toplevel_v6_scheduled_state_compare(struct ds_xdg_toplevel_v6 *toplevel);
+
+void xdg_toplevel_v6_handle_ack_configure(struct ds_xdg_toplevel_v6 *toplevel,
+        struct ds_xdg_toplevel_v6_configure *configure);
+
 void create_xdg_positioner_v6(struct ds_xdg_client_v6 *client, uint32_t id);
 
 struct ds_xdg_popup_v6 *create_xdg_popup_v6(struct ds_xdg_surface_v6 *surface,
index 9511c8a..4c04d29 100644 (file)
@@ -210,11 +210,35 @@ ds_xdg_surface_v6_schedule_configure(struct ds_xdg_surface_v6 *surface)
 {
     struct wl_display *display;
     struct wl_event_loop *loop;
+    bool scheduled_same = false;
 
     display = wl_client_get_display(surface->client->wl_client);
     loop = wl_display_get_event_loop(display);
 
-    if (!surface->configure_idle) {
+    switch (surface->role) {
+        case DS_XDG_SURFACE_V6_ROLE_TOPLEVEL:
+            scheduled_same =
+                xdg_toplevel_v6_scheduled_state_compare(surface->toplevel);
+            break;
+        case DS_XDG_SURFACE_V6_ROLE_POPUP:
+            break;
+        default:
+        case DS_XDG_SURFACE_V6_ROLE_NONE:
+            DS_ASSERT_NOT_REACHED();
+            break;
+    }
+
+    if (surface->configure_idle != NULL) {
+        if (!scheduled_same)
+            goto end;
+
+        wl_event_source_remove(surface->configure_idle);
+        surface->configure_idle = NULL;
+    }
+    else {
+        if (scheduled_same)
+            goto end;
+
         surface->scheduled_serial = wl_display_next_serial(display);
         surface->configure_idle = wl_event_loop_add_idle(loop,
                 surface_send_configure, surface);
@@ -222,6 +246,7 @@ ds_xdg_surface_v6_schedule_configure(struct ds_xdg_surface_v6 *surface)
             wl_client_post_no_memory(surface->client->wl_client);
     }
 
+end:
     return surface->scheduled_serial;
 }
 
@@ -411,7 +436,8 @@ xdg_surface_v6_handle_ack_configure(struct wl_client *client,
 
     switch (surface->role) {
         case DS_XDG_SURFACE_V6_ROLE_TOPLEVEL:
-            // TODO
+            xdg_toplevel_v6_handle_ack_configure(surface->toplevel,
+                    configure->toplevel_configure);
             break;
         case DS_XDG_SURFACE_V6_ROLE_POPUP:
             break;
index 15b1290..5fb7b0a 100644 (file)
@@ -259,6 +259,60 @@ reset_xdg_toplevel_v6(struct ds_xdg_toplevel_v6 *toplevel)
     toplevel->sent_initial_configure = false;
 }
 
+void
+xdg_toplevel_v6_handle_ack_configure(struct ds_xdg_toplevel_v6 *toplevel,
+        struct ds_xdg_toplevel_v6_configure *configure)
+{
+    toplevel->pending.maximized = configure->maximized;
+    toplevel->pending.fullscreen = configure->fullscreen;
+    toplevel->pending.resizing = configure->resizing;
+    toplevel->pending.activated = configure->activated;
+    toplevel->pending.width = configure->width;
+    toplevel->pending.height = configure->height;
+}
+
+bool
+xdg_toplevel_v6_scheduled_state_compare(struct ds_xdg_toplevel_v6 *toplevel)
+{
+    struct ds_xdg_surface_v6_configure *configure;
+    struct ds_xdg_toplevel_v6_state configured;
+
+    if (!toplevel->sent_initial_configure)
+        return false;
+
+    if (wl_list_empty(&toplevel->base->configure_list)) {
+        configured = toplevel->current;
+    }
+    else {
+        configure = wl_container_of(toplevel->base->configure_list.prev,
+                configure, link);
+        configured.maximized = configure->toplevel_configure->maximized;
+        configured.fullscreen = configure->toplevel_configure->fullscreen ;
+        configured.resizing = configure->toplevel_configure->resizing ;
+        configured.activated = configure->toplevel_configure->activated ;
+        configured.width = configure->toplevel_configure->width;
+        configured.height = configure->toplevel_configure->height;
+    }
+
+    if (toplevel->scheduled.activated != configured.activated)
+        return false;
+    if (toplevel->scheduled.fullscreen != configured.fullscreen)
+        return false;
+    if (toplevel->scheduled.maximized != configured.maximized)
+        return false;
+    if (toplevel->scheduled.resizing != configured.resizing)
+        return false;
+
+    if (toplevel->scheduled.width == configured.width &&
+            toplevel->scheduled.height == configured.height)
+        return true;
+
+    if (toplevel->scheduled.width == 0 && toplevel->scheduled.height == 0)
+        return true;
+
+    return false;
+}
+
 static void
 xdg_toplevel_v6_handle_destroy(struct wl_client *client,
         struct wl_resource *resource)