diff options
author | Stephan Sundermann <stephansundermann@gmail.com> | 2023-10-15 12:59:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-15 12:59:14 +0200 |
commit | cf223f413fd62ea24db42af9719709a59f33c09a (patch) | |
tree | 115a7e2ca802a2baf887e559d06ceeb85ca40e7f | |
parent | 49cf52f515546256a867173f5edfaf474986d95b (diff) | |
parent | cf1b5898ec9e30a3a29b97c8f35a3ba9643299a4 (diff) | |
download | xbmc-cf223f413fd62ea24db42af9719709a59f33c09a.tar.xz |
Merge pull request #23854 from webosbrew/webos-pause-minimized
[webOS] Pause video on minimize
-rw-r--r-- | xbmc/windowing/wayland/ShellSurfaceWebOSShell.cpp | 1 | ||||
-rw-r--r-- | xbmc/windowing/wayland/WinSystemWayland.h | 8 | ||||
-rw-r--r-- | xbmc/windowing/wayland/WinSystemWaylandWebOS.cpp | 36 | ||||
-rw-r--r-- | xbmc/windowing/wayland/WinSystemWaylandWebOS.h | 3 |
4 files changed, 44 insertions, 4 deletions
diff --git a/xbmc/windowing/wayland/ShellSurfaceWebOSShell.cpp b/xbmc/windowing/wayland/ShellSurfaceWebOSShell.cpp index a4b9ab869d..2bc6606587 100644 --- a/xbmc/windowing/wayland/ShellSurfaceWebOSShell.cpp +++ b/xbmc/windowing/wayland/ShellSurfaceWebOSShell.cpp @@ -61,6 +61,7 @@ CShellSurfaceWebOSShell::CShellSurfaceWebOSShell(IShellSurfaceHandler& handler, case webos_shell_surface_state::minimized: CLog::Log(LOGDEBUG, "CShellSurfaceWebOSShell: State changed to minimized"); m_surfaceState.reset(); + m_handler.OnConfigure(0, m_windowSize, m_surfaceState); break; case webos_shell_surface_state::_default: CLog::Log(LOGDEBUG, "CShellSurfaceWebOSShell: State changed to default (windowed)"); diff --git a/xbmc/windowing/wayland/WinSystemWayland.h b/xbmc/windowing/wayland/WinSystemWayland.h index a2bd12cb4e..95f2a9cfea 100644 --- a/xbmc/windowing/wayland/WinSystemWayland.h +++ b/xbmc/windowing/wayland/WinSystemWayland.h @@ -118,6 +118,10 @@ protected: virtual void SetContextSize(CSizeInt size) = 0; virtual IShellSurface* CreateShellSurface(const std::string& name); + // IShellSurfaceHandler + void OnConfigure(std::uint32_t serial, CSizeInt size, IShellSurface::StateBitset state) override; + void OnClose() override; + private: // IInputHandler void OnEnter(InputType type) override; @@ -133,10 +137,6 @@ private: void OnWindowMaximize() override; void OnWindowMinimize() override; - // IShellSurfaceHandler - void OnConfigure(std::uint32_t serial, CSizeInt size, IShellSurface::StateBitset state) override; - void OnClose() override; - // Registry handlers void OnSeatAdded(std::uint32_t name, wayland::proxy_t&& seat); void OnSeatRemoved(std::uint32_t name); diff --git a/xbmc/windowing/wayland/WinSystemWaylandWebOS.cpp b/xbmc/windowing/wayland/WinSystemWaylandWebOS.cpp index 18be9a613c..bfbb2fa286 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandWebOS.cpp +++ b/xbmc/windowing/wayland/WinSystemWaylandWebOS.cpp @@ -12,9 +12,14 @@ #include "OSScreenSaverWebOS.h" #include "Registry.h" #include "ShellSurfaceWebOSShell.h" +#include "application/ApplicationComponents.h" +#include "application/ApplicationPlayer.h" #include "cores/AudioEngine/Sinks/AESinkStarfish.h" #include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecStarfish.h" #include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererStarfish.h" +#include "input/actions/Action.h" +#include "input/actions/ActionIDs.h" +#include "messaging/ApplicationMessenger.h" #include "utils/JSONVariantParser.h" #include "utils/log.h" @@ -149,6 +154,37 @@ bool CWinSystemWaylandWebOS::OnAppLifecycleEventWrapper(LSHandle* sh, LSMessage* return static_cast<CWinSystemWaylandWebOS*>(context->userdata)->OnAppLifecycleEvent(sh, reply); } +void CWinSystemWaylandWebOS::OnConfigure(std::uint32_t serial, + CSizeInt size, + IShellSurface::StateBitset state) +{ + const auto& components = CServiceBroker::GetAppComponents(); + const auto player = components.GetComponent<CApplicationPlayer>(); + + // intercept minimized event, passing the minimized event causes a weird animation + if (state.none()) + { + m_resumePlayback = false; + + if (player->IsPlaying() && player->HasVideo() && !player->IsPaused()) + { + CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, + static_cast<void*>(new CAction(ACTION_PAUSE))); + m_resumePlayback = true; + } + } + else + { + if (m_resumePlayback && player->IsPlaying() && player->HasVideo() && player->IsPaused()) + { + CServiceBroker::GetAppMessenger()->SendMsg( + TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_PLAYER_PLAY))); + m_resumePlayback = false; + } + CWinSystemWayland::OnConfigure(serial, size, state); + } +} + bool CWinSystemWaylandWebOS::OnAppLifecycleEvent(LSHandle* sh, LSMessage* reply) { const char* msg = HLunaServiceMessage(reply); diff --git a/xbmc/windowing/wayland/WinSystemWaylandWebOS.h b/xbmc/windowing/wayland/WinSystemWaylandWebOS.h index a9427e299f..3f3c9821b4 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandWebOS.h +++ b/xbmc/windowing/wayland/WinSystemWaylandWebOS.h @@ -46,6 +46,7 @@ public: bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; ~CWinSystemWaylandWebOS() noexcept override; bool HasCursor() override; + void OnConfigure(std::uint32_t serial, CSizeInt size, IShellSurface::StateBitset state) override; protected: std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() override; @@ -64,6 +65,8 @@ private: std::unique_ptr<HContext, int (*)(HContext*)> m_requestContext{new HContext(), HUnregisterServiceCallback}; + + bool m_resumePlayback{false}; }; } // namespace KODI::WINDOWING::WAYLAND |