diff options
author | Chris Toshok <toshok@novell.com> | 2007-01-30 03:42:15 +0300 |
---|---|---|
committer | Chris Toshok <toshok@novell.com> | 2007-01-30 03:42:15 +0300 |
commit | e2a36cf6bd1e62862518a436fbdd96cd1c2d0413 (patch) | |
tree | 86ad9e17ad20877f8ad3aa61b2719634462ab0c1 | |
parent | 7690886912037f765b0453e3d68e303674656865 (diff) |
x2007-01-29 Chris Toshok <toshok@ximian.com>
* XplatUIX11.cs: don't crash, and remove the icon if the user has
set one, if SetIcon is passed a null icon.
svn path=/branches/mono-1-2-3/mcs/; revision=71938
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs | 52 |
2 files changed, 39 insertions, 18 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 5bce5ab2d61..44b9880d9f5 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,8 @@ +x2007-01-29 Chris Toshok <toshok@ximian.com> + + * XplatUIX11.cs: don't crash, and remove the icon if the user has + set one, if SetIcon is passed a null icon. + 2007-01-29 Andreia Gaita <avidigal@novell.com> * TextBox.cs: Redraw when the password characters changes diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs index 85f637bc4c0..278d7ec846b 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs @@ -1003,27 +1003,43 @@ namespace System.Windows.Forms { } } - private void SetIcon(Hwnd hwnd, Icon icon) { - Bitmap bitmap; - int size; - IntPtr[] data; - int index; - - bitmap = icon.ToBitmap(); - index = 0; - size = bitmap.Width * bitmap.Height + 2; - data = new IntPtr[size]; - - data[index++] = (IntPtr)bitmap.Width; - data[index++] = (IntPtr)bitmap.Height; + private void SetIcon(Hwnd hwnd, Icon icon) + { + if (icon == null) { + // XXX - for (int y = 0; y < bitmap.Height; y++) { - for (int x = 0; x < bitmap.Width; x++) { - data[index++] = (IntPtr)bitmap.GetPixel(x, y).ToArgb(); - } + // This really needs to do whatever it + // takes to remove the window manager + // menu, not just delete the ICON + // property. This will cause metacity + // to use the "no icon set" icon, and + // we'll still have an icon. + XDeleteProperty (DisplayHandle, hwnd.whole_window, _NET_WM_ICON); } + else { + Bitmap bitmap; + int size; + IntPtr[] data; + int index; + + bitmap = icon.ToBitmap(); + index = 0; + size = bitmap.Width * bitmap.Height + 2; + data = new IntPtr[size]; + + data[index++] = (IntPtr)bitmap.Width; + data[index++] = (IntPtr)bitmap.Height; + + for (int y = 0; y < bitmap.Height; y++) { + for (int x = 0; x < bitmap.Width; x++) { + data[index++] = (IntPtr)bitmap.GetPixel (x, y).ToArgb (); + } + } - XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_ICON, (IntPtr)Atom.XA_CARDINAL, 32, PropertyMode.Replace, data, size); + XChangeProperty (DisplayHandle, hwnd.whole_window, + _NET_WM_ICON, (IntPtr)Atom.XA_CARDINAL, 32, + PropertyMode.Replace, data, size); + } } private void WakeupMain () { |