2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 #include "GUIWindowScreensaver.h"
23 #include "addons/AddonManager.h"
24 #include "Application.h"
25 #include "GUIPassword.h"
26 #include "settings/GUISettings.h"
27 #include "GUIUserMessages.h"
28 #include "guilib/GUIWindowManager.h"
29 #include "threads/SingleLock.h"
31 using namespace ADDON;
33 CGUIWindowScreensaver::CGUIWindowScreensaver(void)
34 : CGUIWindow(WINDOW_SCREENSAVER, "")
38 CGUIWindowScreensaver::~CGUIWindowScreensaver(void)
42 void CGUIWindowScreensaver::Process(unsigned int currentTime, CDirtyRegionList ®ions)
45 CGUIWindow::Process(currentTime, regions);
46 m_renderRegion.SetRect(0, 0, (float)g_graphicsContext.GetWidth(), (float)g_graphicsContext.GetHeight());
49 void CGUIWindowScreensaver::Render()
51 CSingleLock lock (m_critSection);
53 #ifdef HAS_SCREENSAVER
60 //some screensavers seem to be depending on xbmc clearing the screen
61 // g_Windowing.Get3DDevice()->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x00010001, 1.0f, 0L );
62 g_graphicsContext.CaptureStateBlock();
64 g_graphicsContext.ApplyStateBlock();
68 CLog::Log(LOGERROR, "SCREENSAVER: - Exception in Render() - %s", m_addon->Name().c_str());
77 m_bInitialized = true;
81 CLog::Log(LOGERROR, "SCREENSAVER: - Exception in Start() - %s", m_addon->Name().c_str());
90 bool CGUIWindowScreensaver::OnAction(const CAction &action)
92 // We're just a screen saver, nothing to do here
96 // called when the mouse is moved/clicked etc. etc.
97 EVENT_RESULT CGUIWindowScreensaver::OnMouseEvent(const CPoint &point, const CMouseEvent &event)
99 g_windowManager.PreviousWindow();
100 return EVENT_RESULT_HANDLED;
103 bool CGUIWindowScreensaver::OnMessage(CGUIMessage& message)
105 switch ( message.GetMessage() )
107 case GUI_MSG_WINDOW_DEINIT:
109 CSingleLock lock (m_critSection);
110 #ifdef HAS_SCREENSAVER
114 g_graphicsContext.ApplyStateBlock();
119 m_bInitialized = false;
122 // RESOLUTION res = g_graphicsContext.GetVideoResolution();
123 // g_graphicsContext.SetVideoResolution(res, FALSE);
125 // enable the overlay
126 g_windowManager.ShowOverlay(OVERLAY_STATE_SHOWN);
130 case GUI_MSG_WINDOW_INIT:
132 CGUIWindow::OnMessage(message);
133 CSingleLock lock (m_critSection);
135 #ifdef HAS_SCREENSAVER
137 m_bInitialized = false;
140 // Setup new screensaver instance
142 if (!CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
145 m_addon = boost::dynamic_pointer_cast<CScreenSaver>(addon);
150 g_graphicsContext.CaptureStateBlock();
151 m_addon->CreateScreenSaver();
154 // RESOLUTION res = g_graphicsContext.GetVideoResolution();
155 // g_graphicsContext.SetVideoResolution(res, TRUE);
157 // disable the overlay
158 g_windowManager.ShowOverlay(OVERLAY_STATE_HIDDEN);
161 case GUI_MSG_CHECK_LOCK:
162 if (!g_passwordManager.IsProfileLockUnlocked())
164 g_application.m_iScreenSaveLock = -1;
167 g_application.m_iScreenSaveLock = 1;
170 return CGUIWindow::OnMessage(message);