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
8 gtk/gtknsview.c | 51 +++++++++++----------------------------------------
9 1 file changed, 11 insertions(+), 40 deletions(-)
11 diff --git a/gtk/gtknsview.c b/gtk/gtknsview.c
12 index db1da93..1e0b7e6 100644
15 @@ -143,10 +143,7 @@ gtk_ns_view_init (GtkNSView *ns_view)
21 - g_printerr ("drawRect called\n");
23 + CGContextRef cg_context;
25 ns_view = (GtkNSView *) objc_getAssociatedObject (self, "gtknsview");
27 @@ -156,51 +153,30 @@ gtk_ns_view_init (GtkNSView *ns_view)
31 - viewport = gtk_widget_get_ancestor (GTK_WIDGET (ns_view), GTK_TYPE_VIEWPORT);
32 + cg_context = [[NSGraphicsContext currentContext] graphicsPort];
33 + CGContextSaveGState (cg_context);
36 + for (viewport = gtk_widget_get_ancestor (GTK_WIDGET (ns_view), GTK_TYPE_VIEWPORT);
38 + viewport = gtk_widget_get_ancestor (gtk_widget_get_parent (viewport),
42 - CGContextRef cg_context = [[NSGraphicsContext currentContext] graphicsPort];
43 GtkAllocation viewport_allocation;
47 - g_printerr ("drawRect called on gtknsview in gtkviewport\n");
50 gtk_widget_get_allocation (viewport, &viewport_allocation);
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);
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
66 window = gtk_widget_get_parent_window (viewport);
68 viewport_allocation.width = gdk_window_get_width (window);
69 viewport_allocation.height = gdk_window_get_height (window);
75 - gdk_window_get_position (window, &x, &y);
76 - g_printerr ("viewport parent window at %d, %d (%x x %x)\n",
78 - gdk_window_get_width (window),
79 - gdk_window_get_height (window));
83 if (gtk_viewport_get_shadow_type (GTK_VIEWPORT (viewport)) != GTK_SHADOW_NONE)
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;
90 - CGContextSaveGState (cg_context);
91 CGContextClipToRect (cg_context, rect);
94 - [self myDrawRect: dirtyRect];
95 + [self myDrawRect: dirtyRect];
97 - CGContextRestoreGState (cg_context);
101 - [self myDrawRect: dirtyRect];
103 + CGContextRestoreGState (cg_context);
108 1.7.10.2 (Apple Git-33)