x11: Fix damage tracking hack

We are setting mime data with a destroy notify on the cairo
surface to get notified when cairo registers damage for the
surface (in that case, it clears the mime data, calling the
destroy notify). Unfortunately, the destroy notify is also
called when we remove the mime data ourselves, which was
not intentional.

Use a flag in the window impl struct to ignore the callback
when we are clearing the hook.
This commit is contained in:
Matthias Clasen 2016-01-08 13:44:36 -05:00
parent 3f56c530b3
commit 4d60b5b10c
2 changed files with 20 additions and 11 deletions

View File

@ -250,8 +250,10 @@ static void
on_surface_changed (void *data)
{
GdkWindow *window = data;
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
window_pre_damage (window);
if (impl->tracking_damage)
window_pre_damage (window);
}
/* We want to know when cairo drawing causes damage to the window,
@ -269,12 +271,15 @@ hook_surface_changed (GdkWindow *window)
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (impl->cairo_surface)
cairo_surface_set_mime_data (impl->cairo_surface,
"x-gdk/change-notify",
(unsigned char *)"X",
1,
on_surface_changed,
window);
{
cairo_surface_set_mime_data (impl->cairo_surface,
"x-gdk/change-notify",
(unsigned char *)"X",
1,
on_surface_changed,
window);
impl->tracking_damage = 1;
}
}
static void
@ -283,10 +288,13 @@ unhook_surface_changed (GdkWindow *window)
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (impl->cairo_surface)
cairo_surface_set_mime_data (impl->cairo_surface,
"x-gdk/change-notify",
NULL, 0,
NULL, NULL);
{
impl->tracking_damage = 0;
cairo_surface_set_mime_data (impl->cairo_surface,
"x-gdk/change-notify",
NULL, 0,
NULL, NULL);
}
}
static void

View File

@ -73,6 +73,7 @@ struct _GdkWindowImplX11
guint override_redirect : 1;
guint frame_clock_connected : 1;
guint frame_sync_enabled : 1;
guint tracking_damage: 1;
gint window_scale;