From: Soeren Apel Date: Sun, 22 Dec 2019 16:42:11 +0000 (+0100) Subject: Fix #852 by handling ViewWidget::leaveEvent() properly X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cad96374ba6eb79b1e1cd63018a6a215b6943da8;p=pulseview.git Fix #852 by handling ViewWidget::leaveEvent() properly --- diff --git a/pv/views/trace/viewwidget.cpp b/pv/views/trace/viewwidget.cpp index e4de122d..5d496325 100644 --- a/pv/views/trace/viewwidget.cpp +++ b/pv/views/trace/viewwidget.cpp @@ -339,11 +339,22 @@ void ViewWidget::mouseMoveEvent(QMouseEvent *event) drag_items(event->pos() - mouse_down_point_); } } + + // Force a repaint of the widget to update highlighted parts + update(); } void ViewWidget::leaveEvent(QEvent*) { - mouse_point_ = QPoint(-1, -1); + bool cursor_above_widget = rect().contains(mapFromGlobal(QCursor::pos())); + + // We receive leaveEvent also when the widget loses focus even when + // the mouse cursor hasn't moved at all - e.g. when the popup shows. + // However, we don't want to reset mouse_position_ when the mouse is + // still above this widget as doing so would break the context menu + if (!cursor_above_widget) + mouse_point_ = QPoint(INT_MIN, INT_MIN); + mouse_modifiers_ = Qt::NoModifier; item_hover(nullptr, QPoint()); update();