skins2: rework skins2 as a vout_window provider
[vlc.git] / modules / gui / skins2 / src / vout_window.cpp
blobba43579f754a83c0f4691cf5d172af7acb947494
1 /*****************************************************************************
2 * vout_window.cpp
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
5 * $Id$
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "vout_window.hpp"
25 #include "vout_manager.hpp"
26 #include "vlcproc.hpp"
27 #include "theme.hpp"
28 #include "os_factory.hpp"
29 #include "os_graphics.hpp"
30 #include "os_window.hpp"
31 #include "../events/evt_key.hpp"
33 #include <vlc_keys.h>
36 VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd,
37 int width, int height, GenericWindow* pParent ) :
38 GenericWindow( pIntf, 0, 0, false, false, pParent,
39 GenericWindow::VoutWindow ),
40 m_pWnd( pWnd ), original_width( width ), original_height( height ),
41 m_pParentWindow( pParent ), m_pCtrlVideo( NULL )
43 if( m_pWnd )
45 vlc_object_hold( m_pWnd );
47 #ifdef X11_SKINS
48 m_pWnd->handle.xid = getOSHandle();
49 if( m_pWnd->handle.xid )
50 m_pWnd->display.x11 =
51 OSFactory::instance( getIntf() )->getDisplay();
52 #else
53 m_pWnd->handle.hwnd = getOSHandle();
54 #endif
60 VoutWindow::~VoutWindow()
62 if( m_pWnd )
64 #ifdef X11_SKINS
65 free( m_pWnd->display.x11 );
66 m_pWnd->display.x11 = NULL;
67 #endif
68 vlc_object_release( m_pWnd );
73 void VoutWindow::setCtrlVideo( CtrlVideo* pCtrlVideo )
75 if( pCtrlVideo )
77 hide();
78 const Position *pPos = pCtrlVideo->getPosition();
79 int x = pPos->getLeft();
80 int y = pPos->getTop();
81 int w = pPos->getWidth();
82 int h = pPos->getHeight();
84 setParent( pCtrlVideo->getWindow(), x, y, w, h );
85 m_pParentWindow = pCtrlVideo->getWindow();
87 show();
89 else
91 hide();
92 int w = VoutManager::instance( getIntf() )->getVoutMainWindow()->getWidth();
93 int h = VoutManager::instance( getIntf() )->getVoutMainWindow()->getHeight();
95 setParent( VoutManager::instance( getIntf() )->getVoutMainWindow(),
96 0, 0, w, h );
97 m_pParentWindow =
98 VoutManager::instance( getIntf() )->getVoutMainWindow();
99 show();
102 m_pCtrlVideo = pCtrlVideo;
106 void VoutWindow::processEvent( EvtKey &rEvtKey )
108 // Only do the action when the key is down
109 if( rEvtKey.getKeyState() == EvtKey::kDown )
110 var_SetInteger( getIntf()->p_libvlc, "key-pressed",
111 rEvtKey.getModKey() );