From 6399df1eebb3eee96640d91002ab84a85fe558e1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 20 Jul 2016 11:33:10 +0200 Subject: 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 Tested-by: Jenkins (cherry picked from commit 6ea8084487411feea049f57712979fba4ad2fbce) --- sd/qa/unit/tiledrendering/tiledrendering.cxx | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'sd/qa') diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index acff325c6498..e26c0334209e 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()); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(!aView1.m_bCursorVisibleChanged); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3