diff mbox series

[3/3] kernel-shark-qt: Make the Quick Contex menu less touchy

Message ID 20181217175516.2944-3-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit 03b66f61952111a0ec926c186b22938f681a54a7
Headers show
Series [1/3] kernel-shark-qt: Improve the KsQuickContextMenu | expand

Commit Message

Yordan Karadzhov Dec. 17, 2018, 5:56 p.m. UTC
The menu is shifted just a bit so that it is not positioned under
the mouse. This will prevent from an accidental selection of the menu
item under the mouse.

Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsTraceGraph.cpp  | 7 +++++++
 kernel-shark-qt/src/KsTraceViewer.cpp | 7 +++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsTraceGraph.cpp b/kernel-shark-qt/src/KsTraceGraph.cpp
index 5144f61..462918f 100644
--- a/kernel-shark-qt/src/KsTraceGraph.cpp
+++ b/kernel-shark-qt/src/KsTraceGraph.cpp
@@ -791,6 +791,13 @@  void KsTraceGraph::_onCustomContextMenu(const QPoint &point)
 		QPoint global = _glWindow.mapToGlobal(point);
 		global.ry() -= menu->sizeHint().height() / 2;
 
+		/*
+		 * Shift the menu so that it is not positioned under the mouse.
+		 * This will prevent from an accidental selection of the menu
+		 * item under the mouse.
+		 */
+		global.rx() += FONT_WIDTH;
+
 		menu->exec(global);
 	}
 }
diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 09f6a1e..d64c2af 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -272,6 +272,13 @@  void KsTraceViewer::_onCustomContextMenu(const QPoint &point)
 		QPoint global = _view.mapToGlobal(point);
 		global.ry() -= menu.sizeHint().height() / 2;
 
+		/*
+		 * Shift the menu so that it is not positioned under the mouse.
+		 * This will prevent from an accidental selection of the menu
+		 * item under the mouse.
+		 */
+		global.rx() += FONT_WIDTH;
+
 		connect(&menu,	&KsQuickContextMenu::addTaskPlot,
 			this,	&KsTraceViewer::addTaskPlot);