1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2018 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the plugins of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 or (at your option) any later version 20 ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 ** included in the packaging of this file. Please review the following 23 ** information to ensure the GNU General Public License requirements will 24 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 ** 26 ** $QT_END_LICENSE$ 27 ** 28 ****************************************************************************/ 29 30 #ifndef QWASMWINDOW_H 31 #define QWASMWINDOW_H 32 33 #include "qwasmintegration.h" 34 #include <qpa/qplatformwindow.h> 35 #include <emscripten/html5.h> 36 #include "qwasmbackingstore.h" 37 #include "qwasmscreen.h" 38 #include "qwasmcompositor.h" 39 40 QT_BEGIN_NAMESPACE 41 42 class QWasmCompositor; 43 44 class QWasmWindow : public QPlatformWindow 45 { 46 public: 47 enum ResizeMode { 48 ResizeNone, 49 ResizeTopLeft, 50 ResizeTop, 51 ResizeTopRight, 52 ResizeRight, 53 ResizeBottomRight, 54 ResizeBottom, 55 ResizeBottomLeft, 56 ResizeLeft 57 }; 58 59 QWasmWindow(QWindow *w, QWasmCompositor *compositor, QWasmBackingStore *backingStore); 60 ~QWasmWindow(); 61 void destroy(); 62 63 void initialize() override; 64 65 void setGeometry(const QRect &) override; 66 void setVisible(bool visible) override; 67 QMargins frameMargins() const override; 68 69 WId winId() const override; 70 71 void propagateSizeHints() override; 72 void raise() override; 73 void lower() override; 74 QRect normalGeometry() const override; 75 qreal devicePixelRatio() const override; 76 void requestUpdate() override; 77 78 QWasmScreen *platformScreen() const; setBackingStore(QWasmBackingStore * store)79 void setBackingStore(QWasmBackingStore *store) { m_backingStore = store; } backingStore()80 QWasmBackingStore *backingStore() const { return m_backingStore; } window()81 QWindow *window() const { return m_window; } 82 83 void injectMousePressed(const QPoint &local, const QPoint &global, 84 Qt::MouseButton button, Qt::KeyboardModifiers mods); 85 void injectMouseReleased(const QPoint &local, const QPoint &global, 86 Qt::MouseButton button, Qt::KeyboardModifiers mods); 87 88 int titleHeight() const; 89 int borderWidth() const; 90 QRegion titleGeometry() const; 91 QRegion resizeRegion() const; 92 bool isPointOnTitle(QPoint point) const; 93 bool isPointOnResizeRegion(QPoint point) const; 94 ResizeMode resizeModeAtPoint(QPoint point) const; 95 QRect maxButtonRect() const; 96 QRect minButtonRect() const; 97 QRect closeButtonRect() const; 98 QRect sysMenuRect() const; 99 QRect normButtonRect() const; 100 QRegion titleControlRegion() const; 101 QWasmCompositor::SubControls activeSubControl() const; 102 103 void setWindowState(Qt::WindowStates state) override; setKeyboardGrabEnabled(bool)104 bool setKeyboardGrabEnabled(bool) override { return false; } setMouseGrabEnabled(bool)105 bool setMouseGrabEnabled(bool) override { return false; } 106 107 protected: 108 void invalidate(); 109 bool hasTitleBar() const; 110 111 protected: 112 friend class QWasmScreen; 113 114 QWindow* m_window = nullptr; 115 QWasmCompositor *m_compositor = nullptr; 116 QWasmBackingStore *m_backingStore = nullptr; 117 QRect m_normalGeometry {0, 0, 0 ,0}; 118 119 Qt::WindowState m_windowState = Qt::WindowNoState; 120 QWasmCompositor::SubControls m_activeControl = QWasmCompositor::SC_None; 121 WId m_winid = 0; 122 bool m_hasTitle = false; 123 bool m_needsCompositor = false; 124 friend class QWasmCompositor; 125 friend class QWasmEventTranslator; 126 }; 127 QT_END_NAMESPACE 128 #endif // QWASMWINDOW_H 129