diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/windowing/linux | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/windowing/linux')
-rw-r--r-- | xbmc/windowing/linux/CMakeLists.txt | 16 | ||||
-rw-r--r-- | xbmc/windowing/linux/OSScreenSaverFreedesktop.cpp | 78 | ||||
-rw-r--r-- | xbmc/windowing/linux/OSScreenSaverFreedesktop.h | 40 | ||||
-rw-r--r-- | xbmc/windowing/linux/WinSystemEGL.cpp | 36 | ||||
-rw-r--r-- | xbmc/windowing/linux/WinSystemEGL.h | 37 |
5 files changed, 207 insertions, 0 deletions
diff --git a/xbmc/windowing/linux/CMakeLists.txt b/xbmc/windowing/linux/CMakeLists.txt new file mode 100644 index 0000000..2a36d63 --- /dev/null +++ b/xbmc/windowing/linux/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SOURCES "") +set(HEADERS "") + +if(DBUS_FOUND) + list(APPEND SOURCES OSScreenSaverFreedesktop.cpp) + list(APPEND HEADERS OSScreenSaverFreedesktop.h) +endif() + +if(EGL_FOUND) + list(APPEND SOURCES WinSystemEGL.cpp) + list(APPEND HEADERS WinSystemEGL.h) +endif() + +if(SOURCES) + core_add_library(windowing_linux) +endif() diff --git a/xbmc/windowing/linux/OSScreenSaverFreedesktop.cpp b/xbmc/windowing/linux/OSScreenSaverFreedesktop.cpp new file mode 100644 index 0000000..167930d --- /dev/null +++ b/xbmc/windowing/linux/OSScreenSaverFreedesktop.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "OSScreenSaverFreedesktop.h" + +#include "CompileInfo.h" +#include "guilib/LocalizeStrings.h" +#include "utils/log.h" + +#include "platform/linux/DBusMessage.h" +#include "platform/linux/DBusUtil.h" + +using namespace KODI::WINDOWING::LINUX; + +namespace +{ +const std::string SCREENSAVER_OBJECT = "/org/freedesktop/ScreenSaver"; +const std::string SCREENSAVER_INTERFACE = "org.freedesktop.ScreenSaver"; +} + +bool COSScreenSaverFreedesktop::IsAvailable() +{ + // Test by making a call to a function without side-effects + CDBusMessage dummyMessage(SCREENSAVER_INTERFACE, SCREENSAVER_OBJECT, SCREENSAVER_INTERFACE, "GetActive"); + CDBusError error; + dummyMessage.SendSession(error); + // We do not care whether GetActive() is actually supported, we're just checking for the name to be there + // (GNOME for example does not support GetActive) + return !error || error.Name() == DBUS_ERROR_NOT_SUPPORTED; +} + +void COSScreenSaverFreedesktop::Inhibit() +{ + if (m_inhibited) + { + return; + } + + CDBusMessage inhibitMessage(SCREENSAVER_INTERFACE, SCREENSAVER_OBJECT, SCREENSAVER_INTERFACE, "Inhibit"); + inhibitMessage.AppendArguments(std::string(CCompileInfo::GetAppName()), + g_localizeStrings.Get(14086)); + if (!inhibitMessage.SendSession()) + { + // DBus call failed + CLog::Log(LOGERROR, "Inhibiting freedesktop screen saver failed"); + return; + } + + if (!inhibitMessage.GetReplyArguments(&m_cookie)) + { + CLog::Log(LOGERROR, "Could not retrieve cookie from org.freedesktop.ScreenSaver Inhibit response"); + return; + } + + m_inhibited = true; +} + +void COSScreenSaverFreedesktop::Uninhibit() +{ + if (!m_inhibited) + { + return; + } + + CDBusMessage uninhibitMessage(SCREENSAVER_INTERFACE, SCREENSAVER_OBJECT, SCREENSAVER_INTERFACE, "UnInhibit"); + uninhibitMessage.AppendArgument(m_cookie); + if (!uninhibitMessage.SendSession()) + { + CLog::Log(LOGERROR, "Uninhibiting freedesktop screen saver failed"); + } + + m_inhibited = false; +} diff --git a/xbmc/windowing/linux/OSScreenSaverFreedesktop.h b/xbmc/windowing/linux/OSScreenSaverFreedesktop.h new file mode 100644 index 0000000..041e8ab --- /dev/null +++ b/xbmc/windowing/linux/OSScreenSaverFreedesktop.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../OSScreenSaver.h" + +#include <cstdint> + +namespace KODI +{ +namespace WINDOWING +{ +namespace LINUX +{ + +// FIXME This is not really linux-specific, BSD could also have this. Better directory name? + +class COSScreenSaverFreedesktop : public IOSScreenSaver +{ +public: + COSScreenSaverFreedesktop() = default; + + static bool IsAvailable(); + void Inhibit() override; + void Uninhibit() override; + +private: + bool m_inhibited{false}; + std::uint32_t m_cookie; +}; + +} +} +} diff --git a/xbmc/windowing/linux/WinSystemEGL.cpp b/xbmc/windowing/linux/WinSystemEGL.cpp new file mode 100644 index 0000000..f791b91 --- /dev/null +++ b/xbmc/windowing/linux/WinSystemEGL.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "WinSystemEGL.h" + +using namespace KODI::WINDOWING::LINUX; + +CWinSystemEGL::CWinSystemEGL(EGLenum platform, std::string const& platformExtension) + : m_eglContext{platform, platformExtension} +{ +} + +EGLDisplay CWinSystemEGL::GetEGLDisplay() const +{ + return m_eglContext.GetEGLDisplay(); +} + +EGLSurface CWinSystemEGL::GetEGLSurface() const +{ + return m_eglContext.GetEGLSurface(); +} + +EGLContext CWinSystemEGL::GetEGLContext() const +{ + return m_eglContext.GetEGLContext(); +} + +EGLConfig CWinSystemEGL::GetEGLConfig() const +{ + return m_eglContext.GetEGLConfig(); +} diff --git a/xbmc/windowing/linux/WinSystemEGL.h b/xbmc/windowing/linux/WinSystemEGL.h new file mode 100644 index 0000000..44bb5e4 --- /dev/null +++ b/xbmc/windowing/linux/WinSystemEGL.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "utils/EGLUtils.h" + +namespace KODI +{ +namespace WINDOWING +{ +namespace LINUX +{ + +class CWinSystemEGL +{ +public: + CWinSystemEGL(EGLenum platform, std::string const& platformExtension); + ~CWinSystemEGL() = default; + + EGLDisplay GetEGLDisplay() const; + EGLSurface GetEGLSurface() const; + EGLContext GetEGLContext() const; + EGLConfig GetEGLConfig() const; + +protected: + CEGLContextUtils m_eglContext; +}; + +} // namespace LINUX +} // namespace WINDOWING +} // namespace KODI |