diff options
author | Piotr Wierciński <[email protected]> | 2023-03-16 15:33:35 +0100 |
---|---|---|
committer | Piotr Wierciński <[email protected]> | 2023-07-19 09:25:04 +0200 |
commit | 077da0c0cd67ebe262c367a74e5c81f93edec244 (patch) | |
tree | f30494b9980c825dd650fd812318687f98aca701 | |
parent | 6f0578d7854eac81cd4ea3c84953194c4ada5abe (diff) |
Wasm: Fix displaying frameless QWasmWindow with transparent content
Currently we render shadow and default background-color even for
frameless windows with transparent content.
This behavior is not consistent comparing to other platforms.
An example of such window is InputSelectionHandle from
VirtualKeyboard module.
This commit disables shadow-box and provides transparent
background-color for QWasmWindow which are frameless.
It also provides distinction between "frame" as logic property
of window and "border" as visual decoration.
Change-Id: I902692ea561a2e88e2e6ab7faad8e3eeb536a26b
Reviewed-by: Aleksandr Reviakin <[email protected]>
Reviewed-by: Mikołaj Boc <[email protected]>
(cherry picked from commit c6e04356d46c219176faba3ab868410a22c26cce)
Reviewed-by: Lorn Potter <[email protected]>
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcssstyle.cpp | 10 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.cpp | 15 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.h | 3 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcssstyle.cpp b/src/plugins/platforms/wasm/qwasmcssstyle.cpp index 5005d1aedcf..c0873880b6d 100644 --- a/src/plugins/platforms/wasm/qwasmcssstyle.cpp +++ b/src/plugins/platforms/wasm/qwasmcssstyle.cpp @@ -43,17 +43,21 @@ const char *Style = R"css( box-shadow: rgb(0 0 0 / 20%) 0px 10px 16px 0px, rgb(0 0 0 / 19%) 0px 6px 20px 0px; } -.qt-window.has-frame { +.qt-window.has-border { border: var(--border-width) solid lightgray; caret-color: transparent; } +.qt-window.frameless { + background-color: transparent; +} + .resize-outline { position: absolute; display: none; } -.qt-window.has-frame:not(.maximized) .resize-outline { +.qt-window.has-border:not(.maximized) .resize-outline { display: block; } @@ -129,7 +133,7 @@ const char *Style = R"css( padding-bottom: 4px; } -.qt-window.has-frame .title-bar { +.qt-window.has-border .title-bar { display: flex; } diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 638d78b5b52..cbcc1733e18 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -375,9 +375,10 @@ void QWasmWindow::onActivationChanged(bool active) void QWasmWindow::setWindowFlags(Qt::WindowFlags flags) { m_flags = flags; - dom::syncCSSClassWith(m_qtWindow, "has-frame", hasFrame()); - dom::syncCSSClassWith(m_qtWindow, "has-shadow", !flags.testFlag(Qt::NoDropShadowWindowHint)); + dom::syncCSSClassWith(m_qtWindow, "has-border", hasBorder()); + dom::syncCSSClassWith(m_qtWindow, "has-shadow", hasShadow()); dom::syncCSSClassWith(m_qtWindow, "has-title", flags.testFlag(Qt::WindowTitleHint)); + dom::syncCSSClassWith(m_qtWindow, "frameless", flags.testFlag(Qt::FramelessWindowHint)); dom::syncCSSClassWith(m_qtWindow, "transparent-for-input", flags.testFlag(Qt::WindowTransparentForInput)); @@ -443,7 +444,7 @@ void QWasmWindow::applyWindowState() else newGeom = normalGeometry(); - dom::syncCSSClassWith(m_qtWindow, "has-frame", hasFrame()); + dom::syncCSSClassWith(m_qtWindow, "has-border", hasBorder()); dom::syncCSSClassWith(m_qtWindow, "maximized", isMaximized); m_nonClientArea->titleBar()->setRestoreVisible(isMaximized); @@ -560,12 +561,18 @@ void QWasmWindow::requestUpdate() m_compositor->requestUpdateWindow(this, QWasmCompositor::UpdateRequestDelivery); } -bool QWasmWindow::hasFrame() const +bool QWasmWindow::hasBorder() const { return !m_state.testFlag(Qt::WindowFullScreen) && !m_flags.testFlag(Qt::FramelessWindowHint) && !windowIsPopupType(m_flags); } +bool QWasmWindow::hasShadow() const +{ + return !m_flags.testFlag(Qt::NoDropShadowWindowHint) + && !m_flags.testFlag(Qt::FramelessWindowHint); +} + bool QWasmWindow::hasMaximizeButton() const { return !m_state.testFlag(Qt::WindowMaximized) && m_flags.testFlag(Qt::WindowMaximizeButtonHint); diff --git a/src/plugins/platforms/wasm/qwasmwindow.h b/src/plugins/platforms/wasm/qwasmwindow.h index 3236757aee3..f38b44d4e80 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.h +++ b/src/plugins/platforms/wasm/qwasmwindow.h @@ -97,7 +97,8 @@ private: static constexpr auto minSizeForRegularWindows = 100; void invalidate(); - bool hasFrame() const; + bool hasBorder() const; + bool hasShadow() const; bool hasMaximizeButton() const; void applyWindowState(); |