mirror of https://github.com/qt/qtbase.git
wasm: rename qt-window -> qt-decorated-window
This is the parent element for the window decorations (title bar, resize handles), and also the window contents. Task-number: QTBUG-128732 Change-Id: I9ba814a7cf8477ab767278fe6548cd05e83266ca Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
parent
8f7fc8e9af
commit
2ab07b4558
|
@ -30,7 +30,7 @@ const char *Style = R"css(
|
|||
touch-action: none;
|
||||
}
|
||||
|
||||
.qt-window {
|
||||
.qt-decorated-window {
|
||||
position: absolute;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
@ -40,20 +40,20 @@ const char *Style = R"css(
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.qt-window.transparent-for-input {
|
||||
.qt-decorated-window.transparent-for-input {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.qt-window.has-shadow {
|
||||
.qt-decorated-window.has-shadow {
|
||||
box-shadow: rgb(0 0 0 / 20%) 0px 10px 16px 0px, rgb(0 0 0 / 19%) 0px 6px 20px 0px;
|
||||
}
|
||||
|
||||
.qt-window.has-border {
|
||||
.qt-decorated-window.has-border {
|
||||
border: var(--border-width) solid lightgray;
|
||||
caret-color: transparent;
|
||||
}
|
||||
|
||||
.qt-window.frameless {
|
||||
.qt-decorated-window.frameless {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ const char *Style = R"css(
|
|||
display: none;
|
||||
}
|
||||
|
||||
.qt-window.no-resize > .resize-outline { display: none; }
|
||||
.qt-decorated-window.no-resize > .resize-outline { display: none; }
|
||||
|
||||
.qt-window.has-border:not(.maximized):not(.no-resize) > .resize-outline {
|
||||
.qt-decorated-window.has-border:not(.maximized):not(.no-resize) > .resize-outline {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ const char *Style = R"css(
|
|||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.qt-window.has-border > .title-bar {
|
||||
.qt-decorated-window.has-border > .title-bar {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ const char *Style = R"css(
|
|||
}
|
||||
|
||||
|
||||
.qt-window.has-title .title-bar .window-name {
|
||||
.qt-decorated-window.has-title .title-bar .window-name {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ const char *Style = R"css(
|
|||
flex-grow: 1
|
||||
}
|
||||
|
||||
.qt-window.inactive .title-bar {
|
||||
.qt-decorated-window.inactive .title-bar {
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ const char *Style = R"css(
|
|||
pointer-events: all;
|
||||
}
|
||||
|
||||
.qt-window.blocked div {
|
||||
.qt-decorated-window.blocked div {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,21 +54,21 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
|
|||
m_backingStore(backingStore),
|
||||
m_deadKeySupport(deadKeySupport),
|
||||
m_document(dom::document()),
|
||||
m_qtWindow(m_document.call<emscripten::val>("createElement", emscripten::val("div"))),
|
||||
m_decoratedWindow(m_document.call<emscripten::val>("createElement", emscripten::val("div"))),
|
||||
m_windowContents(m_document.call<emscripten::val>("createElement", emscripten::val("div"))),
|
||||
m_a11yContainer(m_document.call<emscripten::val>("createElement", emscripten::val("div"))),
|
||||
m_canvas(m_document.call<emscripten::val>("createElement", emscripten::val("canvas")))
|
||||
{
|
||||
m_qtWindow.set("className", "qt-window");
|
||||
m_qtWindow["style"].set("display", std::string("none"));
|
||||
m_decoratedWindow.set("className", "qt-decorated-window");
|
||||
m_decoratedWindow["style"].set("display", std::string("none"));
|
||||
|
||||
m_nonClientArea = std::make_unique<NonClientArea>(this, m_qtWindow);
|
||||
m_nonClientArea = std::make_unique<NonClientArea>(this, m_decoratedWindow);
|
||||
m_nonClientArea->titleBar()->setTitle(window()->title());
|
||||
|
||||
m_clientArea = std::make_unique<ClientArea>(this, compositor->screen(), m_windowContents);
|
||||
|
||||
m_windowContents.set("className", "qt-window-contents");
|
||||
m_qtWindow.call<void>("appendChild", m_windowContents);
|
||||
m_decoratedWindow.call<void>("appendChild", m_windowContents);
|
||||
|
||||
m_canvas["classList"].call<void>("add", emscripten::val("qt-window-canvas"));
|
||||
|
||||
|
@ -95,7 +95,7 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
|
|||
m_context2d = m_canvas.call<emscripten::val>("getContext", emscripten::val("2d"));
|
||||
static int serialNo = 0;
|
||||
m_winId = ++serialNo;
|
||||
m_qtWindow.set("id", "qt-window-" + std::to_string(m_winId));
|
||||
m_decoratedWindow.set("id", "qt-window-" + std::to_string(m_winId));
|
||||
emscripten::val::module_property("specialHTMLTargets").set(canvasSelector(), m_canvas);
|
||||
|
||||
m_flags = window()->flags();
|
||||
|
@ -227,7 +227,7 @@ void QWasmWindow::paint()
|
|||
|
||||
void QWasmWindow::setZOrder(int z)
|
||||
{
|
||||
m_qtWindow["style"].set("zIndex", std::to_string(z));
|
||||
m_decoratedWindow["style"].set("zIndex", std::to_string(z));
|
||||
}
|
||||
|
||||
void QWasmWindow::setWindowCursor(QByteArray cssCursorName)
|
||||
|
@ -274,8 +274,8 @@ void QWasmWindow::setGeometry(const QRect &rect)
|
|||
.adjusted(-margins.left(), -margins.top(), margins.right(), margins.bottom())
|
||||
.translated(!parent() ? -screen()->geometry().topLeft() : QPoint());
|
||||
|
||||
m_qtWindow["style"].set("left", std::to_string(frameRect.left()) + "px");
|
||||
m_qtWindow["style"].set("top", std::to_string(frameRect.top()) + "px");
|
||||
m_decoratedWindow["style"].set("left", std::to_string(frameRect.left()) + "px");
|
||||
m_decoratedWindow["style"].set("top", std::to_string(frameRect.top()) + "px");
|
||||
m_canvas["style"].set("width", std::to_string(clientAreaRect.width()) + "px");
|
||||
m_canvas["style"].set("height", std::to_string(clientAreaRect.height()) + "px");
|
||||
m_a11yContainer["style"].set("width", std::to_string(clientAreaRect.width()) + "px");
|
||||
|
@ -304,12 +304,12 @@ void QWasmWindow::setGeometry(const QRect &rect)
|
|||
void QWasmWindow::setVisible(bool visible)
|
||||
{
|
||||
// TODO(mikolajboc): isVisible()?
|
||||
const bool nowVisible = m_qtWindow["style"]["display"].as<std::string>() == "block";
|
||||
const bool nowVisible = m_decoratedWindow["style"]["display"].as<std::string>() == "block";
|
||||
if (visible == nowVisible)
|
||||
return;
|
||||
|
||||
m_compositor->requestUpdateWindow(this, QRect(QPoint(0, 0), geometry().size()), QWasmCompositor::ExposeEventDelivery);
|
||||
m_qtWindow["style"].set("display", visible ? "block" : "none");
|
||||
m_decoratedWindow["style"].set("display", visible ? "block" : "none");
|
||||
if (window()->isActive())
|
||||
m_canvas.call<void>("focus");
|
||||
if (visible)
|
||||
|
@ -324,7 +324,7 @@ bool QWasmWindow::isVisible() const
|
|||
QMargins QWasmWindow::frameMargins() const
|
||||
{
|
||||
const auto frameRect =
|
||||
QRectF::fromDOMRect(m_qtWindow.call<emscripten::val>("getBoundingClientRect"));
|
||||
QRectF::fromDOMRect(m_decoratedWindow.call<emscripten::val>("getBoundingClientRect"));
|
||||
const auto canvasRect =
|
||||
QRectF::fromDOMRect(m_windowContents.call<emscripten::val>("getBoundingClientRect"));
|
||||
return QMarginsF(canvasRect.left() - frameRect.left(), canvasRect.top() - frameRect.top(),
|
||||
|
@ -359,7 +359,7 @@ void QWasmWindow::propagateSizeHints()
|
|||
|
||||
void QWasmWindow::setOpacity(qreal level)
|
||||
{
|
||||
m_qtWindow["style"].set("opacity", qBound(0.0, level, 1.0));
|
||||
m_decoratedWindow["style"].set("opacity", qBound(0.0, level, 1.0));
|
||||
}
|
||||
|
||||
void QWasmWindow::invalidate()
|
||||
|
@ -369,7 +369,7 @@ void QWasmWindow::invalidate()
|
|||
|
||||
void QWasmWindow::onActivationChanged(bool active)
|
||||
{
|
||||
dom::syncCSSClassWith(m_qtWindow, "inactive", !active);
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "inactive", !active);
|
||||
}
|
||||
|
||||
// Fix top level window flags in case only the type flags are passed.
|
||||
|
@ -399,11 +399,11 @@ void QWasmWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
onPositionPreferenceChanged(positionPreferenceFromWindowFlags(flags));
|
||||
}
|
||||
m_flags = flags;
|
||||
dom::syncCSSClassWith(m_qtWindow, "frameless", !hasFrame() || !window()->isTopLevel());
|
||||
dom::syncCSSClassWith(m_qtWindow, "has-border", hasBorder());
|
||||
dom::syncCSSClassWith(m_qtWindow, "has-shadow", hasShadow());
|
||||
dom::syncCSSClassWith(m_qtWindow, "has-title", hasTitleBar());
|
||||
dom::syncCSSClassWith(m_qtWindow, "transparent-for-input",
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "frameless", !hasFrame() || !window()->isTopLevel());
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "has-border", hasBorder());
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "has-shadow", hasShadow());
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "has-title", hasTitleBar());
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "transparent-for-input",
|
||||
flags.testFlag(Qt::WindowTransparentForInput));
|
||||
|
||||
m_nonClientArea->titleBar()->setMaximizeVisible(hasMaximizeButton());
|
||||
|
@ -468,8 +468,8 @@ void QWasmWindow::applyWindowState()
|
|||
else
|
||||
newGeom = normalGeometry();
|
||||
|
||||
dom::syncCSSClassWith(m_qtWindow, "has-border", hasBorder());
|
||||
dom::syncCSSClassWith(m_qtWindow, "maximized", isMaximized);
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "has-border", hasBorder());
|
||||
dom::syncCSSClassWith(m_decoratedWindow, "maximized", isMaximized);
|
||||
|
||||
m_nonClientArea->titleBar()->setRestoreVisible(isMaximized);
|
||||
m_nonClientArea->titleBar()->setMaximizeVisible(hasMaximizeButton());
|
||||
|
@ -724,10 +724,10 @@ bool QWasmWindow::windowEvent(QEvent *event)
|
|||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::WindowBlocked:
|
||||
m_qtWindow["classList"].call<void>("add", emscripten::val("blocked"));
|
||||
m_decoratedWindow["classList"].call<void>("add", emscripten::val("blocked"));
|
||||
return false; // Propagate further
|
||||
case QEvent::WindowUnblocked:;
|
||||
m_qtWindow["classList"].call<void>("remove", emscripten::val("blocked"));
|
||||
m_decoratedWindow["classList"].call<void>("remove", emscripten::val("blocked"));
|
||||
return false; // Propagate further
|
||||
default:
|
||||
return QPlatformWindow::windowEvent(event);
|
||||
|
@ -737,7 +737,7 @@ bool QWasmWindow::windowEvent(QEvent *event)
|
|||
void QWasmWindow::setMask(const QRegion ®ion)
|
||||
{
|
||||
if (region.isEmpty()) {
|
||||
m_qtWindow["style"].set("clipPath", emscripten::val(""));
|
||||
m_decoratedWindow["style"].set("clipPath", emscripten::val(""));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -751,7 +751,7 @@ void QWasmWindow::setMask(const QRegion ®ion)
|
|||
cssClipPath << "L " << cssRect.left() << " " << cssRect.bottom() << " z ";
|
||||
}
|
||||
cssClipPath << "')";
|
||||
m_qtWindow["style"].set("clipPath", emscripten::val(cssClipPath.str()));
|
||||
m_decoratedWindow["style"].set("clipPath", emscripten::val(cssClipPath.str()));
|
||||
}
|
||||
|
||||
void QWasmWindow::setParent(const QPlatformWindow *)
|
||||
|
@ -789,9 +789,9 @@ void QWasmWindow::onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTree
|
|||
QWasmWindowStack::PositionPreference positionPreference)
|
||||
{
|
||||
if (previous)
|
||||
previous->containerElement().call<void>("removeChild", m_qtWindow);
|
||||
previous->containerElement().call<void>("removeChild", m_decoratedWindow);
|
||||
if (current)
|
||||
current->containerElement().call<void>("appendChild", m_qtWindow);
|
||||
current->containerElement().call<void>("appendChild", m_decoratedWindow);
|
||||
QWasmWindowTreeNode::onParentChanged(previous, current, positionPreference);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
|
||||
// QNativeInterface::Private::QWasmWindow
|
||||
emscripten::val document() const override { return m_document; }
|
||||
emscripten::val clientArea() const override { return m_qtWindow; }
|
||||
emscripten::val clientArea() const override { return m_decoratedWindow; }
|
||||
|
||||
// QWasmWindowTreeNode:
|
||||
emscripten::val containerElement() final;
|
||||
|
@ -137,7 +137,7 @@ private:
|
|||
QRect m_normalGeometry {0, 0, 0 ,0};
|
||||
|
||||
emscripten::val m_document;
|
||||
emscripten::val m_qtWindow;
|
||||
emscripten::val m_decoratedWindow;
|
||||
emscripten::val m_windowContents;
|
||||
emscripten::val m_a11yContainer;
|
||||
emscripten::val m_canvas;
|
||||
|
|
Loading…
Reference in New Issue