X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9ce8d6a2b0fec3ce3f6e838445fdea3445d2ce8d..3a4cf8a84d9a41c63125c1c1cdd6d0fbb98f41f0:/src/x11/utilsx.cpp diff --git a/src/x11/utilsx.cpp b/src/x11/utilsx.cpp index 1e9acde567..335078fb05 100644 --- a/src/x11/utilsx.cpp +++ b/src/x11/utilsx.cpp @@ -4,13 +4,91 @@ // Author: Mattia Barbon // Modified by: // Created: 05/04/03 -// RCS-ID: $Id$ // Copyright: (c) Mattia Barbon // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __VMS +#define XShapeQueryExtension XSHAPEQUERYEXTENSION +#endif + #include "wx/x11/privx.h" +#ifdef HAVE_XSHAPE + + #ifndef WX_PRECOMP + #include "wx/bitmap.h" + #include "wx/region.h" + #endif + + #ifdef __VMS + #include "wx/vms_x_fix.h" + #include + #else + #include + #endif + + #include "wx/dcmemory.h" +#endif + +#include "wx/x11/private/wrapxkb.h" + +// ---------------------------------------------------------------------------- +// 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: + // polychrome and with black and white reversed + wxRect box = region.GetBox(); + wxBitmap bmp(box.GetRight(), box.GetBottom(), 1); + wxMemoryDC dc; + dc.SelectObject(bmp); + dc.SetBackground(*wxBLACK_BRUSH); + dc.Clear(); + dc.SetDeviceClippingRegion(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 // ---------------------------------------------------------------------------- @@ -110,7 +188,7 @@ void wxXVisualInfo::Init( Display* dpy, XVisualInfo* vi ) XColor* colors = (XColor*) m_visualColormap; for (int i = 0; i < m_visualColormapSize; i++) - colors[i].pixel = i; + colors[i].pixel = i; XQueryColors( dpy, DefaultColormap(dpy, vi->screen), colors, m_visualColormapSize ); @@ -152,10 +230,25 @@ void wxXVisualInfo::Init( Display* dpy, XVisualInfo* vi ) index |= (g >> (5 - m_visualGreenPrec)) << m_visualGreenShift; index |= (b >> (5 - m_visualBluePrec)) << m_visualBlueShift; } - m_colorCube[ (r*1024) + (g*32) + b ] = index; + m_colorCube[ (r*1024) + (g*32) + b ] = (unsigned char)index; } } } } #endif // !wxUSE_NANOX + +/* Don't synthesize KeyUp events holding down a key and producing + KeyDown events with autorepeat. */ +bool wxSetDetectableAutoRepeat( bool flag ) +{ +#ifdef HAVE_X11_XKBLIB_H + Bool result; + XkbSetDetectableAutoRepeat( (Display *)wxGetDisplay(), flag, &result ); + return result; /* true if keyboard hardware supports this mode */ +#else + wxUnusedVar(flag); + return false; +#endif +} +