Gnomine display corruption



Well, I think I tracked down the bug.  Unfortunately, it appears to be in GDK rather than gnomine:-(

Anyway here's what I think is the story if you are interested.

 - gtk_mine_draw() calls gdk_cairo_create() on the GtkMineField widget to get a cairo context it can use for drawing.
 - If a cairo context isn't yet available - which happens if we are updating the widget but not if we are doing the initial layout from scratch - gdk_cairo_create() creates one.  To do so, it first creates a cairo surface to do the drawing on by calling gdk_window_create_cairo_surface using the window corresponding to the GtkMineField widget as an argument.
 - gdk_window_create_cairo_surface seems to be trying to do the right thing.  It creates a cairo surface from the window using the window's ref_cairo_surface method, then wraps this in a subsurface clipped to the outline of the widget.  So it should cope fine if the root surface corresponds to the entire X11 window.
 - Unfortunately, the ref_cairo_surface method - gdk_x11_ref_cairo_surface in this case - gets it wrong; it creates a new x11 cairo surface using the widget's visual etc, which I assume correspond to the top-level X11 window, but constrains its size to the size of the GtkMineField widget rather than the size of the root window.
So at the end of the day we have a cairo surface for the top-level X11 window that only covers the top left of the GtkMineField widget.

One easy way to fix this is to make sure we use the root window when getting the root cairo surface.  This corresponds with replacing the second line of gdk_window_create_cairo_surface as follows:
--
@@ -3546,7 +3547,7 @@ gdk_window_create_cairo_surface (GdkWindow *window,
 {
   cairo_surface_t *surface, *subsurface;
  
-  surface = gdk_window_ref_impl_surface (window);
+  surface = gdk_window_ref_impl_surface (gdk_window_get_effective_toplevel(window));
   if (gdk_window_has_impl (window))
     return surface;
--
But I'm pretty sure that isn't the proper way to fix this issue:-(

Next step I suppose is to raise a bug against GDK and see what the best way of fixing this is. 

(I'll also have a look at the iagno issue.)

Hope this helps.

rufus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]