| | |
| | | return false; |
| | | } |
| | | |
| | | auto it = m_hitTestVisibleItems.find(obj); |
| | | if (visible) { |
| | | if (it != m_hitTestVisibleItems.end()) { |
| | | return true; |
| | | } |
| | | connect(obj, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_hitTestVisibleItemDestroyed); |
| | | m_hitTestVisibleItems.insert(obj); |
| | | m_hitTestVisibleItems.removeAll(nullptr); |
| | | m_hitTestVisibleItems.removeAll(obj); |
| | | m_hitTestVisibleItems.append(obj); |
| | | } else { |
| | | if (it == m_hitTestVisibleItems.end()) { |
| | | return false; |
| | | for (auto &item : m_hitTestVisibleItems) { |
| | | if (item == obj) { |
| | | item = nullptr; |
| | | } |
| | | } |
| | | disconnect(obj, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_hitTestVisibleItemDestroyed); |
| | | m_hitTestVisibleItems.erase(it); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | |
| | | auto org = m_systemButtons[button]; |
| | | if (org == obj) { |
| | | return true; |
| | | } |
| | | |
| | | if (org) { |
| | | disconnect(org, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_systemButtonDestroyed); |
| | | } |
| | | if (obj) { |
| | | connect(obj, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_systemButtonDestroyed); |
| | | return false; |
| | | } |
| | | m_systemButtons[button] = obj; |
| | | return true; |
| | |
| | | if (org) { |
| | | // Since the title bar is changed, all items inside it should be dereferenced right away |
| | | removeSystemButtonsAndHitTestItems(); |
| | | disconnect(org, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_titleBarDistroyed); |
| | | } |
| | | if (item) { |
| | | connect(item, &QObject::destroyed, this, &AbstractWindowContext::_q_titleBarDistroyed); |
| | | } |
| | | m_titleBar = item; |
| | | return true; |
| | |
| | | *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)) { |
| | | if (!currentButton || !m_delegate->isVisible(currentButton)) { |
| | | continue; |
| | | } |
| | | if (m_delegate->mapGeometryToScene(currentButton).contains(pos)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | for (int i = WindowAgentBase::WindowIcon; i <= WindowAgentBase::Close; ++i) { |
| | | auto currentButton = m_systemButtons[i]; |
| | | if (currentButton && m_delegate->isVisible(currentButton) && |
| | | m_delegate->isEnabled(currentButton) && |
| | | m_delegate->mapGeometryToScene(currentButton).contains(pos)) { |
| | | WindowAgentBase::SystemButton button; |
| | | if (isInSystemButtons(pos, &button)) { |
| | | return true; |
| | | } |
| | | |
| | | for (auto item : m_hitTestVisibleItems) { |
| | | if (item && m_delegate->isVisible(item)&& |
| | | m_delegate->mapGeometryToScene(item).contains(pos)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | for (auto widget : m_hitTestVisibleItems) { |
| | | if (widget && m_delegate->isVisible(widget) && m_delegate->isEnabled(widget) && |
| | | m_delegate->mapGeometryToScene(widget).contains(pos)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | removeEventFilter(m_windowHandle); |
| | | } |
| | | m_windowHandle = m_delegate->hostWindow(m_host); |
| | | if (m_windowHandle) { |
| | | m_windowHandle->installEventFilter(this); |
| | | } |
| | | |
| | | if (oldWinId != m_windowId) { |
| | | winIdChanged(m_windowId, oldWinId); |
| | | } |
| | | |
| | | if (m_windowHandle) { |
| | | m_windowHandle->installEventFilter(this); |
| | | |
| | | // Refresh window attributes |
| | | for (auto it = m_windowAttributesOrder.begin(); it != m_windowAttributesOrder.end();) { |
| | | if (!windowAttributeChanged(it->first, it->second, {})) { |
| | | m_windowAttributes.remove(it->first); |
| | | it = m_windowAttributesOrder.erase(it); |
| | | continue; |
| | | if (m_windowId) { |
| | | // Refresh window attributes |
| | | for (auto it = m_windowAttributesOrder.begin(); |
| | | it != m_windowAttributesOrder.end();) { |
| | | if (!windowAttributeChanged(it->first, it->second, {})) { |
| | | m_windowAttributes.remove(it->first); |
| | | it = m_windowAttributesOrder.erase(it); |
| | | continue; |
| | | } |
| | | ++it; |
| | | } |
| | | ++it; |
| | | } |
| | | } |
| | | |
| | | // Send to shared dispatchers |
| | | if (oldWinId != m_windowId) { |
| | | // Send to shared dispatchers |
| | | QEvent e(QEvent::WinIdChange); |
| | | sharedDispatch(m_host, &e); |
| | | } |
| | |
| | | if (!attribute.isValid()) { |
| | | return true; |
| | | } |
| | | if (m_windowHandle && !windowAttributeChanged(key, attribute, {})) { |
| | | if (m_windowId && !windowAttributeChanged(key, attribute, {})) { |
| | | return false; |
| | | } |
| | | m_windowAttributes.insert(key, |
| | | m_windowAttributesOrder.insert(m_windowAttributesOrder.end(), |
| | | std::make_pair(key, attribute))); |
| | | m_windowAttributes.insert( |
| | | key, m_windowAttributesOrder.insert(m_windowAttributesOrder.end(), |
| | | std::make_pair(key, attribute))); |
| | | return true; |
| | | } |
| | | |
| | | auto &listIter = it.value(); |
| | | auto &oldAttr = listIter->second; |
| | | if (m_windowHandle && !windowAttributeChanged(key, attribute, oldAttr)) { |
| | | if (m_windowId && !windowAttributeChanged(key, attribute, oldAttr)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (!button) { |
| | | continue; |
| | | } |
| | | disconnect(button, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_systemButtonDestroyed); |
| | | button = nullptr; |
| | | } |
| | | for (auto &item : m_hitTestVisibleItems) { |
| | | disconnect(item, &QObject::destroyed, this, |
| | | &AbstractWindowContext::_q_hitTestVisibleItemDestroyed); |
| | | } |
| | | m_hitTestVisibleItems.clear(); |
| | | } |
| | | |
| | | void AbstractWindowContext::_q_titleBarDistroyed(QObject *obj) { |
| | | Q_UNUSED(obj) |
| | | removeSystemButtonsAndHitTestItems(); |
| | | m_titleBar = nullptr; |
| | | } |
| | | |
| | | void AbstractWindowContext::_q_hitTestVisibleItemDestroyed(QObject *obj) { |
| | | m_hitTestVisibleItems.remove(obj); |
| | | } |
| | | |
| | | void AbstractWindowContext::_q_systemButtonDestroyed(QObject *obj) { |
| | | for (auto &item : m_systemButtons) { |
| | | if (item == obj) { |
| | | item = nullptr; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |