diff --git a/tools/chatgui/src/streamgrid_window.cpp b/tools/chatgui/src/streamgrid_window.cpp index 1c503860..b8d3d071 100644 --- a/tools/chatgui/src/streamgrid_window.cpp +++ b/tools/chatgui/src/streamgrid_window.cpp @@ -131,17 +131,23 @@ void StreamGridWindow::restoreGrid() { /* Не перехватываем drag/колесо zoom. Активация после release даёт VideoRenderWidget завершить drag. */ bool StreamGridWindow::eventFilter(QObject* watched, QEvent* event) { + if (event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseMove && event->type() != QEvent::MouseButtonRelease) + return QWidget::eventFilter(watched, event); + auto* mouse = static_cast(event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const auto position = mouse->globalPosition().toPoint(); +#else + const auto position = mouse->globalPos(); +#endif if (event->type() == QEvent::MouseButtonPress) { - auto* mouse = static_cast(event); - if (mouse->button() == Qt::LeftButton) { m_pressed = watched; m_pressPosition = mouse->globalPos(); m_dragged = false; } + if (mouse->button() == Qt::LeftButton) { m_pressed = watched; m_pressPosition = position; m_dragged = false; } } else if (event->type() == QEvent::MouseMove && m_pressed == watched) { - auto* mouse = static_cast(event); - if ((mouse->globalPos() - m_pressPosition).manhattanLength() >= QApplication::startDragDistance()) m_dragged = true; + if ((position - m_pressPosition).manhattanLength() >= QApplication::startDragDistance()) m_dragged = true; } else if (event->type() == QEvent::MouseButtonRelease && m_pressed == watched) { - auto* mouse = static_cast(event); m_pressed = nullptr; + m_pressed = nullptr; if (mouse->button() == Qt::LeftButton && !m_dragged && - (mouse->globalPos() - m_pressPosition).manhattanLength() < QApplication::startDragDistance()) { - for (const auto& tile : m_tiles) if (tile.video == watched || tile.video->isAncestorOf(qobject_cast(watched))) { + (position - m_pressPosition).manhattanLength() < QApplication::startDragDistance()) { + for (const auto& tile : m_tiles) if (tile.video && (tile.video == watched || tile.video->isAncestorOf(qobject_cast(watched)))) { QMetaObject::invokeMethod(this, [this, source = tile.source] { activateTile(source); }, Qt::QueuedConnection); break; } }