From 4b8ef8bd6acfa9c062146bff2168fb0450e9542e Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Sun, 26 Aug 2018 23:54:13 +0300 Subject: tdf#119390 Don't focus the toolbar when closing a floating window Toolbar popup windows have the toolbar as their direct parent. This causes problems when such window is teared-off and later closed, as Window::dispose will attempt to move the focus to its parent which is the toolbar, instead of what users expect to have the focus back in the document area, or in whatever was the last focused control. As a solution reparent the window before dispose, similar to what happens with floating toolbars. Also return the focus to the main window when popup mode ends, so we can keep track of the last focused control. This is also a good thing by itself, as WB_OWNERDRAWDECORATION windows don't get the focus by default, which results in neither the floating window nor the document have focus after tear-off. Change-Id: I060b8c45a64db9c612da58b7c35478bab41a4558 Reviewed-on: https://gerrit.libreoffice.org/59811 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- framework/source/uielement/toolbarmanager.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'framework/source') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index b6fe68308b9b..5ca1bb8daa69 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -234,8 +234,9 @@ void ToolBarManager::Destroy() // Hide toolbar as lazy delete can destroy the toolbar much later. m_pToolBar->Hide(); - /* #i99167# removed change for i93173 since there is some weird crash */ - // #i93173# delete toolbar lazily as we can still be in one of its handlers + // #i93173# delete toolbar lazily as we can still be in one of its handlers + // tdf#119390 this will reparent the toolbar, so focus is restored from a + // floating toolbar to the last focused control of the application window. m_pToolBar->doLazyDelete(); m_pToolBar->SetSelectHdl( Link() ); -- cgit