aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenen92 <92enen@gmail.com>2024-02-07 11:02:57 +0000
committerenen92 <92enen@gmail.com>2024-02-09 12:09:16 +0000
commit98dc3eba5f0b4fba607a14836cd9f3b6d97164cf (patch)
tree31a8ae63e672e85555e7f5d9ab538a2967f614a2
parent7a7420fcd6153bfebc21ac4d2f6764ee9ef7364e (diff)
Screensaver: Do not force dim if another modal is being shown
-rw-r--r--xbmc/application/ApplicationPowerHandling.cpp6
-rw-r--r--xbmc/windows/GUIWindowScreensaver.cpp30
-rw-r--r--xbmc/windows/GUIWindowScreensaver.h8
3 files changed, 30 insertions, 14 deletions
diff --git a/xbmc/application/ApplicationPowerHandling.cpp b/xbmc/application/ApplicationPowerHandling.cpp
index a0978df33e..4354b9b626 100644
--- a/xbmc/application/ApplicationPowerHandling.cpp
+++ b/xbmc/application/ApplicationPowerHandling.cpp
@@ -394,10 +394,8 @@ void CApplicationPowerHandling::ActivateScreenSaver(bool forceType /*= false */)
// Enforce Dim for special cases.
bool bUseDim = false;
- if (CServiceBroker::GetGUI()->GetWindowManager().HasModalDialog(true))
- bUseDim = true;
- else if (appPlayer && appPlayer->IsPlayingVideo() &&
- settings->GetBool(CSettings::SETTING_SCREENSAVER_USEDIMONPAUSE))
+ if (appPlayer && appPlayer->IsPlayingVideo() &&
+ settings->GetBool(CSettings::SETTING_SCREENSAVER_USEDIMONPAUSE))
bUseDim = true;
else if (CServiceBroker::GetPVRManager().Get<PVR::GUI::Channels>().IsRunningChannelScan())
bUseDim = true;
diff --git a/xbmc/windows/GUIWindowScreensaver.cpp b/xbmc/windows/GUIWindowScreensaver.cpp
index 009b5eef5c..75d2194d38 100644
--- a/xbmc/windows/GUIWindowScreensaver.cpp
+++ b/xbmc/windows/GUIWindowScreensaver.cpp
@@ -17,14 +17,17 @@
#include "application/ApplicationComponents.h"
#include "application/ApplicationPowerHandling.h"
#include "guilib/GUIComponent.h"
+#include "guilib/GUITexture.h"
#include "guilib/GUIWindowManager.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
using namespace KODI;
-CGUIWindowScreensaver::CGUIWindowScreensaver() : CGUIWindow(WINDOW_SCREENSAVER, "")
+CGUIWindowScreensaver::CGUIWindowScreensaver()
+ : CGUIDialog(WINDOW_SCREENSAVER, "", DialogModalityType::MODELESS)
{
+ m_renderOrder = RENDER_ORDER_WINDOW_SCREENSAVER;
}
void CGUIWindowScreensaver::Process(unsigned int currentTime, CDirtyRegionList& regions)
@@ -38,6 +41,10 @@ void CGUIWindowScreensaver::Process(unsigned int currentTime, CDirtyRegionList&
void CGUIWindowScreensaver::Render()
{
+ // FIXME/TODO: Screensaver addons should make the screen black instead
+ // keeping this just for compatibility reasons since it's now a dialog.
+ CGUITexture::DrawQuad(m_renderRegion, UTILS::COLOR::BLACK);
+
if (m_addon)
{
auto& context = CServiceBroker::GetWinSystem()->GetGfxContext();
@@ -48,15 +55,24 @@ void CGUIWindowScreensaver::Render()
return;
}
- CGUIWindow::Render();
+ CGUIDialog::Render();
+}
+
+void CGUIWindowScreensaver::OnInitWindow()
+{
+ CGUIDialog::OnInitWindow();
+ m_visible = true;
}
-// called when the mouse is moved/clicked etc. etc.
-EVENT_RESULT CGUIWindowScreensaver::OnMouseEvent(const CPoint& point,
- const MOUSE::CMouseEvent& event)
+void CGUIWindowScreensaver::UpdateVisibility()
{
- CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
- return EVENT_RESULT_HANDLED;
+ auto& components = CServiceBroker::GetAppComponents();
+ const auto appPower = components.GetComponent<CApplicationPowerHandling>();
+ if (!appPower->IsInScreenSaver() && m_visible)
+ {
+ m_visible = false;
+ Close();
+ }
}
bool CGUIWindowScreensaver::OnMessage(CGUIMessage& message)
diff --git a/xbmc/windows/GUIWindowScreensaver.h b/xbmc/windows/GUIWindowScreensaver.h
index 2ec9ae8ccc..4dae29028a 100644
--- a/xbmc/windows/GUIWindowScreensaver.h
+++ b/xbmc/windows/GUIWindowScreensaver.h
@@ -8,7 +8,7 @@
#pragma once
-#include "guilib/GUIWindow.h"
+#include "guilib/GUIDialog.h"
#include <memory>
@@ -20,7 +20,7 @@ class CScreenSaver;
} // namespace ADDONS
} // namespace KODI
-class CGUIWindowScreensaver : public CGUIWindow
+class CGUIWindowScreensaver : public CGUIDialog
{
public:
CGUIWindowScreensaver();
@@ -35,8 +35,10 @@ public:
void Process(unsigned int currentTime, CDirtyRegionList& regions) override;
protected:
- EVENT_RESULT OnMouseEvent(const CPoint& point, const KODI::MOUSE::CMouseEvent& event) override;
+ void UpdateVisibility() override;
+ void OnInitWindow() override;
private:
std::unique_ptr<KODI::ADDONS::CScreenSaver> m_addon;
+ bool m_visible{false};
};