Commit a3cceda1 authored by Olivier Teulière's avatar Olivier Teulière

* skins2: when restoring the previous skin because a new one failed to load,

   show only the windows that were visible before
parent de277e80
...@@ -38,6 +38,7 @@ void CmdChangeSkin::execute() ...@@ -38,6 +38,7 @@ void CmdChangeSkin::execute()
if( pOldTheme ) if( pOldTheme )
{ {
pOldTheme->getWindowManager().saveVisibility();
pOldTheme->getWindowManager().hideAll(); pOldTheme->getWindowManager().hideAll();
} }
...@@ -57,7 +58,7 @@ void CmdChangeSkin::execute() ...@@ -57,7 +58,7 @@ void CmdChangeSkin::execute()
msg_Warn( getIntf(), "a problem occurred when loading the new theme," msg_Warn( getIntf(), "a problem occurred when loading the new theme,"
" restoring the previous one" ); " restoring the previous one" );
getIntf()->p_sys->p_theme = pOldTheme; getIntf()->p_sys->p_theme = pOldTheme;
pOldTheme->getWindowManager().showAll(); pOldTheme->getWindowManager().restoreVisibility();
} }
else else
{ {
......
...@@ -331,6 +331,37 @@ void WindowManager::synchVisibility() const ...@@ -331,6 +331,37 @@ void WindowManager::synchVisibility() const
} }
void WindowManager::saveVisibility()
{
WinSet_t::const_iterator it;
m_savedWindows.clear();
for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
{
// Remember the window if it is visible
if( (*it)->getVisibleVar().get() )
{
m_savedWindows.insert( *it );
}
}
}
void WindowManager::restoreVisibility() const
{
// Warning in case we never called saveVisibility()
if( m_savedWindows.size() == 0 )
{
msg_Warn( getIntf(), "restoring visibility for no window" );
}
WinSet_t::const_iterator it;
for( it = m_savedWindows.begin(); it != m_savedWindows.end(); it++)
{
(*it)->show();
}
}
void WindowManager::raiseAll() const void WindowManager::raiseAll() const
{ {
// Raise all the windows // Raise all the windows
......
...@@ -59,8 +59,10 @@ class WindowManager: public SkinObject ...@@ -59,8 +59,10 @@ class WindowManager: public SkinObject
/// Destructor /// Destructor
virtual ~WindowManager(); virtual ~WindowManager();
/// Add a window to the list of known windows. Necessary if you want /**
/// your window to be movable... * Add a window to the list of known windows. Necessary if you want
* your window to be movable...
*/
void registerWindow( TopWindow &rWindow ); void registerWindow( TopWindow &rWindow );
/// Remove a previously registered window /// Remove a previously registered window
...@@ -105,6 +107,12 @@ class WindowManager: public SkinObject ...@@ -105,6 +107,12 @@ class WindowManager: public SkinObject
/// Synchronize the windows with their visibility variable /// Synchronize the windows with their visibility variable
void synchVisibility() const; void synchVisibility() const;
/// Save the current visibility of the windows
void saveVisibility();
/// Restore the saved visibility of the windows
void restoreVisibility() const;
/// Raise the given window /// Raise the given window
void raise( TopWindow &rWindow ) const { rWindow.raise(); } void raise( TopWindow &rWindow ) const { rWindow.raise(); }
...@@ -164,8 +172,15 @@ class WindowManager: public SkinObject ...@@ -164,8 +172,15 @@ class WindowManager: public SkinObject
map<TopWindow*, WinSet_t> m_dependencies; map<TopWindow*, WinSet_t> m_dependencies;
/// Store all the windows /// Store all the windows
WinSet_t m_allWindows; WinSet_t m_allWindows;
/// Store the moving windows; this set is updated at every start of /**
/// move. * Store the windows that were visible when saveVisibility() was
* last called.
*/
WinSet_t m_savedWindows;
/// Store the moving windows
/**
* This set is updated at every start of move.
*/
WinSet_t m_movingWindows; WinSet_t m_movingWindows;
/** /**
* Store the moving windows in the context of resizing * Store the moving windows in the context of resizing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment