mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Gdk: fix wrong user_data handling in resize_cairo_surface()
Instead of destroying the surface in the backend if this is unable to resize, let the core code do it, and do it properly. Based on a patch by Benjamin Otte. https://bugzilla.gnome.org/show_bug.cgi?id=725172
This commit is contained in:
parent
d5196ded2f
commit
ad2f96ff48
@ -365,16 +365,14 @@ _gdk_broadway_window_destroy (GdkWindow *window,
|
||||
impl->id);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_window_broadway_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* Image surfaces cannot be resized */
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -550,7 +550,7 @@ gdk_offscreen_window_queue_antiexpose (GdkWindow *window,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
@ -559,7 +559,7 @@ gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
|
||||
/* No-op. The surface gets resized in
|
||||
* gdk_offscreen_window_move_resize_internal().
|
||||
*/
|
||||
return surface;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1003,17 +1003,17 @@ recompute_visible_regions_internal (GdkWindow *private,
|
||||
}
|
||||
}
|
||||
|
||||
if (private->cairo_surface && gdk_window_has_impl (private))
|
||||
if (private->cairo_surface)
|
||||
{
|
||||
GdkWindowImplClass *iface = GDK_WINDOW_IMPL_GET_CLASS (private->impl);
|
||||
|
||||
private->cairo_surface = iface->resize_cairo_surface (private,
|
||||
private->cairo_surface,
|
||||
private->width,
|
||||
private->height);
|
||||
if (!gdk_window_has_impl (private) ||
|
||||
!GDK_WINDOW_IMPL_GET_CLASS (private->impl)->resize_cairo_surface (private,
|
||||
private->cairo_surface,
|
||||
private->width,
|
||||
private->height))
|
||||
{
|
||||
gdk_window_drop_cairo_surface (private);
|
||||
}
|
||||
}
|
||||
else if (private->cairo_surface)
|
||||
gdk_window_drop_cairo_surface (private);
|
||||
}
|
||||
|
||||
/* Call this when private has changed in one or more of these ways:
|
||||
|
@ -158,10 +158,14 @@ struct _GdkWindowImplClass
|
||||
*/
|
||||
void (*destroy_foreign) (GdkWindow *window);
|
||||
|
||||
cairo_surface_t * (* resize_cairo_surface) (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height);
|
||||
/* Resizes @surface to a new size. If successful, return %TRUE.
|
||||
* If the backend cannot resize surfaces, return %FALSE and a new
|
||||
* surface will be created instead.
|
||||
*/
|
||||
gboolean (* resize_cairo_surface) (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
/* optional */
|
||||
gboolean (* beep) (GdkWindow *window);
|
||||
|
@ -1104,16 +1104,14 @@ gdk_quartz_window_destroy (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_window_quartz_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* Quartz surfaces cannot be resized */
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1481,14 +1481,14 @@ gdk_window_wayland_destroy_foreign (GdkWindow *window)
|
||||
{
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_window_wayland_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* cairo image surfaces cannot be resized */
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static cairo_region_t *
|
||||
|
@ -796,16 +796,14 @@ gdk_win32_window_destroy (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_win32_window_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* XXX: Make Cairo surface use DC clip */
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1337,7 +1337,7 @@ gdk_x11_window_destroy (GdkWindow *window,
|
||||
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
static gboolean
|
||||
gdk_window_x11_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
@ -1345,7 +1345,7 @@ gdk_window_x11_resize_cairo_surface (GdkWindow *window,
|
||||
{
|
||||
cairo_xlib_surface_set_size (surface, width, height);
|
||||
|
||||
return surface;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user