]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/utilsx.cpp
Some change logs
[wxWidgets.git] / src / x11 / utilsx.cpp
index 1e9acde5673694e628ba961d26d37c8ce177bb5b..7a25ddbcc5dad924bcc374c3f23f0834c12f91aa 100644 (file)
@@ -9,8 +9,78 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+#ifdef __VMS
+#define XShapeQueryExtension XSHAPEQUERYEXTENSION
+#define XtDisplay XTDISPLAY
+#endif
+
 #include "wx/x11/privx.h"
 
 #include "wx/x11/privx.h"
 
+#ifdef HAVE_XSHAPE
+#ifdef __VMS
+# include "wx/vms_x_fix.h"
+# include <X11/shape.h>
+#else
+# include <X11/extensions/shape.h>
+#endif
+#include "wx/region.h"
+#include "wx/bitmap.h"
+#include "wx/dcmemory.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// XShape code
+// ----------------------------------------------------------------------------
+
+#ifdef HAVE_XSHAPE
+
+bool wxDoSetShape( Display* xdisplay,
+                   Window xwindow,
+                   const wxRegion& region )
+{
+    int dummy1, dummy2;
+
+    if( !XShapeQueryExtension( xdisplay, &dummy1, &dummy2 ) )
+        return false;
+
+    if( region.IsEmpty() )
+    {
+        XShapeCombineMask( xdisplay, xwindow, ShapeBounding, 0, 0,
+                           None, ShapeSet );
+    }
+    else
+    {
+        // wxRegion::ConvertToBitmap gives us the wrong Pixmap:
+        // polichrome and with black and whire reversed
+        wxRect box = region.GetBox();
+        wxBitmap bmp(box.GetRight(), box.GetBottom(), 1);
+        wxMemoryDC dc;
+        dc.SelectObject(bmp);
+        dc.SetBackground(*wxBLACK_BRUSH);
+        dc.Clear();
+        dc.SetClippingRegion(region);
+        dc.SetBackground(*wxWHITE_BRUSH);
+        dc.Clear();
+        dc.SelectObject(wxNullBitmap);
+
+        XShapeCombineMask( xdisplay, xwindow, ShapeBounding, 0, 0,
+                           (Pixmap)bmp.GetDrawable(), ShapeSet );
+    }
+
+    return true;
+}
+
+#else
+
+bool wxDoSetShape( Display* WXUNUSED(xdisplay),
+                   Window WXUNUSED(xwindow),
+                   const wxRegion& WXUNUSED(region) )
+{
+    return false;
+}
+
+#endif
+
 // ----------------------------------------------------------------------------
 // wxXVisualInfo
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxXVisualInfo
 // ----------------------------------------------------------------------------