79 lines
2.6 KiB
Diff
79 lines
2.6 KiB
Diff
|
From 24caf0db2af4d43a2d8bf1cd6dff7e54d5268502 Mon Sep 17 00:00:00 2001
|
||
|
From: Michael Natterer <mitch@gimp.org>
|
||
|
Date: Thu, 14 Mar 2013 16:54:38 +0100
|
||
|
Subject: [PATCH 45/68] gtk: clip NSViews to the scrolled window's
|
||
|
overshoot_window
|
||
|
|
||
|
not to the viewport's allocation. This is ugly but by far the
|
||
|
easiest way to get clipping right.
|
||
|
---
|
||
|
gtk/gtknsview.c | 31 +++++++++++++++++++++++++++++++
|
||
|
tests/testnsview.c | 3 ++-
|
||
|
2 files changed, 33 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/gtk/gtknsview.c b/gtk/gtknsview.c
|
||
|
index 84d758f..db1da93 100644
|
||
|
--- a/gtk/gtknsview.c
|
||
|
+++ b/gtk/gtknsview.c
|
||
|
@@ -160,6 +160,7 @@ gtk_ns_view_init (GtkNSView *ns_view)
|
||
|
|
||
|
if (viewport)
|
||
|
{
|
||
|
+ GdkWindow *window;
|
||
|
CGContextRef cg_context = [[NSGraphicsContext currentContext] graphicsPort];
|
||
|
GtkAllocation viewport_allocation;
|
||
|
CGRect rect;
|
||
|
@@ -170,6 +171,36 @@ gtk_ns_view_init (GtkNSView *ns_view)
|
||
|
|
||
|
gtk_widget_get_allocation (viewport, &viewport_allocation);
|
||
|
|
||
|
+#if 0
|
||
|
+ g_printerr ("viewport allocation: %d, %d (%d x %x)\n",
|
||
|
+ viewport_allocation.x,
|
||
|
+ viewport_allocation.y,
|
||
|
+ viewport_allocation.width,
|
||
|
+ viewport_allocation.height);
|
||
|
+#endif
|
||
|
+
|
||
|
+ /* evil: don't clip to the viewport's width/height but to that
|
||
|
+ * of its parent window, because we know we hacked an
|
||
|
+ * overshoot_window into GtkScrolledWindow and need to restrict
|
||
|
+ * rendering in its area
|
||
|
+ */
|
||
|
+ window = gtk_widget_get_parent_window (viewport);
|
||
|
+
|
||
|
+ viewport_allocation.width = gdk_window_get_width (window);
|
||
|
+ viewport_allocation.height = gdk_window_get_height (window);
|
||
|
+
|
||
|
+#if 0
|
||
|
+ {
|
||
|
+ gint x, y;
|
||
|
+
|
||
|
+ gdk_window_get_position (window, &x, &y);
|
||
|
+ g_printerr ("viewport parent window at %d, %d (%x x %x)\n",
|
||
|
+ x, y,
|
||
|
+ gdk_window_get_width (window),
|
||
|
+ gdk_window_get_height (window));
|
||
|
+ }
|
||
|
+#endif
|
||
|
+
|
||
|
if (gtk_viewport_get_shadow_type (GTK_VIEWPORT (viewport)) != GTK_SHADOW_NONE)
|
||
|
{
|
||
|
GtkStyle *style = gtk_widget_get_style (viewport);
|
||
|
diff --git a/tests/testnsview.c b/tests/testnsview.c
|
||
|
index 1a523e6..24d1d41 100644
|
||
|
--- a/tests/testnsview.c
|
||
|
+++ b/tests/testnsview.c
|
||
|
@@ -149,7 +149,8 @@ main (gint argc,
|
||
|
NSTextField *text_field;
|
||
|
|
||
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||
|
- gtk_widget_set_size_request (sw, -1, 100);
|
||
|
+ gtk_widget_set_size_request (sw, -1, 130);
|
||
|
+ gtk_container_set_border_width (GTK_CONTAINER (sw), 20);
|
||
|
gtk_box_pack_start (GTK_BOX (vbox), sw, FALSE, FALSE, 0);
|
||
|
gtk_widget_show (sw);
|
||
|
|
||
|
--
|
||
|
1.7.10.2 (Apple Git-33)
|