summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 11:33:10 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 10:04:50 +0000
commit6ea8084487411feea049f57712979fba4ad2fbce (patch)
tree033876b7c2b17ecfe2685ce9f30351fbb035ead3
parentecb34112cc4c768fd2f57499151920fa7798776f (diff)
sd lok: decouple vcl window focus from cursor visibility
The problem was the the blinking cursor was hidden when another vcl window got its focus, so it wasn't possible to edit two shape text in parallel in two windows. The code path is like this: - show cursor, cursor is created: SdrObjEditView::SdrBeginTextEdit() -> OutlinerView::ShowCursor() - show cursor, focus case: sd::FuText::Activate() -> OutlinerView::ShowCursor() - hide cursor, cursor is deleted: SdrObjEditView::SdrEndTextEdit() -> OutlinerView::HideCursor() - hide cursor, focus case: sd::FuText::Deactivate() -> OutlinerView::HideCursor() So add a new optional bool parameter that allows not emitting the LOK_CALLBACK_CURSOR_VISIBLE callback in the focus change case. Also, if we're at it, make sure that painting emits no show/cursor LOK callbacks. Change-Id: I1068a1b1f5cd76fd09b5a79066834bfb0daebc77 Reviewed-on: https://gerrit.libreoffice.org/27335 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--editeng/source/editeng/editeng.cxx2
-rw-r--r--editeng/source/editeng/editview.cxx8
-rw-r--r--editeng/source/outliner/outlvw.cxx8
-rw-r--r--include/editeng/editview.hxx4
-rw-r--r--include/editeng/outliner.hxx4
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx40
-rw-r--r--sd/source/ui/func/futext.cxx4
-rw-r--r--svx/source/svdraw/svdedxv.cxx2
8 files changed, 55 insertions, 17 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index a20f52eadcd3..970f6b3289d3 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1432,7 +1432,7 @@ void EditEngine::SetUpdateMode( bool bUpdate )
{
pImpEditEngine->SetUpdateMode( bUpdate );
if ( pImpEditEngine->pActiveView )
- pImpEditEngine->pActiveView->ShowCursor( false, false );
+ pImpEditEngine->pActiveView->ShowCursor( false, false, /*bActivate=*/true );
}
bool EditEngine::GetUpdateMode() const
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 8dca0867cdc9..38dac90d197a 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -392,7 +392,7 @@ void EditView::Command( const CommandEvent& rCEvt )
pImpEditView->Command( rCEvt );
}
-void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
+void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivate )
{
if ( pImpEditView->pEditEngine->HasView( this ) )
{
@@ -401,18 +401,18 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
bGotoCursor = false;
pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive() && !bActivate)
{
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
}
}
}
-void EditView::HideCursor()
+void EditView::HideCursor(bool bDeactivate)
{
pImpEditView->GetCursor()->Hide();
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive() && !bDeactivate)
{
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
}
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index ea011f2924c2..fb18848de740 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1229,14 +1229,14 @@ bool OutlinerView::HasSelection() const
return pEditView->HasSelection();
}
-void OutlinerView::ShowCursor( bool bGotoCursor )
+void OutlinerView::ShowCursor( bool bGotoCursor, bool bActivate )
{
- pEditView->ShowCursor( bGotoCursor );
+ pEditView->ShowCursor( bGotoCursor, /*bForceVisCursor=*/true, bActivate );
}
-void OutlinerView::HideCursor()
+void OutlinerView::HideCursor(bool bDeactivate)
{
- pEditView->HideCursor();
+ pEditView->HideCursor(bDeactivate);
}
void OutlinerView::SetWindow( vcl::Window* pWin )
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index f609aa679a25..b8d16cefd22d 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -111,8 +111,8 @@ public:
void Invalidate();
Pair Scroll( long nHorzScroll, long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
- void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true );
- void HideCursor();
+ void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true, bool bActivate = false );
+ void HideCursor( bool bDeactivate = false );
void SetSelectionMode( EESelectionMode eMode );
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index be989e5b1e70..f019696d43e0 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -229,8 +229,8 @@ public:
void ReleaseMouse();
bool MouseMove( const MouseEvent& );
- void ShowCursor( bool bGotoCursor = true );
- void HideCursor();
+ void ShowCursor( bool bGotoCursor = true, bool bActivate = false );
+ void HideCursor( bool bDeactivate = false );
Outliner* GetOutliner() const { return pOwner; }
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 948f06d9a9a0..40fc29639a05 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -65,6 +65,7 @@ public:
void testResizeTableColumn();
void testViewCursors();
void testViewCursorParts();
+ void testCursorViews();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -86,6 +87,7 @@ public:
CPPUNIT_TEST(testResizeTableColumn);
CPPUNIT_TEST(testViewCursors);
CPPUNIT_TEST(testViewCursorParts);
+ CPPUNIT_TEST(testCursorViews);
CPPUNIT_TEST_SUITE_END();
private:
@@ -818,11 +820,13 @@ public:
bool m_bGraphicViewSelectionInvalidated;
/// Our current part, to be able to decide if a view cursor/selection is relevant for us.
int m_nPart;
+ bool m_bCursorVisibleChanged;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
m_bGraphicViewSelectionInvalidated(false),
- m_nPart(0)
+ m_nPart(0),
+ m_bCursorVisibleChanged(false)
{
}
@@ -850,6 +854,11 @@ public:
m_bGraphicViewSelectionInvalidated = true;
}
break;
+ case LOK_CALLBACK_CURSOR_VISIBLE:
+ {
+ m_bCursorVisibleChanged = true;
+ }
+ break;
}
}
};
@@ -925,6 +934,35 @@ void SdTiledRenderingTest::testViewCursorParts()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testCursorViews()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create the first view.
+ SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+ // Begin text edit on the only object on the slide.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ pView->SdrBeginTextEdit(pObject);
+
+ // Make sure that cursor state is not changed just because we create a second view.
+ aView1.m_bCursorVisibleChanged = false;
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(!aView1.m_bCursorVisibleChanged);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index a80fd6cd2c51..a27c0c49a7e9 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -979,7 +979,7 @@ void FuText::Activate()
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (pOLV)
- pOLV->ShowCursor();
+ pOLV->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
FuConstruct::Activate();
@@ -992,7 +992,7 @@ void FuText::Deactivate()
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (pOLV)
- pOLV->HideCursor();
+ pOLV->HideCursor(/*bDeactivate=*/true);
mpView->SetHitTolerancePixel( HITPIX );
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index a0fcb8129625..bcd01d3a2921 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -384,7 +384,7 @@ void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectang
}
}
- rOutlView.ShowCursor();
+ rOutlView.ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
}
void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView& rOutlView) const