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>
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 1a3f17e..4849b81b 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 9fdb08e..05e59a4 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 36763ea..2d50d1f 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 930573f..d3697ad 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 b19b64b..0bbfd46 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 29f20ff..6f734be 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 59a4898..431e8e7 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 a066f62..15dac1b 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 3e09d2b..11aab89 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 8677814..21c3e20 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 2091c41..8f0754d 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;