summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-12-08 16:23:45 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-12-09 00:17:20 +0530
commit782f8be6d4076b0152442e6200426010c1f6704f (patch)
tree808e81214aecbb740e64f4f9b26507236e075bf6 /vcl/source
parent42fae43d70d3d1b8fcc9fc6328b1060d6d72abfc (diff)
lokdialog: Move lok cursor invalidation callbacks to vcl::Cursor
Change-Id: I5cbb845259b6802fb2a0776f8d8f19f9680115ad
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/control/edit.cxx38
-rw-r--r--vcl/source/window/cursor.cxx39
-rw-r--r--vcl/source/window/window.cxx11
3 files changed, 39 insertions, 49 deletions
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index add78c2f49b3..7560860de9de 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1145,23 +1145,6 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible )
pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
pCursor->Show();
-
- if (comphelper::LibreOfficeKit::isActive())
- {
- const long X = GetOutOffXPixel() + pCursor->GetPos().X();
- const long Y = GetOutOffYPixel() + pCursor->GetPos().Y();
-
- if (nCursorWidth == 0)
- nCursorWidth = 2;
- const tools::Rectangle aRect(Point(X, Y), Size(nCursorWidth, pCursor->GetHeight()));
-
- std::vector<vcl::LOKPayloadItem> aPayload;
- aPayload.push_back(std::make_pair("rectangle", aRect.toString()));
-
- Dialog* pParentDlg = GetParentDialog();
- if (pParentDlg)
- pParentDlg->LOKCursor("cursor_invalidate", aPayload);
- }
}
}
@@ -1908,16 +1891,6 @@ void Edit::GetFocus()
SetInputContext( InputContext( GetFont(), !IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) );
}
- // notify dialog's cursor visible status
- if (comphelper::LibreOfficeKit::isActive())
- {
- std::vector<vcl::LOKPayloadItem> aPayload;
- aPayload.push_back(std::make_pair(OString("visible"), OString("true")));
- Dialog* pParentDlg = GetParentDialog();
- if (pParentDlg)
- pParentDlg->LOKCursor("cursor_visible", aPayload);
- }
-
Control::GetFocus();
}
@@ -1945,17 +1918,6 @@ void Edit::LoseFocus()
ImplInvalidateOrRepaint(); // paint the selection
}
-
- // notify dialog's cursor visible status
- if (comphelper::LibreOfficeKit::isActive())
- {
- std::vector<vcl::LOKPayloadItem> aPayload;
- aPayload.push_back(std::make_pair(OString("visible"), OString("false")));
- Dialog* pParentDlg = GetParentDialog();
- if (pParentDlg)
- pParentDlg->LOKCursor("cursor_visible", aPayload);
- }
-
Control::LoseFocus();
}
diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx
index a4c0187097e6..d3049640d07d 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -18,6 +18,8 @@
*/
#include <memory>
+
+#include <comphelper/lok.hxx>
#include <vcl/svapp.hxx>
#include <vcl/timer.hxx>
#include <vcl/settings.hxx>
@@ -187,6 +189,9 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool bRestore )
mpData->mbCurVisible = false;
mpData->maTimer.SetInvokeHandler( LINK( this, Cursor, ImplTimerHdl ) );
mpData->maTimer.SetDebugName( "vcl ImplCursorData maTimer" );
+
+ // tell about "initial" coordinates
+ LOKNotify( pWindow, "cursor_invalidate" );
}
mpData->mpWindow = pWindow;
@@ -201,11 +206,43 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool bRestore )
mpData->maTimer.Start();
else if ( !mpData->mbCurVisible )
ImplDraw();
+ LOKNotify( pWindow, "cursor_visible" );
}
}
}
}
+void vcl::Cursor::LOKNotify( vcl::Window* pWindow, const OUString& rAction )
+{
+ if (VclPtr<vcl::Window> pParent = pWindow->GetParentWithLOKNotifier())
+ {
+ assert(pWindow && "Cannot notify without a window");
+ assert(mpData && "Require ImplCursorData");
+ assert(comphelper::LibreOfficeKit::isActive());
+
+ if (comphelper::LibreOfficeKit::isDialogPainting())
+ return;
+
+ const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier();
+ std::vector<vcl::LOKPayloadItem> aItems;
+ if (rAction == "cursor_visible")
+ aItems.emplace_back("visible", mpData->mbCurVisible ? "true" : "false");
+ else if (rAction == "cursor_invalidate")
+ {
+ const long nX = pWindow->GetOutOffXPixel() + pWindow->LogicToPixel(GetPos()).X();
+ const long nY = pWindow->GetOutOffYPixel() + pWindow->LogicToPixel(GetPos()).Y();
+ Size aSize = pWindow->LogicToPixel(GetSize());
+ if (!aSize.Width())
+ aSize.Width() = pWindow->GetSettings().GetStyleSettings().GetCursorSize();
+
+ const Rectangle aRect(Point(nX, nY), aSize);
+ aItems.emplace_back("rectangle", aRect.toString());
+ }
+
+ pNotifier->notifyWindow(pParent->GetLOKWindowId(), rAction, aItems);
+ }
+}
+
bool vcl::Cursor::ImplDoHide( bool bSuspend )
{
bool bWasCurVisible = false;
@@ -217,6 +254,7 @@ bool vcl::Cursor::ImplDoHide( bool bSuspend )
if ( !bSuspend )
{
+ LOKNotify( mpData->mpWindow, "cursor_visible" );
mpData->maTimer.Stop();
mpData->mpWindow = nullptr;
}
@@ -254,6 +292,7 @@ void vcl::Cursor::ImplNew()
ImplDraw();
if ( !mpWindow )
{
+ LOKNotify( mpData->mpWindow, "cursor_invalidate" );
if ( mpData->maTimer.GetTimeout() != STYLE_CURSOR_NOBLINKTIME )
mpData->maTimer.Start();
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 4ca9e449e683..3c56d46e6efc 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3277,17 +3277,6 @@ void Window::LOKKeyUp(const KeyEvent& rKeyEvent)
ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
}
-void Window::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
-{
- assert(comphelper::LibreOfficeKit::isActive());
-
- if (comphelper::LibreOfficeKit::isDialogPainting())
- return;
-
- if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
- pNotifier->notifyWindow(GetLOKWindowId(), rAction, rPayload);
-}
-
void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
{
// no deactivation if the newly activated window is my child