From: Soeren Apel <redacted>
Date: Sat, 18 Jan 2020 22:01:15 +0000 (+0100)
Subject: TraceView: Fix still-highlighted trace after closing popup
X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3fef0289310e825df71afcfae7b3adc4319c7f7f;p=pulseview.git

TraceView: Fix still-highlighted trace after closing popup
---

diff --git a/pv/views/trace/marginwidget.cpp b/pv/views/trace/marginwidget.cpp
index c2d44365..537ffe5e 100644
--- a/pv/views/trace/marginwidget.cpp
+++ b/pv/views/trace/marginwidget.cpp
@@ -47,6 +47,9 @@ void MarginWidget::item_clicked(const shared_ptr<ViewItem> &item)
 void MarginWidget::show_popup(const shared_ptr<ViewItem> &item)
 {
 	pv::widgets::Popup *const p = item->create_popup(this);
+
+	connect(p, SIGNAL(closed()), this, SLOT(on_popup_closed()));
+
 	if (p)
 		p->show();
 }
@@ -80,6 +83,17 @@ void MarginWidget::keyPressEvent(QKeyEvent *event)
     ViewWidget::keyPressEvent(event);
 }
 
+void MarginWidget::on_popup_closed()
+{
+	bool cursor_above_widget = rect().contains(mapFromGlobal(QCursor::pos()));
+
+	if (!cursor_above_widget)
+		mouse_point_ = QPoint(INT_MIN, INT_MIN);
+
+	update();
+}
+
+
 } // namespace trace
 } // namespace views
 } // namespace pv
diff --git a/pv/views/trace/marginwidget.hpp b/pv/views/trace/marginwidget.hpp
index 9a0686aa..ef5e6350 100644
--- a/pv/views/trace/marginwidget.hpp
+++ b/pv/views/trace/marginwidget.hpp
@@ -61,10 +61,12 @@ protected:
 	 */
 	void show_popup(const shared_ptr<ViewItem> &item);
 
-protected:
+protected Q_SLOTS:
 	virtual void contextMenuEvent(QContextMenuEvent *event);
 
 	virtual void keyPressEvent(QKeyEvent *event);
+
+	virtual void on_popup_closed();
 };
 
 } // namespace trace
diff --git a/pv/views/trace/viewwidget.cpp b/pv/views/trace/viewwidget.cpp
index 5d496325..5a85c15d 100644
--- a/pv/views/trace/viewwidget.cpp
+++ b/pv/views/trace/viewwidget.cpp
@@ -357,6 +357,7 @@ void ViewWidget::leaveEvent(QEvent*)
 
 	mouse_modifiers_ = Qt::NoModifier;
 	item_hover(nullptr, QPoint());
+
 	update();
 }