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.
This commit is contained in:
Jonas Ådahl 2020-11-23 16:39:11 +01:00
parent 23d7392eb9
commit f4c36fe1ce
2 changed files with 41 additions and 1 deletions

View File

@ -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)
{

View File

@ -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__ */