Fix #852 by handling ViewWidget::leaveEvent() properly
authorSoeren Apel <soeren@apelpie.net>
Sun, 22 Dec 2019 16:42:11 +0000 (17:42 +0100)
committerSoeren Apel <soeren@apelpie.net>
Sun, 22 Dec 2019 16:42:11 +0000 (17:42 +0100)
pv/views/trace/viewwidget.cpp

index e4de122d9e7ddd8bc6f0efc5763ac3b338fc63c2..5d496325d875c09e285b4636fd46c2a53bdfdcaf 100644 (file)
@@ -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();