[gtk/matthiasc/surface-state-rework: 7/80] gdk/surface: Add API to queue and apply state changes




commit 2204107063db49bba66903beab148df7a0b7f486
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Nov 23 16:39:11 2020 +0100

    gdk/surface: Add API to queue and apply state changes
    
    This will be used to compress state changes and apply as part of a frame
    clock dispatch.

 gdk/gdksurface.c        | 33 ++++++++++++++++++++++++++++++++-
 gdk/gdksurfaceprivate.h |  9 +++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 93e61d5c68..a64cbb0f94 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1670,7 +1670,11 @@ gdk_surface_hide (GdkSurface *surface)
   was_mapped = GDK_SURFACE_IS_MAPPED (surface);
 
   if (GDK_SURFACE_IS_MAPPED (surface))
-    gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_WITHDRAWN);
+    {
+      gdk_synthesize_surface_state (surface, 0, GDK_TOPLEVEL_STATE_WITHDRAWN);
+      surface->pending_unset_flags = 0;
+      surface->pending_set_flags = 0;
+    }
 
   if (was_mapped)
     {
@@ -2659,6 +2663,33 @@ gdk_synthesize_surface_state (GdkSurface       *surface,
   gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
 }
 
+void
+gdk_surface_queue_state_change (GdkSurface       *surface,
+                                GdkToplevelState  unset_flags,
+                                GdkToplevelState  set_flags)
+{
+  surface->pending_unset_flags |= unset_flags;
+  surface->pending_set_flags &= ~unset_flags;
+
+  surface->pending_set_flags |= set_flags;
+  surface->pending_unset_flags &= ~set_flags;
+}
+
+void
+gdk_surface_apply_state_change (GdkSurface *surface)
+{
+  if (!surface->pending_unset_flags && !surface->pending_set_flags)
+    return;
+
+  gdk_synthesize_surface_state (surface,
+                                surface->pending_unset_flags,
+                                surface->pending_set_flags);
+  if (surface->pending_unset_flags & GDK_TOPLEVEL_STATE_WITHDRAWN)
+    gdk_surface_invalidate_rect (surface, NULL);
+  surface->pending_unset_flags = 0;
+  surface->pending_set_flags = 0;
+}
+
 static gboolean
 check_autohide (GdkEvent *event)
 {
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index c3933e0437..5bc290493f 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -59,6 +59,8 @@ struct _GdkSurface
      more than we have to, but it represents the "true" damage. */
   cairo_region_t *active_update_area;
 
+  GdkToplevelState pending_set_flags;
+  GdkToplevelState pending_unset_flags;
   GdkToplevelState state;
 
   guint8 resize_count;
@@ -325,9 +327,16 @@ void       gdk_surface_constrain_size      (GdkGeometry    *geometry,
                                             int            *new_width,
                                             int            *new_height);
 
+void       gdk_surface_queue_state_change  (GdkSurface       *surface,
+                                            GdkToplevelState  unset_flags,
+                                            GdkToplevelState  set_flags);
+
+void       gdk_surface_apply_state_change  (GdkSurface       *surface);
+
 GDK_AVAILABLE_IN_ALL
 void           gdk_surface_request_motion (GdkSurface *surface);
 
+
 G_END_DECLS
 
 #endif /* __GDK_SURFACE_PRIVATE_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]