diff options
author | Uli Schlachter <psychon@znc.in> | 2012-07-17 23:40:45 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-25 00:59:32 +0200 |
commit | 597b99305e7c46ffcc83c60b7412bdff4e888500 (patch) | |
tree | ad558750b062b6b7a968c9b80c8ba757ba02908c /src/plugins/platforms | |
parent | 958e4e6bec1905f59dbac392dc48203a0a770558 (diff) |
Reimplement QXcbWindow::setMask() with xcb
This functionality does not need libXext. The bindings for the shape extension
from libxcb-shape is enough and is available without Xlib.
Change-Id: I9f1927024c64df00ace1666998c6c6deda2ef782
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 51 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/xcb.pro | 3 |
3 files changed, 19 insertions, 39 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e51bab495d..55ba0459a8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -64,6 +64,9 @@ #include <xcb/xcb_icccm.h> #undef class #include <xcb/xfixes.h> +#ifndef QT_NO_SHAPE +# include <xcb/shape.h> +#endif // QT_NO_SHAPE // xcb-icccm 3.8 support #ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS @@ -98,9 +101,6 @@ #ifdef XCB_USE_XLIB #include <X11/Xlib.h> #include <X11/Xutil.h> -#ifndef QT_NO_SHAPE -# include <X11/extensions/shape.h> -#endif // QT_NO_SHAPE #endif #if defined(XCB_USE_XINPUT2_MAEMO) || defined(XCB_USE_XINPUT2) @@ -1704,11 +1704,11 @@ bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) return true; } -#if defined(XCB_USE_XLIB) && !defined(QT_NO_SHAPE) +#if !defined(QT_NO_SHAPE) -static inline XRectangle qRectToX11Rectangle(const QRect &r) +static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r) { - XRectangle result; + xcb_rectangle_t result; result.x = qMax(SHRT_MIN, r.x()); result.y = qMax(SHRT_MIN, r.y()); result.width = qMin((int)USHRT_MAX, r.width()); @@ -1716,42 +1716,21 @@ static inline XRectangle qRectToX11Rectangle(const QRect &r) return result; } -static inline Region qRegionToX11Region(const QRegion ®ion) -{ - if (region.isEmpty()) - return None; - Region result = XCreateRegion(); - if (!result) - return None; - const QVector<QRect> rects = region.rects(); - if (rects.size() == 1) { - XRectangle xrect = qRectToX11Rectangle(region.boundingRect()); - XUnionRectWithRegion(&xrect, result, result); - } else { - foreach (const QRect &r, rects) { - XRectangle xrect = qRectToX11Rectangle(r); - XUnionRectWithRegion(&xrect, result, result); - } - } - return result; -} - - void QXcbWindow::setMask(const QRegion ®ion) { - - Display *display = (Display *)connection()->xlib_display(); if (region.isEmpty()) { - XShapeCombineMask(display, xcb_window(), - ShapeBounding, 0, 0, - None, ShapeSet); + xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET, + XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE); } else { - XShapeCombineRegion(display, xcb_window(), - ShapeBounding, 0, 0, - qRegionToX11Region(region), ShapeSet); + QVector<xcb_rectangle_t> rects; + foreach (const QRect &r, region.rects()) + rects.push_back(qRectToXCBRectangle(r)); + xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET, + XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, + xcb_window(), 0, 0, rects.size(), &rects[0]); } } -#endif // XCB_USE_XLIB && !QT_NO_SHAPE +#endif // !QT_NO_SHAPE QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 0c4ec34269..fa5ae635f9 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -109,9 +109,9 @@ public: bool startSystemResize(const QPoint &pos, Qt::Corner corner); -#if defined(XCB_USE_XLIB) && !defined(QT_NO_SHAPE) +#if !defined(QT_NO_SHAPE) void setMask(const QRegion ®ion); -#endif // XCB_USE_XLIB && !QT_NO_SHAPE +#endif // !QT_NO_SHAPE xcb_window_t xcb_window() const { return m_window; } uint depth() const { return m_depth; } diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 70992fc1c0..76cdbf488b 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -45,7 +45,6 @@ contains(QT_CONFIG, xcb-poll-for-queued-event) { # needed by GLX, Xcursor, XLookupString, ... contains(QT_CONFIG, xcb-xlib) { DEFINES += XCB_USE_XLIB - !contains(DEFINES, QT_NO_SHAPE):LIBS += -lXext LIBS += -lX11 -lX11-xcb linux-g++-maemo { @@ -71,6 +70,8 @@ contains(QT_CONFIG, xcb-render) { LIBS += -lxcb-render -lxcb-render-util -lXrender } +!contains(DEFINES, QT_NO_SHAPE):LIBS += -lxcb-shape + # DEFINES += XCB_USE_DRI2 contains(DEFINES, XCB_USE_DRI2) { LIBS += -lxcb-dri2 -lEGL |