summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-17 18:49:31 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-09-17 18:49:31 +0000
commitf2f0a9ee0ee94b952de339b536a7a3812df213fb (patch)
treec72d0d7291bc4e473984759defc038f7c39b37bc
parent90991a341dc451eb3db2e85c93b59939a447661e (diff)
parent4200936f21d88bd8fc4a71f6a3b067fe3059f79b (diff)
downloadgtk+-f2f0a9ee0ee94b952de339b536a7a3812df213fb.tar.gz
Merge branch 'wip/wayland-respond-to-configure' into 'master'
Make sure to respond to configure events in time Closes #2910 See merge request GNOME/gtk!2588
-rw-r--r--gdk/wayland/gdkcairocontext-wayland.c6
-rw-r--r--gdk/wayland/gdkglcontext-wayland.c2
-rw-r--r--gdk/wayland/gdkprivate-wayland.h2
-rw-r--r--gdk/wayland/gdksurface-wayland.c57
-rw-r--r--gdk/wayland/gdkvulkancontext-wayland.c2
5 files changed, 34 insertions, 35 deletions
diff --git a/gdk/wayland/gdkcairocontext-wayland.c b/gdk/wayland/gdkcairocontext-wayland.c
index bb28ada46f..fcc547ecf6 100644
--- a/gdk/wayland/gdkcairocontext-wayland.c
+++ b/gdk/wayland/gdkcairocontext-wayland.c
@@ -23,6 +23,7 @@
#include "gdkprivate-wayland.h"
#include "gdkinternals.h"
+#include "gdkprofilerprivate.h"
static const cairo_user_data_key_t gdk_wayland_cairo_context_key;
static const cairo_user_data_key_t gdk_wayland_cairo_region_key;
@@ -180,6 +181,11 @@ gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_attach_image (surface, self->paint_surface, painted);
gdk_wayland_surface_sync (surface);
+ gdk_wayland_surface_request_frame (surface);
+
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
+ gdk_wayland_surface_commit (surface);
+ gdk_wayland_surface_notify_committed (surface);
gdk_wayland_cairo_context_surface_clear_region (self->paint_surface);
self->paint_surface = NULL;
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 8ed0bb1d49..a668731196 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -261,6 +261,8 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
}
else
eglSwapBuffers (display_wayland->egl_display, egl_surface);
+
+ gdk_wayland_surface_notify_committed (surface);
}
static void
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index dc7c4848a2..11c6cefed4 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -94,6 +94,8 @@ guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
guint *next_image_delay);
void gdk_wayland_surface_sync (GdkSurface *surface);
+void gdk_wayland_surface_commit (GdkSurface *surface);
+void gdk_wayland_surface_notify_committed (GdkSurface *surface);
void gdk_wayland_surface_request_frame (GdkSurface *surface);
void gdk_wayland_surface_attach_image (GdkSurface *surface,
cairo_surface_t *cairo_surface,
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 99af132356..aee98a2d48 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -45,14 +45,6 @@
#include <string.h>
#include <errno.h>
-enum {
- COMMITTED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
#define SURFACE_IS_TOPLEVEL(surface) TRUE
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
@@ -102,8 +94,8 @@ struct _GdkWaylandSurface
PopupState popup_state;
unsigned int initial_configure_received : 1;
+ unsigned int has_uncommitted_ack_configure : 1;
unsigned int mapped : 1;
- unsigned int pending_commit : 1;
unsigned int awaiting_frame : 1;
unsigned int awaiting_frame_frozen : 1;
unsigned int is_drag_surface : 1;
@@ -623,30 +615,32 @@ gdk_wayland_surface_request_frame (GdkSurface *surface)
impl->awaiting_frame = TRUE;
}
+void
+gdk_wayland_surface_commit (GdkSurface *surface)
+{
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+
+ wl_surface_commit (impl->display_server.wl_surface);
+}
+
+void
+gdk_wayland_surface_notify_committed (GdkSurface *surface)
+{
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+
+ impl->has_uncommitted_ack_configure = FALSE;
+}
+
static void
on_frame_clock_after_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
- if (impl->pending_commit && surface->update_freeze_count == 0)
+ if (surface->update_freeze_count == 0 && impl->has_uncommitted_ack_configure)
{
- gdk_wayland_surface_request_frame (surface);
-
- /* From this commit forward, we can't write to the buffer,
- * it's "live". In the future, if we need to stage more changes
- * we have to allocate a new staging buffer and draw to it instead.
- *
- * Our one saving grace is if the compositor releases the buffer
- * before we need to stage any changes, then we can take it back and
- * use it again.
- */
- gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
- wl_surface_commit (impl->display_server.wl_surface);
-
- impl->pending_commit = FALSE;
-
- g_signal_emit (impl, signals[COMMITTED], 0);
+ gdk_wayland_surface_commit (surface);
+ gdk_wayland_surface_notify_committed (surface);
}
if (impl->awaiting_frame &&
@@ -814,7 +808,6 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
cairo_region_get_rectangle (damage, i, &rect);
wl_surface_damage (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
}
- impl->pending_commit = TRUE;
}
void
@@ -1480,6 +1473,8 @@ gdk_wayland_surface_configure (GdkSurface *surface)
impl->pending.is_initial_configure = TRUE;
}
+ impl->has_uncommitted_ack_configure = TRUE;
+
if (is_realized_popup (surface))
gdk_wayland_surface_configure_popup (surface);
else if (is_realized_toplevel (surface))
@@ -2799,7 +2794,6 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
unset_transient_for_exported (surface);
_gdk_wayland_surface_clear_saved_size (surface);
- impl->pending_commit = FALSE;
impl->mapped = FALSE;
}
@@ -4026,13 +4020,6 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
impl_class->set_opaque_region = gdk_wayland_surface_set_opaque_region;
impl_class->set_shadow_width = gdk_wayland_surface_set_shadow_width;
impl_class->create_gl_context = gdk_wayland_surface_create_gl_context;
-
- signals[COMMITTED] = g_signal_new (g_intern_static_string ("committed"),
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE, 0);
}
void
diff --git a/gdk/wayland/gdkvulkancontext-wayland.c b/gdk/wayland/gdkvulkancontext-wayland.c
index fa2f89c8d8..ee88e8e66c 100644
--- a/gdk/wayland/gdkvulkancontext-wayland.c
+++ b/gdk/wayland/gdkvulkancontext-wayland.c
@@ -69,6 +69,8 @@ gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
gdk_wayland_surface_request_frame (surface);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted);
+
+ gdk_wayland_surface_notify_committed (surface);
}
static void