| | |
| | | |
| | | AbstractWindowContext::~AbstractWindowContext() = default; |
| | | |
| | | class EventFilterForwarder : public QObject { |
| | | public: |
| | | using EventProc = bool (*)(QEvent *, void *); |
| | | |
| | | EventFilterForwarder(EventProc proc, void *user, QObject *parent = nullptr) |
| | | : QObject(parent), proc(proc), user(user) { |
| | | } |
| | | |
| | | bool eventFilter(QObject *obj, QEvent *event) override { |
| | | Q_UNUSED(obj) |
| | | return proc(event, user); |
| | | } |
| | | |
| | | protected: |
| | | EventProc proc; |
| | | void *user; |
| | | }; |
| | | |
| | | bool AbstractWindowContext::setup(QObject *host, WindowItemDelegate *delegate) { |
| | | if (!host || !delegate) { |
| | | return false; |
| | |
| | | m_windowHandle = nullptr; |
| | | return false; |
| | | } |
| | | |
| | | // Install specific event filter |
| | | host->installEventFilter(new EventFilterForwarder( |
| | | [](QEvent *event, void *user) { |
| | | return reinterpret_cast<AbstractWindowContext *>(user)->hostEventFilter(event); |
| | | }, |
| | | this, this)); |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | bool AbstractWindowContext::setSystemButton(CoreWindowAgent::SystemButton button, |
| | | bool AbstractWindowContext::setSystemButton(WindowAgentBase::SystemButton button, |
| | | const QObject *obj) { |
| | | Q_ASSERT(obj); |
| | | Q_ASSERT(button != CoreWindowAgent::Unknown); |
| | | if (!obj || (button == CoreWindowAgent::Unknown)) { |
| | | Q_ASSERT(button != WindowAgentBase::Unknown); |
| | | if (!obj || (button == WindowAgentBase::Unknown)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | void AbstractWindowContext::showSystemMenu(const QPoint &pos) { |
| | | // ? |
| | | } |
| | | void AbstractWindowContext::showSystemMenu(const QPoint &pos){Q_UNUSED(pos)} |
| | | |
| | | QRegion AbstractWindowContext::hitTestShape() const { |
| | | if (hitTestVisibleShapeDirty) { |
| | |
| | | } |
| | | |
| | | bool AbstractWindowContext::isInSystemButtons(const QPoint &pos, |
| | | CoreWindowAgent::SystemButton *button) const { |
| | | *button = CoreWindowAgent::Unknown; |
| | | for (int i = CoreWindowAgent::WindowIcon; i <= CoreWindowAgent::Close; ++i) { |
| | | WindowAgentBase::SystemButton *button) const { |
| | | *button = WindowAgentBase::Unknown; |
| | | for (int i = WindowAgentBase::WindowIcon; i <= WindowAgentBase::Close; ++i) { |
| | | auto currentButton = m_systemButtons[i]; |
| | | if (!currentButton || !m_delegate->isVisible(currentButton) || |
| | | !m_delegate->isEnabled(currentButton)) { |
| | | continue; |
| | | } |
| | | if (m_delegate->mapGeometryToScene(currentButton).contains(pos)) { |
| | | *button = static_cast<CoreWindowAgent::SystemButton>(i); |
| | | *button = static_cast<WindowAgentBase::SystemButton>(i); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | for (int i = CoreWindowAgent::WindowIcon; i <= CoreWindowAgent::Close; ++i) { |
| | | for (int i = WindowAgentBase::WindowIcon; i <= WindowAgentBase::Close; ++i) { |
| | | auto currentButton = m_systemButtons[i]; |
| | | if (currentButton && m_delegate->isVisible(currentButton) && |
| | | m_delegate->isEnabled(currentButton) && |
| | |
| | | return true; |
| | | } |
| | | |
| | | bool AbstractWindowContext::hostEventFilter(QEvent *event) { |
| | | Q_UNUSED(event) |
| | | return false; |
| | | QObject *AbstractWindowContext::target() const { |
| | | return m_host; |
| | | } |
| | | |
| | | } |