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

* skins2: prevent a window from using the layout of another window

parent d3bbcab8
......@@ -28,33 +28,19 @@
#include "../src/theme.hpp"
CmdLayout::CmdLayout( intf_thread_t *pIntf, const string &windowId,
const string &layoutId ):
CmdGeneric( pIntf ), m_windowId( windowId ), m_layoutId( layoutId )
CmdLayout::CmdLayout( intf_thread_t *pIntf, TopWindow &rWindow,
GenericLayout &rLayout ):
CmdGeneric( pIntf ), m_rWindow( rWindow ), m_rLayout( rLayout )
{
}
void CmdLayout::execute()
{
// Get the window and the layout
if( !getIntf()->p_sys->p_theme )
{
return;
}
TopWindow *pWindow =
getIntf()->p_sys->p_theme->getWindowById( m_windowId );
GenericLayout *pLayout =
getIntf()->p_sys->p_theme->getLayoutById( m_layoutId );
if( !pWindow || !pLayout )
{
msg_Err( getIntf(), "Cannot change layout (%s, %s)",
m_windowId.c_str(), m_layoutId.c_str() );
return;
}
// XXX TODO: check that the layout isn't a layout of another window
getIntf()->p_sys->p_theme->getWindowManager().setActiveLayout( *pWindow,
*pLayout );
getIntf()->p_sys->p_theme->getWindowManager().setActiveLayout( m_rWindow,
m_rLayout );
}
......@@ -26,15 +26,16 @@
#define CMD_LAYOUT_HPP
#include "cmd_generic.hpp"
#include <string>
class TopWindow;
class GenericLayout;
/// "Change layout" command
class CmdLayout: public CmdGeneric
{
public:
CmdLayout( intf_thread_t *pIntf, const string &windowId,
const string &layoutId );
CmdLayout( intf_thread_t *pIntf, TopWindow &rWindow,
GenericLayout &rLayout );
virtual ~CmdLayout() {}
/// This method does the real job of the command
......@@ -44,8 +45,8 @@ class CmdLayout: public CmdGeneric
virtual string getType() const { return "change layout"; }
private:
string m_windowId;
string m_layoutId;
TopWindow &m_rWindow;
GenericLayout &m_rLayout;
};
#endif
......@@ -199,7 +199,27 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
int rightPos = rAction.find( ")", windowId.size() + 11 );
string layoutId = rAction.substr( windowId.size() + 11,
rightPos - (windowId.size() + 11) );
pCommand = new CmdLayout( getIntf(), windowId, layoutId );
TopWindow *pWin = pTheme->getWindowById( windowId );
GenericLayout *pLayout = pTheme->getLayoutById( layoutId );
if( !pWin )
{
msg_Err( getIntf(), "Unknown window (%s)", windowId.c_str() );
}
else if( !pLayout )
{
msg_Err( getIntf(), "Unknown layout (%s)", layoutId.c_str() );
}
// Check that the layout doesn't correspond to another window
else if( pWin != pLayout->getWindow() )
{
msg_Err( getIntf(), "Layout %s is not associated to window %s",
layoutId.c_str(), windowId.c_str() );
}
else
{
pCommand = new CmdLayout( getIntf(), *pWin, *pLayout );
}
}
else if( rAction.find( ".show()" ) != string::npos )
{
......
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