Rolf pointed out that I have been modifying the new tree, which is not
yet in use.
I have attached an updated patch. Unfortunately it causes a black
client rectangle instead of a transparent control. It also causes a
BadMatch[1] error and a lot of BadWindow errors.
Any X11 gurus around? :|
[1]
Error: BadMatch (invalid parameter attributes)
Request: 1 (0)
Resource ID: 0x3400012
Serial: 189
Hwnd: Hwnd, Mapped:False ClientWindow:0x3400014,
WholeWindow:0x3400012, Zombie=False, Parent:[Hwnd, Mapped:False
ClientWindow:0x340000F, WholeWindow:0x340000E, Zombie=False,
Parent:[Hwnd, Mapped:False ClientWindow:0x340000D,
WholeWindow:0x340000C, Zombie=False, Parent:[<null>]]]
Control: <handle 54525972 non-existant> at
System.Environment.get_StackTrace()
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs (revision 82534)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs (working copy)
@@ -1659,4 +1659,19 @@
public int nimage; /* number of images */
public IntPtr images; /* array of XcursorImage pointers */
}
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XVisualInfo
+ {
+ internal IntPtr visual;
+ internal int visualid;
+ internal int screen;
+ internal uint depth;
+ internal int klass;
+ internal uint red_mask;
+ internal uint green_mask;
+ internal uint blue_mask;
+ internal int colormap_size;
+ internal int bits_per_rgb;
+ }
}
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs (revision 82534)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs (working copy)
@@ -2621,7 +2621,13 @@
if (WholeWindow != IntPtr.Zero) {
ValueMask &= ~(SetWindowValuemask.OverrideRedirect | SetWindowValuemask.SaveUnder);
- if (CustomVisual != IntPtr.Zero && CustomColormap != IntPtr.Zero) {
+ if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_TRANSPARENT)) {
+ IntPtr colormap = GetRGBAColormap (Display, RootWindowHandle, Screen);
+ if (colormap != IntPtr.Zero) {
+ ValueMask |= SetWindowValuemask.ColorMap;
+ Attributes.colormap = colormap;
+ }
+ } else if (CustomVisual != IntPtr.Zero && CustomColormap != IntPtr.Zero) {
ValueMask = SetWindowValuemask.ColorMap;
Attributes.colormap = CustomColormap;
}
@@ -2711,6 +2717,30 @@
return hwnd.Handle;
}
+ public IntPtr GetRGBAColormap (IntPtr display, IntPtr rootWindow, int screenNo)
+ {
+ IntPtr rgbaColormap = IntPtr.Zero;
+
+ // try to find the rgba visual
+ XVisualInfo visual = new XVisualInfo ();
+ visual.screen = screenNo;
+ visual.depth = 32;
+ visual.red_mask = 0xff0000;
+ visual.green_mask = 0x00ff00;
+ visual.blue_mask = 0x0000ff;
+ int mask = 0x2 /* VisualScreenMask */ | 0x04 /* VisualDepthMask */ | 0x10 /* VisualRedMaskMask */ |
+ 0x20 /* VisualGreenMaskMask */ | 0x40 /* VisualBlueMaskMask */;
+
+ int nitems = 0;
+ IntPtr vPtr = XGetVisualInfo (display, mask, ref visual, ref nitems);
+ if (vPtr != IntPtr.Zero && nitems > 0) {
+ rgbaColormap = XCreateColormap (display, rootWindow, vPtr, 0x0 /* AllocNone */);
+ XFree (vPtr);
+ }
+
+ return rgbaColormap;
+ }
+
internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
CreateParams create_params = new CreateParams();
@@ -5998,7 +6028,13 @@
internal extern static void XkbSetDetectableAutoRepeat (IntPtr display, bool detectable, IntPtr supported);
[DllImport ("libX11")]
- internal extern static void XPeekEvent (IntPtr display, ref XEvent xevent);
+ internal extern static void XPeekEvent (IntPtr display, ref XEvent xevent);
+
+ [DllImport ("libX11")]
+ internal extern static IntPtr XGetVisualInfo (IntPtr display, int vinfo_mask, ref XVisualInfo vinfo_template, ref int nitems);
+
+ [DllImport ("libX11")]
+ internal extern static IntPtr XCreateColormap (IntPtr display, IntPtr window, IntPtr visual, int alloc);
#endregion
}
}
_______________________________________________
Mono-winforms-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list