Skip to content

Commit 19d7459

Browse files
committed
core/window: premultiply background colors
Apparently these are supposed to be premultiplied. Some docs would be nice.
1 parent 2c485e4 commit 19d7459

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/core/proxywindow.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,23 @@ QuickshellScreenInfo* ProxyWindowBase::screen() const {
287287
return QuickshellTracked::instance()->screenInfo(qscreen);
288288
}
289289

290-
QColor ProxyWindowBase::color() const {
291-
if (this->window == nullptr) return this->mColor;
292-
else return this->window->color();
293-
}
290+
QColor ProxyWindowBase::color() const { return this->mColor; }
294291

295292
void ProxyWindowBase::setColor(QColor color) {
293+
this->mColor = color;
294+
296295
if (this->window == nullptr) {
297-
this->mColor = color;
298-
emit this->colorChanged();
299-
} else this->window->setColor(color);
296+
if (color != this->mColor) emit this->colorChanged();
297+
} else {
298+
auto premultiplied = QColor::fromRgbF(
299+
color.redF() * color.alphaF(),
300+
color.greenF() * color.alphaF(),
301+
color.blueF() * color.alphaF(),
302+
color.alphaF()
303+
);
304+
305+
this->window->setColor(premultiplied);
306+
}
300307
}
301308

302309
PendingRegion* ProxyWindowBase::mask() const { return this->mMask; }

src/core/windowinterface.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ class WindowInterface: public Reloadable {
4646
/// along with map[To|From]Item (which is not reactive).
4747
Q_PROPERTY(QObject* windowTransform READ windowTransform NOTIFY windowTransformChanged);
4848
/// The background color of the window. Defaults to white.
49-
///
50-
/// > [!WARNING] This seems to behave weirdly when using transparent colors on some systems.
51-
/// > Using a colored content item over a transparent window is the recommended way to work around this:
52-
/// > ```qml
53-
/// > ProxyWindow {
54-
/// > color: "transparent"
55-
/// > Rectangle {
56-
/// > anchors.fill: parent
57-
/// > color: "#20ffffff"
58-
/// >
59-
/// > // your content here
60-
/// > }
61-
/// > }
62-
/// > ```
6349
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged);
6450
/// The clickthrough mask. Defaults to null.
6551
///

0 commit comments

Comments
 (0)