static void gdk_wayland_surface_sync_shadow (GdkSurface *surface);
static void gdk_wayland_surface_sync_input_region (GdkSurface *surface);
static void gdk_wayland_surface_sync_opaque_region (GdkSurface *surface);
+static void gdk_wayland_surface_sync_buffer_scale (GdkSurface *surface);
/* {{{ Utilities */
if (impl->display_server.egl_window)
wl_egl_window_resize (impl->display_server.egl_window, width * scale, height * scale, 0, 0);
- if (impl->display_server.wl_surface && scale_changed)
- wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
+ if (scale_changed)
+ impl->buffer_scale_dirty = TRUE;
gdk_surface_invalidate_rect (surface, NULL);
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
if (monitor)
{
- GDK_WAYLAND_SURFACE (surface)->scale = gdk_monitor_get_scale_factor (monitor);
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+
+ impl->scale = gdk_monitor_get_scale_factor (monitor);
+ if (impl->scale != 1)
+ impl->buffer_scale_dirty = TRUE;
+
g_object_unref (monitor);
}
}
const cairo_region_t *damage)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
- GdkWaylandDisplay *display;
cairo_rectangle_int_t rect;
int i, n;
impl->pending_buffer_offset_x = 0;
impl->pending_buffer_offset_y = 0;
- /* Only set the buffer scale if supported by the compositor */
- display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
- if (display->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
- wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
-
n = cairo_region_num_rectangles (damage);
for (i = 0; i < n; i++)
{
gdk_wayland_surface_sync_shadow (surface);
gdk_wayland_surface_sync_opaque_region (surface);
gdk_wayland_surface_sync_input_region (surface);
+ gdk_wayland_surface_sync_buffer_scale (surface);
}
static gboolean
impl->input_region_dirty = FALSE;
}
+static void
+gdk_wayland_surface_sync_buffer_scale (GdkSurface *surface)
+{
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+ GdkWaylandDisplay *display;
+
+ if (!impl->display_server.wl_surface)
+ return;
+
+ if (!impl->buffer_scale_dirty)
+ return;
+
+ /* Only set the buffer scale if supported by the compositor */
+ display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
+ if (display->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
+ wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
+
+ impl->buffer_scale_dirty = FALSE;
+}
+
static void
surface_enter (void *data,
struct wl_surface *wl_surface,
impl->has_uncommitted_ack_configure = FALSE;
impl->input_region_dirty = TRUE;
impl->opaque_region_dirty = TRUE;
+ if (impl->scale != 1)
+ impl->buffer_scale_dirty = TRUE;
impl->last_sent_window_geometry = (GdkRectangle) { 0 };
impl->mapped = FALSE;
wl_egl_window_create (impl->display_server.wl_surface,
surface->width * impl->scale,
surface->height * impl->scale);
- wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
-
gdk_surface_set_egl_native_window (surface, impl->display_server.egl_window);
}
}