diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 1e046aa677..979c8142f7 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -520,16 +520,7 @@ void QXcbShmImage::setClip(const QRegion ®ion) static const uint32_t values[] = { XCB_NONE }; xcb_change_gc(xcb_connection(), m_gc, mask, values); } else { - const QVector qrects = region.rects(); - QVector xcb_rects(qrects.size()); - - for (int i = 0; i < qrects.size(); i++) { - xcb_rects[i].x = qrects[i].x(); - xcb_rects[i].y = qrects[i].y(); - xcb_rects[i].width = qrects[i].width(); - xcb_rects[i].height = qrects[i].height(); - } - + const auto xcb_rects = qRegionToXcbRectangleList(region); xcb_set_clip_rectangles(xcb_connection(), XCB_CLIP_ORDERING_YX_BANDED, m_gc, diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 5ea865f74a..e7096fb8f0 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2776,6 +2776,15 @@ void QXcbWindow::setOpacity(qreal level) (uchar *)&value); } +QVector qRegionToXcbRectangleList(const QRegion ®ion) +{ + QVector rects; + rects.reserve(region.rectCount()); + for (const QRect &r : region) + rects.push_back(qRectToXCBRectangle(r)); + return rects; +} + void QXcbWindow::setMask(const QRegion ®ion) { if (!connection()->hasXShape()) @@ -2784,10 +2793,7 @@ void QXcbWindow::setMask(const QRegion ®ion) xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE); } else { - QVector rects; - rects.reserve(region.rectCount()); - for (const QRect &r : region) - rects.push_back(qRectToXCBRectangle(r)); + const auto rects = qRegionToXcbRectangleList(region); 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]); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index b89dddf72f..638ab26cea 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -296,6 +296,8 @@ protected: void create() override {} // No-op }; +QVector qRegionToXcbRectangleList(const QRegion ®ion); + QT_END_NAMESPACE Q_DECLARE_METATYPE(QXcbWindow*)