summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-15 11:06:33 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-15 15:07:34 +0100
commit5c89695f3885ec2e7cd00eaf56a46a7f00c44883 (patch)
treedd9e584c20959d567e74a2caa8077cbe722fef47
parent760100d1dfe0df3e67227618013297e5f1f419aa (diff)
tdf#140414 add getting mouse pos to EditViewCallbacks
Change-Id: I09172e0cb24f5c45d2837cf2f2fc7cc4baa456a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110932 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--editeng/source/editeng/editview.cxx12
-rw-r--r--include/editeng/editview.hxx3
-rw-r--r--include/svx/svdedxv.hxx1
-rw-r--r--include/svx/weldeditview.hxx2
-rw-r--r--include/vcl/customweld.hxx1
-rw-r--r--include/vcl/weld.hxx2
-rw-r--r--svx/source/dialog/weldeditview.cxx5
-rw-r--r--svx/source/svdraw/svdedxv.cxx2
-rw-r--r--vcl/inc/salvtables.hxx2
-rw-r--r--vcl/source/app/salvtables.cxx5
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx11
11 files changed, 41 insertions, 5 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 1a3f17e61d34..4849b81b6898 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1322,11 +1322,13 @@ const SvxFieldItem* EditView::GetField( const Point& rPos, sal_Int32* pPara, sal
const SvxFieldItem* EditView::GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const
{
- auto pWin = pImpEditView->GetWindow();
- if (!pWin)
- return nullptr;
- Point aPos = pWin->GetPointerPosPixel();
- aPos = pImpEditView->GetWindow()->PixelToLogic( aPos );
+ Point aPos;
+ if (EditViewCallbacks* pEditViewCallbacks = pImpEditView->getEditViewCallbacks())
+ aPos = pEditViewCallbacks->EditViewPointerPosPixel();
+ else
+ aPos = pImpEditView->GetWindow()->GetPointerPosPixel();
+ OutputDevice& rDevice = pImpEditView->GetOutputDevice();
+ aPos = rDevice.PixelToLogic(aPos);
return GetField( aPos, &nPara, &nPos );
}
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 9fdb08ebc1d9..05e59a4753fd 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -114,6 +114,9 @@ public:
return nullptr;
}
+ // return the Mouse Position
+ virtual Point EditViewPointerPosPixel() const = 0;
+
// Triggered to update InputEngine context information
virtual void EditViewInputContext(const InputContext& rInputContext) = 0;
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 36763ea01656..2d50d1f3e6fa 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -68,6 +68,7 @@ class SVXCORE_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditView
virtual void EditViewInvalidate(const tools::Rectangle& rRect) override;
virtual void EditViewSelectionChange() override;
virtual OutputDevice& EditViewOutputDevice() const override;
+ virtual Point EditViewPointerPosPixel() const override;
virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() override;
virtual void EditViewInputContext(const InputContext& rInputContext) override;
virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) override;
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index 930573f97856..d3697ad3ffb0 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -78,6 +78,8 @@ protected:
return GetDrawingArea()->get_ref_device();
}
+ virtual Point EditViewPointerPosPixel() const override;
+
virtual void EditViewInputContext(const InputContext& rInputContext) override
{
SetInputContext(rInputContext);
diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx
index b19b64bf980e..0bbfd46f4f94 100644
--- a/include/vcl/customweld.hxx
+++ b/include/vcl/customweld.hxx
@@ -90,6 +90,7 @@ public:
}
void CaptureMouse() { m_pDrawingArea->grab_add(); }
bool IsMouseCaptured() const { return m_pDrawingArea->has_grab(); }
+ Point GetPointerPosPixel() const { return m_pDrawingArea->get_pointer_position(); }
void EnableRTL(bool bEnable) { m_pDrawingArea->set_direction(bEnable); }
bool IsRTLEnabled() const { return m_pDrawingArea->get_direction(); }
void ReleaseMouse() { m_pDrawingArea->grab_remove(); }
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 29f20ffef966..6f734be32b6d 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -2180,6 +2180,8 @@ public:
virtual void set_cursor(PointerStyle ePointerStyle) = 0;
+ virtual Point get_pointer_position() const = 0;
+
virtual void set_input_context(const InputContext& rInputContext) = 0;
virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
int nExtTextInputWidth)
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index 59a4898e2be5..431e8e7c0486 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -235,6 +235,11 @@ bool WeldEditView::Command(const CommandEvent& rCEvt)
return pEditView->Command(rCEvt);
}
+Point WeldEditView::EditViewPointerPosPixel() const
+{
+ return GetDrawingArea()->get_pointer_position();
+}
+
class WeldEditAccessible;
namespace
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index a066f62d4471..15dac1b614ee 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -655,6 +655,8 @@ void SdrObjEditView::EditViewSelectionChange()
OutputDevice& SdrObjEditView::EditViewOutputDevice() const { return *pTextEditWin; }
+Point SdrObjEditView::EditViewPointerPosPixel() const { return pTextEditWin->GetPointerPosPixel(); }
+
css::uno::Reference<css::datatransfer::dnd::XDropTarget> SdrObjEditView::GetDropTarget()
{
if (!pTextEditWin)
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 3e09d2b12f0d..11aab8917f7e 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1148,6 +1148,8 @@ public:
virtual void set_cursor(PointerStyle ePointerStyle) override;
+ virtual Point get_pointer_position() const override;
+
virtual void set_input_context(const InputContext& rInputContext) override;
virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 867781476a18..21c3e206fa88 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5968,6 +5968,11 @@ Point SalInstanceDrawingArea::get_accessible_location()
return m_xDrawingArea->OutputToAbsoluteScreenPixel(Point());
}
+Point SalInstanceDrawingArea::get_pointer_position() const
+{
+ return m_xDrawingArea->GetPointerPosPixel();
+}
+
void SalInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
sal_uInt8 eDNDConstants)
{
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 2091c41d4135..8f0754d4325e 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -13893,6 +13893,17 @@ public:
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(m_pDrawingArea)), pCursor);
}
+ virtual Point get_pointer_position() const override
+ {
+ GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
+ GdkSeat* pSeat = gdk_display_get_default_seat(pDisplay);
+ GdkDevice* pPointer = gdk_seat_get_pointer(pSeat);
+ gint x(-1), y(-1);
+ GdkWindow* pWin = gtk_widget_get_window(m_pWidget);
+ gdk_window_get_device_position(pWin, pPointer, &x, &y, nullptr);
+ return Point(x, y);
+ }
+
virtual void set_input_context(const InputContext& rInputContext) override;
virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect, int nExtTextInputWidth) override;