| | |
| | | #include <memory> |
| | | |
| | | #include <QtCore/QSet> |
| | | #include <QtGui/QRegion> |
| | | #include <QtGui/QWindow> |
| | | #include <QtGui/QPolygon> |
| | | |
| | | #include <QWKCore/corewindowagent.h> |
| | | #include <QWKCore/windowitemdelegate.h> |
| | | #include <QWKCore/windowagentbase.h> |
| | | #include <QWKCore/private/nativeeventfilter_p.h> |
| | | #include <QWKCore/private/windowitemdelegate_p.h> |
| | | |
| | | namespace QWK { |
| | | |
| | | class QWK_CORE_EXPORT AbstractWindowContext : public QObject { |
| | | class QWK_CORE_EXPORT AbstractWindowContext : public QObject, public NativeEventDispatcher { |
| | | Q_OBJECT |
| | | public: |
| | | AbstractWindowContext(); |
| | |
| | | bool setHitTestVisible(const QObject *obj, bool visible); |
| | | bool setHitTestVisible(const QRect &rect, bool visible); |
| | | |
| | | inline const QObject *systemButton(CoreWindowAgent::SystemButton button) const; |
| | | bool setSystemButton(CoreWindowAgent::SystemButton button, const QObject *obj); |
| | | inline QObject *systemButton(WindowAgentBase::SystemButton button) const; |
| | | bool setSystemButton(WindowAgentBase::SystemButton button, QObject *obj); |
| | | |
| | | inline const QObject *titleBar() const; |
| | | bool setTitleBar(const QObject *obj); |
| | | inline QObject *titleBar() const; |
| | | bool setTitleBar(QObject *obj); |
| | | |
| | | QRegion hitTestShape() const; |
| | | bool isInSystemButtons(const QPoint &pos, WindowAgentBase::SystemButton *button) const; |
| | | bool isInTitleBarDraggableArea(const QPoint &pos) const; |
| | | |
| | | virtual QString key() const; |
| | | |
| | | enum WindowContextHook { |
| | | CentralizeHook = 1, |
| | | ShowSystemMenuHook, |
| | | DefaultColorsHook, |
| | | DrawWindows10BorderHook, // Only works on Windows 10 |
| | | }; |
| | | virtual void virtual_hook(int id, void *data); |
| | | |
| | | void showSystemMenu(const QPoint &pos); |
| | | |
| | | QRegion hitTestShape() const; |
| | | bool isInSystemButtons(const QPoint &pos, CoreWindowAgent::SystemButton *button) const; |
| | | bool isInTitleBarDraggableArea(const QPoint &pos) const; |
| | | |
| | | protected: |
| | | virtual bool setupHost() = 0; |
| | | virtual bool hostEventFilter(QEvent *event); |
| | | |
| | | protected: |
| | | QObject *m_host; |
| | | QObject *m_host{}; |
| | | std::unique_ptr<WindowItemDelegate> m_delegate; |
| | | QWindow *m_windowHandle; |
| | | QWindow *m_windowHandle{}; |
| | | |
| | | QSet<const QObject *> m_hitTestVisibleItems; |
| | | QList<QRect> m_hitTestVisibleRects; |
| | | |
| | | const QObject *m_titleBar{}; |
| | | std::array<const QObject *, CoreWindowAgent::NumSystemButton> m_systemButtons{}; |
| | | QObject *m_titleBar{}; |
| | | std::array<QObject *, WindowAgentBase::NumSystemButton> m_systemButtons{}; |
| | | |
| | | // Cached shape |
| | | mutable bool hitTestVisibleShapeDirty{}; |
| | |
| | | return m_hitTestVisibleItems.contains(obj); |
| | | } |
| | | |
| | | inline const QObject * |
| | | AbstractWindowContext::systemButton(CoreWindowAgent::SystemButton button) const { |
| | | inline QObject * |
| | | AbstractWindowContext::systemButton(WindowAgentBase::SystemButton button) const { |
| | | return m_systemButtons[button]; |
| | | } |
| | | |
| | | inline const QObject *AbstractWindowContext::titleBar() const { |
| | | inline QObject *AbstractWindowContext::titleBar() const { |
| | | return m_titleBar; |
| | | } |
| | | |