+bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)
+{
+ const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE);
+ if (!connection()->wmSupport()->isSupportedByWM(moveResize))
+ return false;
+ xcb_client_message_event_t xev;
+ xev.response_type = XCB_CLIENT_MESSAGE;
+ xev.type = moveResize;
+ xev.window = xcb_window();
+ xev.format = 32;
+ const QPoint globalPos = window()->mapToGlobal(pos);
+ xev.data.data32[0] = globalPos.x();
+ xev.data.data32[1] = globalPos.y();
+ const bool bottom = corner == Qt::BottomRightCorner || corner == Qt::BottomLeftCorner;
+ const bool left = corner == Qt::BottomLeftCorner || corner == Qt::TopLeftCorner;
+ if (bottom)
+ xev.data.data32[2] = left ? 6 : 4; // bottomleft/bottomright
+ else
+ xev.data.data32[2] = left ? 0 : 2; // topleft/topright
+ xev.data.data32[3] = XCB_BUTTON_INDEX_1;
+ xev.data.data32[4] = 0;
+ xcb_ungrab_pointer(connection()->xcb_connection(), XCB_CURRENT_TIME);
+ xcb_send_event(connection()->xcb_connection(), false, m_screen->root(),
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
+ (const char *)&xev);
+ return true;
+}
+
+#if !defined(QT_NO_SHAPE)
+
+static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r)
+{
+ 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());
+ result.height = qMin((int)USHRT_MAX, r.height());
+ return result;
+}
+
+void QXcbWindow::setMask(const QRegion ®ion)
+{
+ if (!connection()->hasXShape())
+ return;
+ if (region.isEmpty()) {
+ xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
+ XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE);
+ } else {
+ 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 // !QT_NO_SHAPE
+