mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
feat: pause mpv when fullscreen
This commit is contained in:
parent
db8179a45e
commit
c659bb19c6
@ -173,7 +173,8 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
|
||||
}
|
||||
|
||||
void CWallpaperApplication::loadBackgrounds () {
|
||||
if (this->m_context.settings.render.mode == CApplicationContext::NORMAL_WINDOW || this->m_context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW) {
|
||||
if (this->m_context.settings.render.mode == CApplicationContext::NORMAL_WINDOW ||
|
||||
this->m_context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW) {
|
||||
this->m_backgrounds ["default"] = this->loadBackground (this->m_context.settings.general.defaultBackground);
|
||||
return;
|
||||
}
|
||||
@ -349,7 +350,8 @@ void CWallpaperApplication::show () {
|
||||
new WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector (this->m_context);
|
||||
}
|
||||
|
||||
m_inputContext = new WallpaperEngine::Input::CInputContext (new WallpaperEngine::Input::Drivers::CGLFWMouseInput (
|
||||
m_inputContext =
|
||||
new WallpaperEngine::Input::CInputContext (new WallpaperEngine::Input::Drivers::CGLFWMouseInput (
|
||||
reinterpret_cast<Render::Drivers::CGLFWOpenGLDriver*> (m_videoDriver)));
|
||||
}
|
||||
|
||||
@ -374,7 +376,8 @@ void CWallpaperApplication::show () {
|
||||
|
||||
// set all the specific wallpapers required
|
||||
for (const auto& [background, info] : this->m_backgrounds) {
|
||||
m_renderContext->setWallpaper (background, WallpaperEngine::Render::CWallpaper::fromWallpaper (
|
||||
m_renderContext->setWallpaper (background,
|
||||
WallpaperEngine::Render::CWallpaper::fromWallpaper (
|
||||
info->getWallpaper (), *m_renderContext, *m_audioContext, m_browserContext,
|
||||
this->m_context.settings.general.screenScalings [background]));
|
||||
}
|
||||
@ -401,6 +404,13 @@ void CWallpaperApplication::show () {
|
||||
m_audioDriver->update ();
|
||||
// update input information
|
||||
m_inputContext->update ();
|
||||
// check for fullscreen windows and wait until there's none fullscreen
|
||||
if (this->m_fullScreenDetector->anythingFullscreen () && this->m_context.state.general.keepRunning) {
|
||||
m_renderContext->setPause (true);
|
||||
while (this->m_fullScreenDetector->anythingFullscreen () && this->m_context.state.general.keepRunning)
|
||||
usleep (FULLSCREEN_CHECK_WAIT_TIME);
|
||||
m_renderContext->setPause (false);
|
||||
}
|
||||
// process driver events
|
||||
m_videoDriver->dispatchEventQueue ();
|
||||
|
||||
@ -420,10 +430,6 @@ void CWallpaperApplication::show () {
|
||||
}
|
||||
|
||||
void CWallpaperApplication::update (Render::Drivers::Output::COutputViewport* viewport) {
|
||||
// check for fullscreen windows and wait until there's none fullscreen
|
||||
while (this->m_fullScreenDetector->anythingFullscreen () && this->m_context.state.general.keepRunning)
|
||||
usleep (FULLSCREEN_CHECK_WAIT_TIME);
|
||||
|
||||
// render the scene
|
||||
m_renderContext->render (viewport);
|
||||
}
|
||||
|
@ -42,6 +42,11 @@ void CRenderContext::setWallpaper (const std::string& display, CWallpaper* wallp
|
||||
this->m_wallpapers.insert_or_assign (display, wallpaper);
|
||||
}
|
||||
|
||||
void CRenderContext::setPause (bool newState) {
|
||||
for (auto&& wallpaper : this->m_wallpapers)
|
||||
wallpaper.second->setPause (newState);
|
||||
}
|
||||
|
||||
Input::CInputContext& CRenderContext::getInputContext () const {
|
||||
return this->m_input;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ class CRenderContext {
|
||||
|
||||
void render (Drivers::Output::COutputViewport* viewport);
|
||||
void setWallpaper (const std::string& display, CWallpaper* wallpaper);
|
||||
void setPause (bool newState);
|
||||
[[nodiscard]] Input::CInputContext& getInputContext () const;
|
||||
[[nodiscard]] const CWallpaperApplication& getApp () const;
|
||||
[[nodiscard]] const Drivers::CVideoDriver& getDriver () const;
|
||||
|
@ -232,6 +232,8 @@ void CWallpaper::render (glm::ivec4 viewport, bool vflip) {
|
||||
glDrawArrays (GL_TRIANGLES, 0, 6);
|
||||
}
|
||||
|
||||
void CWallpaper::setPause (bool newState) {}
|
||||
|
||||
void CWallpaper::setupFramebuffers () {
|
||||
const uint32_t width = this->getWidth ();
|
||||
const uint32_t height = this->getHeight ();
|
||||
|
@ -50,6 +50,11 @@ class CWallpaper : public Helpers::CContextAware {
|
||||
*/
|
||||
void render (glm::ivec4 viewport, bool vflip);
|
||||
|
||||
/**
|
||||
* Pause the renderer
|
||||
*/
|
||||
virtual void setPause (bool newState);
|
||||
|
||||
/**
|
||||
* @return The container to resolve files for this wallpaper
|
||||
*/
|
||||
@ -141,7 +146,8 @@ class CWallpaper : public Helpers::CContextAware {
|
||||
* @return
|
||||
*/
|
||||
static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||
CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
CWebBrowserContext& browserContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
|
||||
protected:
|
||||
CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRenderContext& context, CAudioContext& audioContext,
|
||||
|
@ -15,6 +15,7 @@ CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& aud
|
||||
CWallpaper (video, Type, context, audioContext, scalingMode),
|
||||
m_width (16),
|
||||
m_height (16),
|
||||
m_paused (false),
|
||||
m_mpvGl (nullptr) {
|
||||
double volume = this->getContext ().getApp ().getContext ().settings.audio.volume * 100.0 / 128.0;
|
||||
|
||||
@ -121,6 +122,14 @@ Core::CVideo* CVideo::getVideo () {
|
||||
return this->getWallpaperData ()->as<Core::CVideo> ();
|
||||
}
|
||||
|
||||
void CVideo::setPause (bool newState) {
|
||||
if (m_paused == newState)
|
||||
return;
|
||||
m_paused = newState;
|
||||
int pause = newState;
|
||||
mpv_set_property (m_mpv, "pause", MPV_FORMAT_FLAG, &pause);
|
||||
}
|
||||
|
||||
int CVideo::getWidth () const {
|
||||
return this->m_width;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class CVideo final : public CWallpaper {
|
||||
[[nodiscard]] int getWidth () const override;
|
||||
[[nodiscard]] int getHeight () const override;
|
||||
|
||||
void setPause (bool newState) override;
|
||||
void setSize (int width, int height);
|
||||
|
||||
protected:
|
||||
@ -31,6 +32,7 @@ class CVideo final : public CWallpaper {
|
||||
mpv_handle* m_mpv;
|
||||
mpv_render_context* m_mpvGl;
|
||||
|
||||
bool m_paused;
|
||||
int64_t m_width;
|
||||
int64_t m_height;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user