Fix 'mono' package typo
[mono.git] / bockbuild / mac-sdk / patches / gtk / 0046-gtk-implement-clipping-to-multiple-parent-viewports-.patch
1 From ab0bb7104783da5155361e6fbd89ee14f25e2544 Mon Sep 17 00:00:00 2001
2 From: Michael Natterer <mitch@gimp.org>
3 Date: Thu, 14 Mar 2013 20:10:51 +0100
4 Subject: [PATCH 46/68] gtk: implement clipping to multiple parent viewports
5  in GtkNSView
6
7 ---
8  gtk/gtknsview.c |   51 +++++++++++----------------------------------------
9  1 file changed, 11 insertions(+), 40 deletions(-)
10
11 diff --git a/gtk/gtknsview.c b/gtk/gtknsview.c
12 index db1da93..1e0b7e6 100644
13 --- a/gtk/gtknsview.c
14 +++ b/gtk/gtknsview.c
15 @@ -143,10 +143,7 @@ gtk_ns_view_init (GtkNSView *ns_view)
16  {
17    GtkNSView *ns_view;
18    GtkWidget *viewport;
19 -
20 -#if 0
21 -  g_printerr ("drawRect called\n");
22 -#endif
23 +  CGContextRef cg_context;
24
25    ns_view = (GtkNSView *) objc_getAssociatedObject (self, "gtknsview");
26
27 @@ -156,51 +153,30 @@ gtk_ns_view_init (GtkNSView *ns_view)
28        return;
29      }
30
31 -  viewport = gtk_widget_get_ancestor (GTK_WIDGET (ns_view), GTK_TYPE_VIEWPORT);
32 +  cg_context = [[NSGraphicsContext currentContext] graphicsPort];
33 +  CGContextSaveGState (cg_context);
34
35 -  if (viewport)
36 +  for (viewport = gtk_widget_get_ancestor (GTK_WIDGET (ns_view), GTK_TYPE_VIEWPORT);
37 +       viewport;
38 +       viewport = gtk_widget_get_ancestor (gtk_widget_get_parent (viewport),
39 +                                           GTK_TYPE_VIEWPORT))
40      {
41        GdkWindow *window;
42 -      CGContextRef cg_context = [[NSGraphicsContext currentContext] graphicsPort];
43        GtkAllocation viewport_allocation;
44        CGRect rect;
45
46 -#if 0
47 -      g_printerr ("drawRect called on gtknsview in gtkviewport\n");
48 -#endif
49 -
50        gtk_widget_get_allocation (viewport, &viewport_allocation);
51
52 -#if 0
53 -      g_printerr ("viewport allocation: %d, %d (%d x %x)\n",
54 -                  viewport_allocation.x,
55 -                  viewport_allocation.y,
56 -                  viewport_allocation.width,
57 -                  viewport_allocation.height);
58 -#endif
59 -
60        /* evil: don't clip to the viewport's width/height but to that
61         * of its parent window, because we know we hacked an
62         * overshoot_window into GtkScrolledWindow and need to restrict
63 -       * rendering in its area
64 +       * rendering to its area
65         */
66        window = gtk_widget_get_parent_window (viewport);
67
68        viewport_allocation.width = gdk_window_get_width (window);
69        viewport_allocation.height = gdk_window_get_height (window);
70
71 -#if 0
72 -      {
73 -        gint x, y;
74 -
75 -        gdk_window_get_position (window, &x, &y);
76 -        g_printerr ("viewport parent window at %d, %d (%x x %x)\n",
77 -                    x, y,
78 -                    gdk_window_get_width (window),
79 -                    gdk_window_get_height (window));
80 -      }
81 -#endif
82 -
83        if (gtk_viewport_get_shadow_type (GTK_VIEWPORT (viewport)) != GTK_SHADOW_NONE)
84          {
85            GtkStyle *style = gtk_widget_get_style (viewport);
86 @@ -222,17 +198,12 @@ gtk_ns_view_init (GtkNSView *ns_view)
87        rect.size.width = viewport_allocation.width;
88        rect.size.height = viewport_allocation.height;
89
90 -      CGContextSaveGState (cg_context);
91        CGContextClipToRect (cg_context, rect);
92 +    }
93
94 -      [self myDrawRect: dirtyRect];
95 +  [self myDrawRect: dirtyRect];
96
97 -      CGContextRestoreGState (cg_context);
98 -    }
99 -  else
100 -    {
101 -      [self myDrawRect: dirtyRect];
102 -    }
103 +  CGContextRestoreGState (cg_context);
104  }
105  @end
106
107 --
108 1.7.10.2 (Apple Git-33)