vcl/qt: add Mac display sleep inhibit support

Change-Id: I8a5085529fe85ab43a6db462fbc2b4953d22d58f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207984
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Dan Williams
2026-07-15 17:04:54 +02:00
parent 805c489c1c
commit f927da9fd8
7 changed files with 78 additions and 13 deletions
+1
View File
@@ -136,6 +136,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_osx,\
vcl/osx/salsys \
vcl/osx/saltimer \
vcl/osx/service_entry \
vcl/osx/sessioninhibitor \
vcl/quartz/CoreTextFont \
vcl/quartz/CoreTextFontFace \
vcl/quartz/SystemFontList \
+2 -5
View File
@@ -19,10 +19,6 @@
#pragma once
#include <premac.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <postmac.h>
#include <tools/long.hxx>
#include <vcl/sysdata.hxx>
@@ -30,6 +26,7 @@
#include <osx/salmenu.h>
#include <osx/saldata.hxx>
#include <osx/osxvcltypes.h>
#include <osx/sessioninhibitor.hxx>
#include <salframe.hxx>
@@ -85,7 +82,7 @@ public:
InputContextFlags mnICOptions;
// To prevent display sleep during presentation
IOPMAssertionID mnAssertionID;
SessionManagerInhibitor mSessionManagerInhibitor;
NSRect maFrameRect;
NSRect maContentRect;
+35
View File
@@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vclpluginapi.h>
#include <string_view>
#include <assert.h>
#include <premac.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <postmac.h>
enum ApplicationInhibitFlags
{
APPLICATION_INHIBIT_IDLE = (1 << 3) // Inhibit the session being marked as idle
};
class VCLPLUG_OSX_PUBLIC SessionManagerInhibitor
{
public:
void inhibit(bool bInhibit, std::u16string_view sReason = u"",
ApplicationInhibitFlags eType = APPLICATION_INHIBIT_IDLE);
private:
IOPMAssertionID mnAssertionID;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+4 -2
View File
@@ -26,7 +26,9 @@
#include "QtWidget.hxx"
#include <salframe.hxx>
#if defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD
#if defined MACOSX
#include <osx/sessioninhibitor.hxx>
#elif defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD
#include <unx/sessioninhibitor.hxx>
#endif
#include <vclpluginapi.h>
@@ -100,7 +102,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame
sal_uInt32 m_nRestoreScreen;
QRect m_aRestoreGeometry;
#if defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD
#if defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD || defined MACOSX
SessionManagerInhibitor m_SessionManagerInhibitor;
#endif
#if CHECK_ANY_QT_USING_X11
+2 -5
View File
@@ -1052,10 +1052,7 @@ void AquaSalFrame::StartPresentation( bool bStart )
if( bStart )
{
GetSalData()->maPresentationFrames.push_back( this );
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
kIOPMAssertionLevelOn,
CFSTR("LibreOffice presentation running"),
&mnAssertionID);
mSessionManagerInhibitor.inhibit(true);
[mpNSWindow setLevel: NSPopUpMenuWindowLevel];
if( mbShown )
[mpNSWindow makeMainWindow];
@@ -1063,7 +1060,7 @@ void AquaSalFrame::StartPresentation( bool bStart )
else
{
GetSalData()->maPresentationFrames.remove( this );
IOPMAssertionRelease(mnAssertionID);
mSessionManagerInhibitor.inhibit(false);
[mpNSWindow setLevel: NSNormalWindowLevel];
}
}
+33
View File
@@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <osx/sessioninhibitor.hxx>
#include <sal/log.hxx>
void SessionManagerInhibitor::inhibit(bool bInhibit, std::u16string_view sReason,
ApplicationInhibitFlags eType)
{
(void)sReason;
assert(eType == APPLICATION_INHIBIT_IDLE);
if (bInhibit)
{
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn,
CFSTR("LibreOffice presentation running"), &mnAssertionID);
}
else
{
IOPMAssertionRelease(mnAssertionID);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+1 -1
View File
@@ -668,7 +668,7 @@ void QtFrame::ShowFullScreen(bool bFullScreen, sal_Int32 nScreen)
void QtFrame::StartPresentation(bool bStart)
{
#if defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD
#if defined LINUX || defined __sun || defined FREEBSD || defined OPENBSD || defined MACOSX
#if CHECK_QT5_USING_X11
unsigned int nRootWindow(0);
std::optional<Display*> aDisplay;