From 0549a4b6f52e6929daec4b0c97df2085739bc719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 12 Dec 2012 09:15:14 +0100 Subject: [PATCH] Made QWidget::setWindowOpacity work with the XCB platform plugin. Ported the rather trivial implementation from Qt 4. Task-number: QTBUG-28477 Change-Id: I44e14a3c150af43c6b9b880242b655fe06084fd7 Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbwindow.cpp | 17 +++++++++++++++++ src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 5e4e749c83..0db4176607 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1786,6 +1786,23 @@ static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r) return result; } +void QXcbWindow::setOpacity(qreal level) +{ + if (!m_window) + return; + + quint32 value = qRound64(qBound(qreal(0), level, qreal(1)) * 0xffffffff); + + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::_NET_WM_WINDOW_OPACITY), + XCB_ATOM_CARDINAL, + 32, + 1, + (uchar *)&value)); +} + void QXcbWindow::setMask(const QRegion ®ion) { if (!connection()->hasXShape()) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index bd4d18a175..07ac0e0fcb 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -109,6 +109,8 @@ public: bool startSystemResize(const QPoint &pos, Qt::Corner corner); + void setOpacity(qreal level); + #if !defined(QT_NO_SHAPE) void setMask(const QRegion ®ion); #endif // !QT_NO_SHAPE