diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-05-23 23:21:21 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-05-24 15:39:30 +0200 |
commit | 4b42fd7e9516fbbd8a92d97680524f32dd260fb2 (patch) | |
tree | c2e4035874ca686e9ad4ec044fd744b539759af0 /framework | |
parent | Updated core (diff) | |
download | core-4b42fd7e9516fbbd8a92d97680524f32dd260fb2.tar.gz core-4b42fd7e9516fbbd8a92d97680524f32dd260fb2.zip |
tdf#115284: Unify LibreOffice and system full-screen concepts on macOS
Also tdf#76476, and probably more.
Make it so that when a window is in full-screen mode from
LibreOffice's point of view, it is also full-screen from the system's
point of view, and vice versa.
All three ways to enter and leave full-screen mode can now be used
with the same end result: The Ctrl-Cmd-F shortcut, the "View > Full
Screen" menu entry, and the green bubble on the title bar.
Don't disable/deactivate/etc menus while in full-screen mode. The menu
auto-hides so there is no harm in having it function normally.
Don't display the floating toolbar with a single "Full Screen" button
in it as the way to leave full-screen mode. Instead, the same three
ways that can be used to enter full-screen mode work to leave it, too.
Sadly I could not figure out a way to set a window properly to
full-screen at the point where a document window is created and set to
be the same size as that kind of document window was the previous time
it was open in LibreOffice. Thus don't save state for full-screen
windows as we can't properly restore them. At least not for macOS. It
is not good to just restore them as non-full-screened but still at the
size they had when full-screen.
One irritating glitch remains, and I was unable to fix that properly:
I now prevent closing the document window that is in full-screen mode.
Otherwise, if it is closed, the full-screen mode remains even if no
window is open there; the desktop is completely black. Moving the
cursor to the top edge, the LibreOffice menu is there, though. I tried
to fix that but with no fully satisfying result. (Some attempts even
lead to crashes, so just disabling closing is better than crashing at
least.)
Change-Id: Id909077ef9de9f19d48c8b9ad10d748a65b2417f
Reviewed-on: https://gerrit.libreoffice.org/54760
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/helper/persistentwindowstate.hxx | 2 | ||||
-rw-r--r-- | framework/source/dispatch/closedispatcher.cxx | 17 | ||||
-rw-r--r-- | framework/source/helper/persistentwindowstate.cxx | 29 |
3 files changed, 46 insertions, 2 deletions
diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx index e6b5c47d8c72..f9062d4344c4 100644 --- a/framework/inc/helper/persistentwindowstate.hxx +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -119,6 +119,8 @@ class PersistentWindowState : public ::cppu::WeakImplHelper< static OUString implst_getWindowStateFromConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext , const OUString& sModuleName); + static bool implst_isWindowFullScreen(const css::uno::Reference< css::awt::XWindow >& xWindow); + /** @short retrieve the window state from the container window. @param xWindow diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx index ed79058194ab..1fc959734168 100644 --- a/framework/source/dispatch/closedispatcher.cxx +++ b/framework/source/dispatch/closedispatcher.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -38,6 +38,7 @@ #include <vcl/window.hxx> #include <vcl/svapp.hxx> #include <vcl/syswin.hxx> +#include <vcl/wrkwin.hxx> #include <unotools/moduleoptions.hxx> using namespace com::sun::star; @@ -176,6 +177,20 @@ void SAL_CALL CloseDispatcher::dispatchWithNotification(const css::util::URL& return; } +#ifdef MACOSX + // FIXME: In full-screen mode, if we call ShowFullScreenMode(false) here, it leads to a crash + // later, so disallow closing for now. And yes, if we don't allow closing a window that is in + // full-screen mode, the menu entry should be greyed out then, too. But doing that looks + // insanely hard, too. I am so tempted to just abort this and instead just don't even try to + // support the system full-screen mode. + if (m_pSysWindow) + { + WorkWindow *pWorkWindow = dynamic_cast<WorkWindow*>(m_pSysWindow.get()); + if (pWorkWindow && pWorkWindow->IsFullScreenMode()) + return; + } +#endif + if (m_pSysWindow && m_pSysWindow->GetCloseHdl().IsSet()) { // The closing frame has its own close handler. Call it instead. diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index ecec7f39d63c..e20a152a19d2 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -125,6 +125,11 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv case css::frame::FrameAction_COMPONENT_DETACHING : { + // FIXME: Hack: Don't save state for full-screen windows. We can't properly restore + // them anyway. + if (implst_isWindowFullScreen(xWindow)) + break; + OUString sWindowState = PersistentWindowState::implst_getWindowStateFromWindow(xWindow); PersistentWindowState::implst_setWindowStateOnConfig(xContext, sModuleName, sWindowState); } @@ -199,6 +204,28 @@ void PersistentWindowState::implst_setWindowStateOnConfig( {} } +bool PersistentWindowState::implst_isWindowFullScreen(const css::uno::Reference< css::awt::XWindow >& xWindow) +{ + bool bRetval = false; + + if (xWindow.is()) + { + SolarMutexGuard aSolarGuard; + + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); + if ( pWindow && pWindow->IsSystemWindow() ) + { + WindowStateData aWSD; + aWSD.SetMask(WindowStateMask::All); + static_cast<SystemWindow*>(pWindow.get())->GetWindowStateData(aWSD); + if (aWSD.GetState() & WindowStateState::FullScreen) + bRetval = true; + } + } + + return bRetval; +} + OUString PersistentWindowState::implst_getWindowStateFromWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) { OUString sWindowState; |