123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 | // Copyright (C) 2018 The Qt Company Ltd.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only#ifndef QWASMWINDOW_H#define QWASMWINDOW_H#include"qwasmintegration.h"#include"qwasmbackingstore.h"#include"qwasmscreen.h"#include"qwasmcompositor.h"#include"qwasmwindownonclientarea.h"#include"qwasmwindowstack.h"#include"qwasmwindowtreenode.h"#include"qwasmevent.h"#include <QtCore/private/qstdweb_p.h>#include <qpa/qwindowsysteminterface.h>#include <qpa/qplatformwindow.h>#include <qpa/qplatformwindow_p.h>#include <emscripten/val.h>#include <emscripten/html5.h>#include <memory> QT_BEGIN_NAMESPACE namespace qstdweb {class EventCallback;}struct KeyEvent;struct PointerEvent;class QWasmDeadKeySupport;struct WheelEvent;Q_DECLARE_LOGGING_CATEGORY(qLcQpaWasmInputContext)class QWasmWindow final :public QPlatformWindow,public QWasmWindowTreeNode,public QNativeInterface::Private::QWasmWindow {public:QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport, QWasmCompositor *compositor, QWasmBackingStore *backingStore, WId nativeHandle);~QWasmWindow() final;static QWasmWindow *fromWindow(const QWindow *window); QSurfaceFormat format()const override;voidregisterEventHandlers();voidpaint();voidsetZOrder(int order);voidsetWindowCursor(QByteArray cssCursorName);voidonActivationChanged(bool active);boolisVisible()const;voidonNonClientAreaInteraction();voidonRestoreClicked();voidonMaximizeClicked();voidonToggleMaximized();voidonCloseClicked();boolonNonClientEvent(const PointerEvent &event);// QPlatformWindow:voidinitialize() override;voidsetGeometry(const QRect &) override;voidsetVisible(bool visible) override; QMargins frameMargins()const override; WId winId()const override;voidpropagateSizeHints() override;voidsetOpacity(qreal level) override;voidraise() override;voidlower() override; QRect normalGeometry()const override; qreal devicePixelRatio()const override;voidrequestUpdate() override;voidrequestActivateWindow() override;voidsetWindowFlags(Qt::WindowFlags flags) override;voidsetWindowState(Qt::WindowStates state) override;voidsetWindowTitle(const QString &title) override;voidsetWindowIcon(const QIcon &icon) override;boolsetKeyboardGrabEnabled(bool) override {return false; }boolsetMouseGrabEnabled(bool grab) final;boolwindowEvent(QEvent *event) final;voidsetMask(const QRegion ®ion) final;voidsetParent(const QPlatformWindow *window) final;voidfocus(); QWasmScreen *platformScreen()const;voidsetBackingStore(QWasmBackingStore *store) { m_backingStore = store; } QWasmBackingStore *backingStore()const{return m_backingStore; }std::string canvasSelector()const;emscripten::val context2d()const{return m_context2d; }emscripten::val a11yContainer()const{return m_a11yContainer; }emscripten::val inputHandlerElement()const{return m_window; }// QNativeInterface::Private::QWasmWindowemscripten::val document()const override {return m_document; }emscripten::val clientArea()const override {return m_decoratedWindow; }// QWasmWindowTreeNode:emscripten::val containerElement() final; QWasmWindowTreeNode *parentNode() final;private:friend class QWasmScreen;staticconstexpr auto defaultWindowSize =160;// QWasmWindowTreeNode: QWasmWindow *asWasmWindow() final;voidonParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current,QWasmWindowStack::PositionPreference positionPreference) final;voidinvalidate();boolhasFrame()const;boolhasTitleBar()const;boolhasBorder()const;boolhasShadow()const;boolhasMaximizeButton()const;voidapplyWindowState();voidcommitParent(QWasmWindowTreeNode *parent);voidhandleKeyEvent(const KeyEvent &event);boolprocessKey(const KeyEvent &event);voidhandleKeyForInputContextEvent(EventType eventType,constemscripten::val &event);boolprocessKeyForInputContext(const KeyEvent &event);voidhandlePointerEnterLeaveEvent(const PointerEvent &event);boolprocessPointerEnterLeave(const PointerEvent &event);voidprocessPointer(const PointerEvent &event);booldeliverPointerEvent(const PointerEvent &event);voidhandleWheelEvent(constemscripten::val &event);boolprocessWheel(const WheelEvent &event); QWasmCompositor *m_compositor =nullptr; QWasmBackingStore *m_backingStore =nullptr; QWasmDeadKeySupport *m_deadKeySupport; QRect m_normalGeometry {0,0,0,0};emscripten::val m_document =emscripten::val::undefined();emscripten::val m_decoratedWindow =emscripten::val::undefined();emscripten::val m_window =emscripten::val::undefined();emscripten::val m_windowInput =emscripten::val::undefined();emscripten::val m_a11yContainer =emscripten::val::undefined();emscripten::val m_canvas =emscripten::val::undefined();emscripten::val m_context2d =emscripten::val::undefined();std::unique_ptr<NonClientArea> m_nonClientArea; QWasmWindowTreeNode *m_commitedParent =nullptr; QWasmEventHandler m_keyDownCallback; QWasmEventHandler m_keyUpCallback; QWasmEventHandler m_keyDownCallbackForInputContext; QWasmEventHandler m_keyUpCallbackForInputContext; QWasmEventHandler m_pointerDownCallback; QWasmEventHandler m_pointerMoveCallback; QWasmEventHandler m_pointerUpCallback; QWasmEventHandler m_pointerCancelCallback; QWasmEventHandler m_pointerLeaveCallback; QWasmEventHandler m_pointerEnterCallback; QWasmEventHandler m_dragOverCallback; QWasmEventHandler m_dragStartCallback; QWasmEventHandler m_dragEndCallback; QWasmEventHandler m_dropCallback; QWasmEventHandler m_dragLeaveCallback; QWasmEventHandler m_wheelEventCallback; QMap<int,QWindowSystemInterface::TouchPoint> m_pointerIdToTouchPoints; QWasmEventHandler m_cutCallback; QWasmEventHandler m_copyCallback; QWasmEventHandler m_pasteCallback; QWasmEventHandler m_beforeInputCallback; QWasmEventHandler m_inputCallback;Qt::WindowStates m_state =Qt::WindowNoState;Qt::WindowStates m_previousWindowState =Qt::WindowNoState;Qt::WindowFlags m_flags =Qt::Widget; QPoint m_lastPointerMovePoint; WId m_winId =0;bool m_wantCapture =false;bool m_hasTitle =false;bool m_needsCompositor =false;long m_requestAnimationFrameId = -1;friend class QWasmCompositor;friend class QWasmEventTranslator;boolwindowIsPopupType(Qt::WindowFlags flags)const;}; QT_END_NAMESPACE #endif// QWASMWINDOW_H
|