summaryrefslogtreecommitdiff
path: root/starmath/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-02 21:43:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-03 14:39:20 +0100
commit4321fb516f4a65b047b182c4cb6f9c9a232efd85 (patch)
tree142d113b3eb8e3ed0a97838418e22ebca13233ae /starmath/source
parent47b088e2c7917762f96c44346931cc40d56b2efa (diff)
Resolves: tdf#145959 menu pos should be relative to SmCmdBoxWindow
Change-Id: Ie8da9bbb4385b3315fd62e6f2dc8ab394ea3709f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126263 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath/source')
-rw-r--r--starmath/source/edit.cxx5
-rw-r--r--starmath/source/view.cxx24
2 files changed, 21 insertions, 8 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 2588e9f60325..e8e79a24e12c 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -266,10 +266,9 @@ bool SmEditTextWindow::Command(const CommandEvent& rCEvt)
if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
{
- // purely for "ExecutePopup" taking a vcl::Window and
- // we assume SmEditTextWindow 0,0 is at SmEditWindow 0,0
ReleaseMouse();
- mrEditWindow.GetCmdBox().Command(rCEvt);
+ SmCmdBoxWindow& rCmdBox = mrEditWindow.GetCmdBox();
+ rCmdBox.ShowContextMenu(rCmdBox.WidgetToWindowPos(*GetDrawingArea(), rCEvt.GetMousePosPixel()));
GrabFocus();
return true;
}
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 6eb1213071cb..5bc143ab394b 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -831,15 +831,29 @@ SmCmdBoxWindow::SmCmdBoxWindow(SfxBindings *pBindings_, SfxChildWindow *pChildWi
aInitialFocusTimer.SetTimeout(100);
}
+Point SmCmdBoxWindow::WidgetToWindowPos(const weld::Widget& rWidget, const Point& rPos)
+{
+ Point aRet(rPos);
+ int x(0), y(0), width(0), height(0);
+ rWidget.get_extents_relative_to(*m_xContainer, x, y, width, height);
+ aRet.Move(x, y);
+ aRet.Move(m_xBox->GetPosPixel().X(), m_xBox->GetPosPixel().Y());
+ return aRet;
+}
+
+void SmCmdBoxWindow::ShowContextMenu(const Point& rPos)
+{
+ ToTop();
+ SmViewShell *pViewSh = GetView();
+ if (pViewSh)
+ pViewSh->GetViewFrame()->GetDispatcher()->ExecutePopup("edit", this, &rPos);
+}
+
void SmCmdBoxWindow::Command(const CommandEvent& rCEvt)
{
if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
{
- ToTop();
- Point aPoint = rCEvt.GetMousePosPixel();
- SmViewShell *pViewSh = GetView();
- if (pViewSh)
- pViewSh->GetViewFrame()->GetDispatcher()->ExecutePopup("edit", this, &aPoint);
+ ShowContextMenu(rCEvt.GetMousePosPixel());
return;
}