qtbase/src/plugins/platforms/wasm/qwasmwindowtreenode.h
Even Oscar Andersen 0c60d2c066 wasm: Fix focus handling
We had input handling enabled as a precondition for setting focus.
This is wrong, we need to have the focus for toggle buttons
and other non-input things as well.
(Also toggle buttons act on spacebar).

Also selects a new active window if the window
that is active (i.e a dialog) is deleted.

Also shift + tab did not always work, fixed
to emit Key_Backtab

Fixes: QTBUG-130371
Change-Id: I3b36a3e200ba9d4b0791865e75235ddfb72bcaa5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit ef8bf4c2cf3d86a869ff8a555d4e390168864144)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-27 06:47:13 +00:00

62 lines
1.7 KiB
C++

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWASMWINDOWTREENODE_H
#define QWASMWINDOWTREENODE_H
#include "qwasmwindowstack.h"
namespace emscripten {
class val;
}
class QWasmWindow;
enum class QWasmWindowTreeNodeChangeType {
NodeInsertion,
NodeRemoval,
};
class QWasmWindowTreeNode
{
public:
QWasmWindowTreeNode();
virtual ~QWasmWindowTreeNode();
virtual emscripten::val containerElement() = 0;
virtual QWasmWindowTreeNode *parentNode() = 0;
protected:
virtual void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current,
QWasmWindowStack::PositionPreference positionPreference);
virtual QWasmWindow *asWasmWindow();
virtual void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType,
QWasmWindowTreeNode *parent, QWasmWindow *child);
virtual void setWindowZOrder(QWasmWindow *window, int z);
void onPositionPreferenceChanged(QWasmWindowStack::PositionPreference positionPreference);
void setAsActiveNode();
void bringToTop();
void sendToBottom();
void shutdown();
const QWasmWindowStack &childStack() const { return m_childStack; }
QWasmWindow *activeChild() const { return m_activeChild; }
uint64_t getActiveIndex() const {
return m_activeIndex;
}
private:
void onTopWindowChanged();
void setActiveChildNode(QWasmWindow *activeChild);
uint64_t m_activeIndex = 0;
static uint64_t s_nextActiveIndex;
QWasmWindowStack m_childStack;
QWasmWindow *m_activeChild = nullptr;
};
#endif // QWASMWINDOWTREENODE_H