From 2c831268463a99853c43a41a48784b0ed702c34d Mon Sep 17 00:00:00 2001 From: Olivier Dufour Date: Thu, 1 Sep 2011 21:25:25 +0200 Subject: [PATCH] Fix NRE in Gdk.Window.SetBackgroundPattern If we set it to null background is set to parent brackground. So we must handle null case and sent it to native. --- gdk/Gdk.metadata | 2 ++ gdk/Window.custom | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 0be599e81..c852ef28f 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -111,9 +111,11 @@ out out out + 1 call 1 1 + 1 1 1 1 diff --git a/gdk/Window.custom b/gdk/Window.custom index 109958e93..3e2178769 100644 --- a/gdk/Window.custom +++ b/gdk/Window.custom @@ -24,6 +24,23 @@ public Window (Gdk.Window parent, Gdk.WindowAttr attributes, Gdk.WindowAttributesType attributes_mask) : this (parent, attributes, (int)attributes_mask) {} + [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr gdk_window_get_background_pattern(IntPtr raw); + + [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void gdk_window_set_background_pattern(IntPtr raw, IntPtr pattern); + + public Cairo.Pattern BackgroundPattern { + get { + IntPtr raw_ret = gdk_window_get_background_pattern(Handle); + Cairo.Pattern ret = Cairo.Pattern.Lookup (raw_ret); + return ret; + } + set { + gdk_window_set_background_pattern(Handle, (value == null) ? IntPtr.Zero : value.Handle); + } + } + [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_window_get_children(IntPtr raw);