Fix 'mono' package typo
[mono.git] / bockbuild / mac-sdk / patches / gtk / gtknsview-defer-map-and-lock-in-clipping.patch
1 commit 33da74a9ab13bba4f46b2455cc858c7ae02bd923
2 Author: Cody Russell <cody@jhu.edu>
3 Date:   Mon Mar 31 08:51:25 2014 -0500
4
5     This is an attempt to solve an issue in GtkNSView that occurs in
6     Xamarin Studio when we try to use an animating NSProgressIndicator.
7     The error only occurred if the indicator was in animating mode,
8     and it seems likely to be a threading race condition somewhere.
9
10     This patch does two things. I've found the issue to be reproducible
11     if we do one of these things but not the other, but I have not been
12     able to reproduce it with both of these.
13
14     First, we slightly defer the mapping of the widget.
15     Second, we lock the view during clip_to_parent_viewports().
16
17     https://bugzilla.xamarin.com/show_bug.cgi?id=17401
18
19 diff --git a/gtk/gtknsview.c b/gtk/gtknsview.c
20 index d5eb307..31c4970 100644
21 --- a/gtk/gtknsview.c
22 +++ b/gtk/gtknsview.c
23 @@ -280,6 +280,7 @@ clip_to_parent_viewports (GtkNSView *ns_view,
24
25    ns_view = get_associated_gtknsview (self);
26
27 +  [self lockFocusIfCanDraw];
28    if (ns_view)
29      cg_context = clip_to_parent_viewports (ns_view, self);
30
31 @@ -287,6 +288,8 @@ clip_to_parent_viewports (GtkNSView *ns_view,
32
33    if (cg_context)
34      CGContextRestoreGState (cg_context);
35 +
36 +  [self unlockFocus];
37  }
38  @end
39
40 @@ -566,15 +569,17 @@ gtk_ns_view_unrealize (GtkWidget *widget)
41    GTK_WIDGET_CLASS (gtk_ns_view_parent_class)->unrealize (widget);
42  }
43
44 -static void
45 -gtk_ns_view_map (GtkWidget *widget)
46 -{
47 +static gboolean
48 +really_map (GtkWidget *widget) {
49    GtkNSView *ns_view = GTK_NS_VIEW (widget);
50    GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
51    GtkAllocation allocation;
52    NSView *parent_view;
53    NSWindow *window;
54
55 +  if (gtk_widget_get_mapped (widget))
56 +    return FALSE;
57 +
58    gtk_widget_get_allocation (widget, &allocation);
59    gtk_ns_view_position_view (ns_view, &allocation);
60
61 @@ -605,6 +610,14 @@ gtk_ns_view_map (GtkWidget *widget)
62            gtk_ns_view_swizzle_draw_rect_recursive (text, "gtkwindow", toplevel);
63          }
64      }
65 +
66 +  return FALSE;
67 +}
68 +
69 +static void
70 +gtk_ns_view_map (GtkWidget *widget)
71 +{
72 +   g_timeout_add (50, (GSourceFunc)really_map, widget);
73  }
74
75  static void