Commit 84ade0ea authored by Erwan Tulou's avatar Erwan Tulou

skins2: rework of vout manager

This patch does the following :
- as a vout window provider, make sure skins functions run by vout thread(s)
  don't issue any calls to the GUI. (skins on Linux runs fine at last !)
- prepare support for SET_VOUT_SET_FULLSCREEN new control
- implement hotkeys (no longer available at the vout level)
- modify a show() method not consistent across platform
- cleanup (dead code)
parent 9ad7729f
......@@ -32,6 +32,8 @@ SOURCES_skins2 = \
commands/cmd_quit.hpp \
commands/cmd_resize.cpp \
commands/cmd_resize.hpp \
commands/cmd_voutwindow.cpp \
commands/cmd_voutwindow.hpp \
commands/cmd_snapshot.cpp \
commands/cmd_snapshot.hpp \
commands/cmd_show_window.hpp \
......
......@@ -44,7 +44,6 @@ void CmdChangeSkin::execute()
pOldTheme->getWindowManager().hideAll();
}
VoutManager::instance( getIntf() )->lockVout();
VoutManager::instance( getIntf() )->saveVoutConfig();
ThemeLoader loader( getIntf() );
......@@ -57,7 +56,6 @@ void CmdChangeSkin::execute()
// restore vout config
VoutManager::instance( getIntf() )->restoreVoutConfig( true );
VoutManager::instance( getIntf() )->unlockVout();
}
else if( pOldTheme )
{
......@@ -65,12 +63,10 @@ void CmdChangeSkin::execute()
" restoring the previous one" );
getIntf()->p_sys->p_theme = pOldTheme;
VoutManager::instance( getIntf() )->restoreVoutConfig( false );
VoutManager::instance( getIntf() )->unlockVout();
pOldTheme->getWindowManager().restoreVisibility();
}
else
{
VoutManager::instance( getIntf() )->unlockVout();
msg_Err( getIntf(), "cannot load the theme, aborting" );
// Quit
CmdQuit cmd( getIntf() );
......
......@@ -24,11 +24,10 @@
#include "cmd_resize.hpp"
#include "../src/generic_layout.hpp"
#include "../src/window_manager.hpp"
#include "../src/vlcproc.hpp"
#include "../src/vout_window.hpp"
#include "../src/window_manager.hpp"
#include "../src/vout_manager.hpp"
#include "../controls/ctrl_video.hpp"
#include <vlc_vout.h>
CmdResize::CmdResize( intf_thread_t *pIntf, const WindowManager &rWindowManager,
......@@ -46,39 +45,46 @@ void CmdResize::execute()
}
CmdResizeVout::CmdResizeVout( intf_thread_t *pIntf, VoutWindow *pVoutWindow,
int width, int height ):
CmdGeneric( pIntf ), m_pVoutWindow( pVoutWindow ), m_width( width ),
m_height( height )
CmdResizeInnerVout::CmdResizeInnerVout( intf_thread_t *pIntf,
CtrlVideo* pCtrlVideo )
: CmdGeneric( pIntf ), m_pCtrlVideo( pCtrlVideo )
{
}
void CmdResizeVout::execute()
void CmdResizeInnerVout::execute()
{
if( m_pVoutWindow )
{
m_pVoutWindow->setOriginalWidth( m_width );
m_pVoutWindow->setOriginalHeight( m_height );
CtrlVideo* pCtrlVideo = m_pVoutWindow->getCtrlVideo();
if( pCtrlVideo )
{
pCtrlVideo->resizeControl( m_width, m_height );
}
}
m_pCtrlVideo->resizeInnerVout();
}
CmdResizeInnerVout::CmdResizeInnerVout( intf_thread_t *pIntf,
CtrlVideo* pCtrlVideo )
: CmdGeneric( pIntf ), m_pCtrlVideo( pCtrlVideo )
CmdResizeVout::CmdResizeVout( intf_thread_t *pIntf, vout_window_t* pWnd,
int width, int height )
: CmdGeneric( pIntf ), m_pWnd( pWnd ), m_width( width ), m_height( height )
{
}
void CmdResizeInnerVout::execute()
void CmdResizeVout::execute()
{
VoutManager* p_VoutManager = getIntf()->p_sys->p_voutManager;
p_VoutManager->setSizeWnd( m_pWnd, m_width, m_height );
}
CmdSetFullscreen::CmdSetFullscreen( intf_thread_t *pIntf,
vout_window_t * pWnd, bool fullscreen )
: CmdGeneric( pIntf ), m_pWnd( pWnd ), m_bFullscreen( fullscreen )
{
m_pCtrlVideo->resizeInnerVout();
}
void CmdSetFullscreen::execute()
{
VoutManager* p_VoutManager = getIntf()->p_sys->p_voutManager;
p_VoutManager->setFullscreenWnd( m_pWnd, m_bFullscreen );
}
......@@ -26,12 +26,11 @@
#define CMD_RESIZE_HPP
#include "cmd_generic.hpp"
#include <vlc_vout.h>
#include <vlc_vout_window.h>
class WindowManager;
class GenericLayout;
class CtrlVideo;
class VoutWindow;
/// Command to resize a layout
......@@ -56,12 +55,31 @@ class CmdResize: public CmdGeneric
};
/// Command to resize the inner vout window
class CmdResizeInnerVout: public CmdGeneric
{
public:
/// Resize the given layout
CmdResizeInnerVout( intf_thread_t *pIntf, CtrlVideo* pCtrlVideo );
virtual ~CmdResizeInnerVout() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "resize inner vout"; }
private:
CtrlVideo* m_pCtrlVideo;
};
/// Command to resize the vout window
class CmdResizeVout: public CmdGeneric
{
public:
/// Resize the given layout
CmdResizeVout( intf_thread_t *pIntf, VoutWindow *pVoutWindow,
CmdResizeVout( intf_thread_t *pIntf, vout_window_t* pWnd,
int width, int height );
virtual ~CmdResizeVout() {}
......@@ -72,27 +90,29 @@ class CmdResizeVout: public CmdGeneric
virtual string getType() const { return "resize vout"; }
private:
VoutWindow *m_pVoutWindow;
vout_window_t* m_pWnd;
int m_width, m_height;
};
/// Command to resize the inner vout window
class CmdResizeInnerVout: public CmdGeneric
/// Command to toggle Fullscreen
class CmdSetFullscreen: public CmdGeneric
{
public:
/// Resize the given layout
CmdResizeInnerVout( intf_thread_t *pIntf, CtrlVideo* pCtrlVideo );
virtual ~CmdResizeInnerVout() {}
CmdSetFullscreen( intf_thread_t *pIntf, vout_window_t* pWnd,
bool fullscreen );
virtual ~CmdSetFullscreen() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "resize inner vout"; }
virtual string getType() const { return "toogle fullscreen"; }
private:
CtrlVideo* m_pCtrlVideo;
vout_window_t* m_pWnd;
bool m_bFullscreen;
};
#endif
/*****************************************************************************
* cmd_voutwindow.cpp
*****************************************************************************
* Copyright (C) 2009 the VideoLAN team
* $Id$
*
* Author: Erwan Tulou <erwan10 aT videolan doT org >
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "cmd_voutwindow.hpp"
#include "../src/vout_manager.hpp"
#include "../src/vout_window.hpp"
CmdNewVoutWindow::CmdNewVoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd )
: CmdGeneric( pIntf ), m_pWnd( pWnd )
{
}
void CmdNewVoutWindow::execute()
{
vlc_mutex_lock( &getIntf()->p_sys->vout_lock );
VoutManager* p_VoutManager = getIntf()->p_sys->p_voutManager;
void* handle = p_VoutManager->acceptWnd( m_pWnd );
getIntf()->p_sys->handle = handle;
getIntf()->p_sys->b_vout_ready = true;
vlc_cond_signal( &getIntf()->p_sys->vout_wait );
vlc_mutex_unlock( &getIntf()->p_sys->vout_lock );
}
CmdReleaseVoutWindow::CmdReleaseVoutWindow( intf_thread_t *pIntf,
vout_window_t* pWnd )
: CmdGeneric( pIntf ), m_pWnd( pWnd )
{
}
void CmdReleaseVoutWindow::execute()
{
vlc_mutex_lock( &getIntf()->p_sys->vout_lock );
VoutManager* p_VoutManager = getIntf()->p_sys->p_voutManager;
p_VoutManager->releaseWnd( m_pWnd );
getIntf()->p_sys->b_vout_ready = true;
vlc_cond_signal( &getIntf()->p_sys->vout_wait );
vlc_mutex_unlock( &getIntf()->p_sys->vout_lock );
}
/*****************************************************************************
* cmd_voutwindow.hpp
*****************************************************************************
* Copyright (C) 2009 the VideoLAN team
* $Id$
*
* Author: Erwan Tulou <erwan10 aT videolan doT org >
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CMD_VOUTWINDOW_HPP
#define CMD_VOUTWINDOW_HPP
#include "cmd_generic.hpp"
#include <vlc_vout_window.h>
/// Command to create a vout window
class CmdNewVoutWindow: public CmdGeneric
{
public:
/// Create a vout window
CmdNewVoutWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
virtual ~CmdNewVoutWindow() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "new vout window"; }
private:
vout_window_t* m_pWnd;
};
/// Command to release a vout window
class CmdReleaseVoutWindow: public CmdGeneric
{
public:
/// Release a vout window
CmdReleaseVoutWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
virtual ~CmdReleaseVoutWindow() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "new vout window"; }
private:
vout_window_t* m_pWnd;
};
#endif
......@@ -89,9 +89,8 @@ void CtrlVideo::onPositionChange()
void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
{
GenericWindow *pParent = getWindow();
const Position *pPos = getPosition();
if( pParent && pPos )
if( pPos && !m_pVoutWindow )
{
// Draw a black rectangle under the video to avoid transparency
rImage.fillRect( pPos->getLeft(), pPos->getTop(), pPos->getWidth(),
......@@ -118,28 +117,28 @@ void CtrlVideo::setLayout( GenericLayout *pLayout,
void CtrlVideo::resizeControl( int width, int height )
{
int newWidth = width + m_xShift;
int newHeight = height + m_yShift;
// Create a resize command
// FIXME: this way of getting the window manager kind of sucks
WindowManager &rWindowManager =
getIntf()->p_sys->p_theme->getWindowManager();
rWindowManager.startResize( m_rLayout, WindowManager::kResizeSE );
CmdGeneric *pCmd = new CmdResize( getIntf(), rWindowManager,
m_rLayout, newWidth, newHeight );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
pQueue->push( CmdGenericPtr( pCmd ), false );
// FIXME: this should be a command too
rWindowManager.stopResize();
const Position *pPos = getPosition();
pCmd = new CmdResizeInnerVout( getIntf(), this );
pQueue->push( CmdGenericPtr( pCmd ), false );
if( width != pPos->getWidth() || height != pPos->getHeight() )
{
// new layout dimensions
int newWidth = width + m_xShift;
int newHeight = height + m_yShift;
TopWindow* pWin = getWindow();
rWindowManager.show( *pWin );
// Resize the layout
rWindowManager.startResize( m_rLayout, WindowManager::kResizeSE );
rWindowManager.resize( m_rLayout, newWidth, newHeight );
rWindowManager.stopResize();
if( m_pVoutWindow )
{
m_pVoutWindow->resize( pPos->getWidth(), pPos->getHeight() );
m_pVoutWindow->move( pPos->getLeft(), pPos->getTop() );
}
}
}
......@@ -225,9 +224,6 @@ void CtrlVideo::resizeInnerVout( )
m_pVoutWindow->resize( pPos->getWidth(), pPos->getHeight() );
m_pVoutWindow->move( pPos->getLeft(), pPos->getTop() );
rWindowManager.show( *pWin );
m_pVoutWindow->show();
}
}
......@@ -148,7 +148,7 @@ void GenericWindow::innerShow()
{
if( m_pOsWindow )
{
m_pOsWindow->show( m_left, m_top );
m_pOsWindow->show();
}
}
......
......@@ -38,7 +38,7 @@ class OSWindow: public SkinObject
virtual ~OSWindow() {}
// Show the window
virtual void show( int left, int top ) const = 0;
virtual void show() const = 0;
// Hide the window
virtual void hide() const = 0;
......
......@@ -146,6 +146,12 @@ struct intf_sys_t
vlc_mutex_t init_lock;
vlc_cond_t init_wait;
bool b_ready;
/// handle (vout windows)
void* handle;
vlc_mutex_t vout_lock;
vlc_cond_t vout_wait;
bool b_vout_ready;
};
......
......@@ -150,6 +150,9 @@ static int Open( vlc_object_t *p_this )
skin_load.intf = p_intf;
vlc_mutex_unlock( &skin_load.mutex );
vlc_mutex_init( &p_intf->p_sys->vout_lock );
vlc_cond_init( &p_intf->p_sys->vout_wait );
return VLC_SUCCESS;
}
......@@ -179,6 +182,9 @@ static void Close( vlc_object_t *p_this )
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
#endif
vlc_cond_destroy( &p_intf->p_sys->vout_wait );
vlc_mutex_destroy( &p_intf->p_sys->vout_lock );
// Destroy structure
free( p_intf->p_sys );
}
......@@ -309,9 +315,6 @@ static void *Run( void * p_obj )
// Destroy OSLoop
OSFactory::instance( p_intf )->destroyOSLoop();
// save config file
config_SaveConfigFile( p_intf, NULL );
// save and delete the theme
if( p_intf->p_sys->p_theme )
{
......@@ -323,6 +326,9 @@ static void *Run( void * p_obj )
msg_Dbg( p_intf, "current theme deleted" );
}
// save config file
config_SaveConfigFile( p_intf, NULL );
end:
// Destroy "singleton" objects
Dialogs::destroy( p_intf );
......@@ -347,6 +353,7 @@ end:
return NULL;
}
static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
// Callbacks for vout requests
static int WindowOpen( vlc_object_t *p_this )
......@@ -360,16 +367,20 @@ static int WindowOpen( vlc_object_t *p_this )
vlc_object_release( pIntf );
vlc_mutex_lock( &serializer );
pWnd->handle.hwnd = VoutManager::getWindow( pIntf, pWnd );
if( pWnd->handle.hwnd )
{
pWnd->sys = (vout_window_sys_t*)pIntf;
pWnd->control = &VoutManager::controlWindow;
vlc_mutex_unlock( &serializer );
return VLC_SUCCESS;
}
else
{
vlc_mutex_unlock( &serializer );
return VLC_EGENERIC;
}
}
......
......@@ -367,8 +367,12 @@ void TopWindow::innerShow()
updateShape();
m_pActiveLayout->onShow();
}
// Show the window
GenericWindow::innerShow();
// place the top window on the screen (after show!)
move( getLeft(), getTop() );
}
......
......@@ -33,6 +33,7 @@
#include "../commands/async_queue.hpp"
#include "../commands/cmd_show_window.hpp"
#include "../commands/cmd_resize.hpp"
#include "../commands/cmd_voutwindow.hpp"
......@@ -58,16 +59,12 @@ VoutManager::VoutManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_pVoutMainWindow( NULL ), m_pCtrlVideoVec(),
m_pCtrlVideoVecBackup(), m_SavedWndVec()
{
vlc_mutex_init( &vout_lock );
m_pVoutMainWindow = new VoutMainWindow( getIntf() );
}
VoutManager::~VoutManager( )
{
vlc_mutex_destroy( &vout_lock );
delete m_pVoutMainWindow;
}
......@@ -176,8 +173,11 @@ CtrlVideo* VoutManager::getBestCtrlVideo( )
}
void* VoutManager::acceptWnd( vout_window_t* pWnd, int width, int height )
void* VoutManager::acceptWnd( vout_window_t* pWnd )
{
int width = (int)pWnd->cfg->width;
int height = (int)pWnd->cfg->height;
// Creation of a dedicated Window per vout thread
VoutWindow* pVoutWindow = new VoutWindow( getIntf(), pWnd, width, height,
(GenericWindow*) m_pVoutMainWindow );
......@@ -196,13 +196,82 @@ void* VoutManager::acceptWnd( vout_window_t* pWnd, int width, int height )
// save vout characteristics
m_SavedWndVec.push_back( SavedWnd( pWnd, pVoutWindow, pCtrlVideo ) );
msg_Dbg( getIntf(), "New incoming vout=0x%p, handle=0x%p, VideoCtrl=0x%p",
pWnd, handle, pCtrlVideo );
msg_Dbg( pWnd, "New vout : handle = %p, Ctrl = %p, w x h = %dx%d",
handle, pCtrlVideo, width, height );
return handle;
}
void VoutManager::releaseWnd( vout_window_t *pWnd )
{
// remove vout thread from savedVec
vector<SavedWnd>::iterator it;
for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
{
if( (*it).pWnd == pWnd )
{
msg_Dbg( getIntf(), "vout released vout=0x%p, VideoCtrl=0x%p",
pWnd, (*it).pCtrlVideo );
// if a video control was being used, detach from it
if( (*it).pCtrlVideo )
{
(*it).pCtrlVideo->detachVoutWindow( );
}
// remove resources
delete (*it).pVoutWindow;
m_SavedWndVec.erase( it );
break;
}
}
}
void VoutManager::setSizeWnd( vout_window_t *pWnd, int width, int height )
{
msg_Dbg( pWnd, "setSize (%dx%d) received from vout threadr",
width, height );
vector<SavedWnd>::iterator it;
for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
{
if( (*it).pWnd == pWnd )
{
VoutWindow* pVoutWindow = (*it).pVoutWindow;
pVoutWindow->setOriginalWidth( width );
pVoutWindow->setOriginalHeight( height );
CtrlVideo* pCtrlVideo = pVoutWindow->getCtrlVideo();
if( pCtrlVideo )
{
pCtrlVideo->resizeControl( width, height );
}
break;
}
}
}
void VoutManager::setFullscreenWnd( vout_window_t *pWnd, bool b_fullscreen )
{
msg_Dbg( pWnd, "setFullscreen (%d) received from vout thread",
b_fullscreen ? 1 : 0 );
vector<SavedWnd>::iterator it;
for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
{
if( (*it).pWnd == pWnd )
{
VoutWindow* pVoutWindow = (*it).pVoutWindow;
pVoutWindow->setFullscreen( b_fullscreen );
break;
}
}
}
// Functions called by window provider
// ///////////////////////////////////
......@@ -212,16 +281,21 @@ void *VoutManager::getWindow( intf_thread_t *pIntf, vout_window_t *pWnd )
if( !pIntf->p_sys->p_theme )
return NULL;
VoutManager *pThis = pIntf->p_sys->p_voutManager;
vlc_mutex_lock( &pIntf->p_sys->vout_lock );
pIntf->p_sys->b_vout_ready = false;
pIntf->p_sys->handle = NULL;
int width = (int)pWnd->cfg->width;
int height = (int)pWnd->cfg->height;
CmdNewVoutWindow *pCmd =
new CmdNewVoutWindow( pIntf, pWnd );
pThis->lockVout();
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
pQueue->push( CmdGenericPtr( pCmd ), false );
void* handle = pThis->acceptWnd( pWnd, width, height );
while( !pIntf->p_sys->b_vout_ready )
vlc_cond_wait( &pIntf->p_sys->vout_wait, &pIntf->p_sys->vout_lock );
pThis->unlockVout();
void* handle = pIntf->p_sys->handle;
vlc_mutex_unlock( &pIntf->p_sys->vout_lock );
return handle;
}
......@@ -229,37 +303,19 @@ void *VoutManager::getWindow( intf_thread_t *pIntf, vout_window_t *pWnd )
void VoutManager::releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd )
{
VoutManager *pThis = pIntf->p_sys->p_voutManager;
vlc_mutex_lock( &pIntf->p_sys->vout_lock );
pIntf->p_sys->b_vout_ready = false;
// Theme may have been destroyed
if( !pIntf->p_sys->p_theme )
return;
pThis->lockVout();
// remove vout thread from savedVec
vector<SavedWnd>::iterator it;
for( it = pThis->m_SavedWndVec.begin(); it != pThis->m_SavedWndVec.end(); it++ )
{
if( (*it).pWnd == pWnd )
{
msg_Dbg( pIntf, "vout released vout=0x%p, VideoCtrl=0x%p",
pWnd, (*it).pCtrlVideo );
CmdReleaseVoutWindow *pCmd =
new CmdReleaseVoutWindow( pIntf, pWnd );
// if a video control was being used, detach from it
if( (*it).pCtrlVideo )
{
(*it).pCtrlVideo->detachVoutWindow( );
}
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
pQueue->push( CmdGenericPtr( pCmd ), false );
// remove resources
delete (*it).pVoutWindow;
pThis->m_SavedWndVec.erase( it );
break;
}
}
while( !pIntf->p_sys->b_vout_ready )
vlc_cond_wait( &pIntf->p_sys->vout_wait, &pIntf->p_sys->vout_lock );
pThis->unlockVout();
vlc_mutex_unlock( &pIntf->p_sys->vout_lock );
}
......@@ -278,31 +334,31 @@ int VoutManager::controlWindow( struct vout_window_t *pWnd,
if( i_width && i_height )
{
pThis->lockVout();
vector<SavedWnd>::iterator it;
for( it = pThis->m_SavedWndVec.begin();
it != pThis->m_SavedWndVec.end(); it++ )
{
if( (*it).pWnd == pWnd )
{
// Post a vout resize command
CmdResizeVout *pCmd =
new CmdResizeVout( pThis->getIntf(),
(*it).pVoutWindow,
i_width, i_height );
AsyncQueue *pQueue =
AsyncQueue::instance( pThis->getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
break;
}
}
pThis->unlockVout();
// Post a vout resize command
CmdResizeVout *pCmd =
new CmdResizeVout( pThis->getIntf(),
pWnd, (int)i_width, (int)i_height );
AsyncQueue *pQueue =
AsyncQueue::instance( pThis->getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
}
return VLC_SUCCESS;
}
case VOUT_WINDOW_SET_FULLSCREEN:
{
bool b_fullscreen = va_arg( args, int );
// Post a vout resize command
CmdSetFullscreen* pCmd =
new CmdSetFullscreen( pThis->getIntf(), pWnd, b_fullscreen );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
return VLC_SUCCESS;
}
default:
msg_Dbg( pWnd, "control query not supported" );
return VLC_EGENERIC;
......
......@@ -80,12 +80,21 @@ class VoutManager: public SkinObject
/// Delete the instance of VoutManager
static void destroy( intf_thread_t *pIntf );
/// Accept Wnd
void* acceptWnd( vout_window_t* pWnd );
/// Release Wnd
void releaseWnd( vout_window_t* pWnd );
/// set size Wnd
void setSizeWnd( vout_window_t* pWnd, int width, int height );
/// set fullscreen Wnd
void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen );
/// Callback to request a vout window
static void *getWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
/// Accept Wnd
void* acceptWnd( vout_window_t* pWnd, int width, int height );
// Window provider (release)
static void releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
......@@ -113,10 +122,6 @@ class VoutManager: public SkinObject
// test if vout are running
bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; }
// (un)lock functions to protect vout sets
void lockVout( ) { vlc_mutex_lock( &vout_lock ); }
void unlockVout( ) { vlc_mutex_unlock( &vout_lock ); }
protected:
// Protected because it is a singleton
VoutManager( intf_thread_t *pIntf );
......@@ -129,8 +134,6 @@ class VoutManager: public SkinObject
vector<SavedWnd> m_SavedWndVec;
VoutMainWindow* m_pVoutMainWindow;
vlc_mutex_t vout_lock;
};
......
......@@ -28,6 +28,11 @@
#include "os_factory.hpp"
#include "os_graphics.hpp"
#include "os_window.hpp"
#include "../events/evt_key.hpp"
#include <vlc_keys.h>
int VoutWindow::count = 0;
......@@ -35,22 +40,18 @@ VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd,
int width, int height, GenericWindow* pParent ) :
GenericWindow( pIntf, 0, 0, false, false, pParent ),
m_pWnd( pWnd ), original_width( width ), original_height( height ),
m_pParentWindow( pParent ), m_pImage( NULL )
m_pParentWindow( pParent ), m_pCtrlVideo( NULL ), m_bFullscreen( false )
{
// counter for debug
count++;
if( m_pWnd )
vlc_object_hold( m_pWnd );
// needed on MS-Windows to prevent vlc hanging
show();
}
VoutWindow::~VoutWindow()
{
delete m_pImage;
if( m_pWnd )
vlc_object_release( m_pWnd );
......@@ -59,38 +60,6 @@ VoutWindow::~VoutWindow()
}
void VoutWindow::resize( int width, int height )
{
// don't try to resize with zero value
if( !width || !height )
return;
// Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Recreate the image
delete m_pImage;
m_pImage = pOsFactory->createOSGraphics( width, height );
// Draw a black rectangle
m_pImage->fillRect( 0, 0, width, height, 0 );
// Resize the window
GenericWindow::resize( width, height );
}
void VoutWindow::refresh( int left, int top, int width, int height )
{
if( m_pImage )
{
if( !m_pCtrlVideo )
{
m_pImage->copyToWindow( *getOSWindow(), left, top,
width, height, left, top );
}
}
}
void VoutWindow::setCtrlVideo( CtrlVideo* pCtrlVideo )
{
if( pCtrlVideo )
......@@ -103,9 +72,12 @@ void VoutWindow::setCtrlVideo( CtrlVideo* pCtrlVideo )
setParent( pCtrlVideo->getWindow(), x, y, w, h );
m_pParentWindow = pCtrlVideo->getWindow();
show();
}
else
{
hide();
setParent( VoutManager::instance( getIntf() )->getVoutMainWindow(),
0, 0, 0, 0 );
m_pParentWindow =
......@@ -115,3 +87,36 @@ void VoutWindow::setCtrlVideo( CtrlVideo* pCtrlVideo )
m_pCtrlVideo = pCtrlVideo;
}
void VoutWindow::setFullscreen( bool b_fullscreen )
{
/*TODO: fullscreen implementation */
}
void VoutWindow::processEvent( EvtKey &rEvtKey )
{
// Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos )
{
vlc_value_t val;
// Set the key
val.i_int = rEvtKey.getKey();
// Set the modifiers
if( rEvtKey.getMod() & EvtInput::kModAlt )
{
val.i_int |= KEY_MODIFIER_ALT;
}
if( rEvtKey.getMod() & EvtInput::kModCtrl )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( rEvtKey.getMod() & EvtInput::kModShift )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
var_Set( getIntf()->p_libvlc, "key-pressed", val );
}
}
......@@ -48,22 +48,24 @@ class VoutWindow: private GenericWindow
using GenericWindow::show;
using GenericWindow::hide;
using GenericWindow::move;
using GenericWindow::resize;
using GenericWindow::getOSHandle;
//@}
/// Resize the window
virtual void resize( int width, int height );
/// get the parent window
virtual GenericWindow* getWindow( ) { return m_pParentWindow; }
/// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height );
/// hotkeys processing
virtual void processEvent( EvtKey &rEvtKey );
/// set and get Video Control for VoutWindow
virtual void setCtrlVideo( CtrlVideo* pCtrlVideo );
virtual CtrlVideo* getCtrlVideo( ) { return m_pCtrlVideo; }
/// toggle fullscreen mode
virtual void setFullscreen( bool b_fullscreen );
virtual bool isFullscreen() { return m_bFullscreen; }
/// get original size of vout
virtual int getOriginalWidth( ) { return original_width; }
virtual int getOriginalHeight( ) { return original_height; }
......@@ -76,9 +78,6 @@ class VoutWindow: private GenericWindow
private:
/// Image when there is no video
OSGraphics *m_pImage;
/// vout thread
vout_window_t* m_pWnd;
......@@ -86,6 +85,9 @@ class VoutWindow: private GenericWindow
int original_width;
int original_height;
/// fulscreen mode indicator
bool m_bFullscreen;
/// VideoControl attached to it
CtrlVideo* m_pCtrlVideo;
......
......@@ -118,7 +118,7 @@ void Win32Window::reparent( void* OSHandle, int x, int y, int w, int h )
}
void Win32Window::show( int left, int top ) const
void Win32Window::show() const
{
ShowWindow( m_hWnd, SW_SHOW );
}
......
......@@ -41,7 +41,7 @@ class Win32Window: public OSWindow
virtual ~Win32Window();
// Show the window
virtual void show( int left, int top ) const;
virtual void show() const;
// Hide the window
virtual void hide() const;
......
......@@ -160,7 +160,9 @@ void X11Loop::handleX11Event()
Theme *pTheme = getIntf()->p_sys->p_theme;
if( pTheme )
{
pTheme->getWindowManager().synchVisibility();
// Commented out as it really doesn't seem useful
// but rather brings visible problems
// pTheme->getWindowManager().synchVisibility();
}
}
return;
......
......@@ -41,36 +41,34 @@ X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
OSWindow( pIntf ), m_rDisplay( rDisplay ), m_pParent( pParentWindow ),
m_dragDrop( dragDrop )
{
XSetWindowAttributes attr;
unsigned long valuemask;
if (pParentWindow)
{
m_wnd_parent = pParentWindow->m_wnd;
int i_screen = DefaultScreen( XDISPLAY );
attr.event_mask = ExposureMask | StructureNotifyMask;
attr.backing_store = Always;
attr.background_pixel = BlackPixel( XDISPLAY, i_screen );
valuemask = CWBackingStore | CWBackPixel | CWEventMask;
}
else
{
m_wnd_parent = DefaultRootWindow( XDISPLAY );
attr.event_mask = ExposureMask | StructureNotifyMask;
valuemask = CWEventMask;
}
XSetWindowAttributes attr;
attr.event_mask = ExposureMask | StructureNotifyMask;
// Create the window
m_wnd = XCreateWindow( XDISPLAY, m_wnd_parent, -10, 0, 1, 1, 0, 0,
InputOutput, CopyFromParent, CWEventMask, &attr );
InputOutput, CopyFromParent, valuemask, &attr );
// Make sure window is created before returning
XMapWindow( XDISPLAY, m_wnd );
bool b_map_notify = false;
do
{
XEvent xevent;
XWindowEvent( XDISPLAY, m_wnd, SubstructureNotifyMask |
StructureNotifyMask, &xevent);
if( (xevent.type == MapNotify)
&& (xevent.xmap.window == m_wnd ) )
{
b_map_notify = true;
}
} while( ! b_map_notify );
XUnmapWindow( XDISPLAY, m_wnd );
// wait for X server to process the previous commands
XSync( XDISPLAY, false );
// Set the colormap for 8bpp mode
if( XPIXELSIZE == 1 )
......@@ -156,11 +154,10 @@ void X11Window::reparent( void* OSHandle, int x, int y, int w, int h )
}
void X11Window::show( int left, int top ) const
void X11Window::show() const
{
// Map the window
XMapRaised( XDISPLAY, m_wnd );
XMoveWindow( XDISPLAY, m_wnd, left, top );
}
......
......@@ -44,7 +44,7 @@ class X11Window: public OSWindow
virtual ~X11Window();
// Show the window
virtual void show( int left, int top ) const;
virtual void show() const;
// Hide the window
virtual void hide() const;
......
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