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>
This commit is contained in:
Miklos Vajna
2016-07-20 11:33:10 +02:00
parent ecb34112cc
commit 6ea8084487
8 changed files with 55 additions and 17 deletions

View File

@@ -1432,7 +1432,7 @@ void EditEngine::SetUpdateMode( bool bUpdate )
{ {
pImpEditEngine->SetUpdateMode( bUpdate ); pImpEditEngine->SetUpdateMode( bUpdate );
if ( pImpEditEngine->pActiveView ) if ( pImpEditEngine->pActiveView )
pImpEditEngine->pActiveView->ShowCursor( false, false ); pImpEditEngine->pActiveView->ShowCursor( false, false, /*bActivate=*/true );
} }
bool EditEngine::GetUpdateMode() const bool EditEngine::GetUpdateMode() const

View File

@@ -392,7 +392,7 @@ void EditView::Command( const CommandEvent& rCEvt )
pImpEditView->Command( 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 ) ) if ( pImpEditView->pEditEngine->HasView( this ) )
{ {
@@ -401,18 +401,18 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
bGotoCursor = false; bGotoCursor = false;
pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor ); pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive() && !bActivate)
{ {
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr()); pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
} }
} }
} }
void EditView::HideCursor() void EditView::HideCursor(bool bDeactivate)
{ {
pImpEditView->GetCursor()->Hide(); pImpEditView->GetCursor()->Hide();
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive() && !bDeactivate)
{ {
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr()); pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
} }

View File

@@ -1229,14 +1229,14 @@ bool OutlinerView::HasSelection() const
return pEditView->HasSelection(); 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 ) void OutlinerView::SetWindow( vcl::Window* pWin )

View File

@@ -111,8 +111,8 @@ public:
void Invalidate(); void Invalidate();
Pair Scroll( long nHorzScroll, long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative ); Pair Scroll( long nHorzScroll, long nVertScroll, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative );
void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true ); void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true, bool bActivate = false );
void HideCursor(); void HideCursor( bool bDeactivate = false );
void SetSelectionMode( EESelectionMode eMode ); void SetSelectionMode( EESelectionMode eMode );

View File

@@ -229,8 +229,8 @@ public:
void ReleaseMouse(); void ReleaseMouse();
bool MouseMove( const MouseEvent& ); bool MouseMove( const MouseEvent& );
void ShowCursor( bool bGotoCursor = true ); void ShowCursor( bool bGotoCursor = true, bool bActivate = false );
void HideCursor(); void HideCursor( bool bDeactivate = false );
Outliner* GetOutliner() const { return pOwner; } Outliner* GetOutliner() const { return pOwner; }

View File

@@ -65,6 +65,7 @@ public:
void testResizeTableColumn(); void testResizeTableColumn();
void testViewCursors(); void testViewCursors();
void testViewCursorParts(); void testViewCursorParts();
void testCursorViews();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testRegisterCallback);
@@ -86,6 +87,7 @@ public:
CPPUNIT_TEST(testResizeTableColumn); CPPUNIT_TEST(testResizeTableColumn);
CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testViewCursors);
CPPUNIT_TEST(testViewCursorParts); CPPUNIT_TEST(testViewCursorParts);
CPPUNIT_TEST(testCursorViews);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
@@ -818,11 +820,13 @@ public:
bool m_bGraphicViewSelectionInvalidated; bool m_bGraphicViewSelectionInvalidated;
/// Our current part, to be able to decide if a view cursor/selection is relevant for us. /// Our current part, to be able to decide if a view cursor/selection is relevant for us.
int m_nPart; int m_nPart;
bool m_bCursorVisibleChanged;
ViewCallback() ViewCallback()
: m_bGraphicSelectionInvalidated(false), : m_bGraphicSelectionInvalidated(false),
m_bGraphicViewSelectionInvalidated(false), m_bGraphicViewSelectionInvalidated(false),
m_nPart(0) m_nPart(0),
m_bCursorVisibleChanged(false)
{ {
} }
@@ -850,6 +854,11 @@ public:
m_bGraphicViewSelectionInvalidated = true; m_bGraphicViewSelectionInvalidated = true;
} }
break; break;
case LOK_CALLBACK_CURSOR_VISIBLE:
{
m_bCursorVisibleChanged = true;
}
break;
} }
} }
}; };
@@ -925,6 +934,35 @@ void SdTiledRenderingTest::testViewCursorParts()
comphelper::LibreOfficeKit::setActive(false); 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_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();

View File

@@ -979,7 +979,7 @@ void FuText::Activate()
OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (pOLV) if (pOLV)
pOLV->ShowCursor(); pOLV->ShowCursor(/*bGotoCursor=*/true, /*bActivate=*/true);
FuConstruct::Activate(); FuConstruct::Activate();
@@ -992,7 +992,7 @@ void FuText::Deactivate()
OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (pOLV) if (pOLV)
pOLV->HideCursor(); pOLV->HideCursor(/*bDeactivate=*/true);
mpView->SetHitTolerancePixel( HITPIX ); mpView->SetHitTolerancePixel( HITPIX );

View File

@@ -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 void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView& rOutlView) const