1 /*****************************************************************************
2 * video.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <vlc_common.h>
34 #include <vlc_interface.h>
38 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *,
39 int *pi_x_hint, int *pi_y_hint,
40 unsigned int *pi_width_hint,
41 unsigned int *pi_height_hint );
42 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
44 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
45 int i_query, va_list args );
47 /* IDs for the controls and the menu commands */
50 UpdateSize_Event = 1000 + 1,
55 class VideoWindow : public CBaseWindow
59 VideoWindow( intf_thread_t *_p_intf, HWND _p_parent );
60 virtual ~VideoWindow();
62 void *GetWindow( vout_thread_t *, int *, int *, unsigned int *,
64 void ReleaseWindow( void * );
65 int ControlWindow( void *, int, va_list );
67 HWND p_child_window; // public because of menu
70 intf_thread_t *p_intf;
71 vout_thread_t *p_vout;
75 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
78 /*****************************************************************************
80 *****************************************************************************/
81 CBaseWindow *CreateVideoWindow( intf_thread_t *p_intf, HWND p_parent )
83 return new VideoWindow( p_intf, p_parent );
86 /*****************************************************************************
88 *****************************************************************************/
89 VideoWindow::VideoWindow( intf_thread_t *_p_intf, HWND _p_parent )
97 p_child_window = NULL;
99 vlc_mutex_init( &lock );
103 // Changeset 138da19...
104 //p_intf->pf_request_window = ::GetWindow;
105 //p_intf->pf_release_window = ::ReleaseWindow;
106 //p_intf->pf_control_window = ::ControlWindow;
108 p_intf->p_sys->p_video_window = this;
110 GetClientRect( p_parent, &rect );
112 wc.style = CS_HREDRAW | CS_VREDRAW ;
113 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
117 wc.hInstance = GetModuleHandle(0);
119 wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
120 wc.lpszMenuName = NULL;
121 wc.lpszClassName = _T("VIDEOWINDOW");
122 RegisterClass( &wc );
124 p_child_window = CreateWindow (
125 _T("VIDEOWINDOW"), _T(""),
126 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_BORDER,
127 0, 20, rect.right - rect.left,
128 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT - 20,
129 p_parent, NULL, GetModuleHandle(0), (void *)this );
131 ShowWindow( p_child_window, SW_SHOW );
132 UpdateWindow( p_child_window );
134 ReleaseWindow( (void*)p_child_window );
137 VideoWindow::~VideoWindow()
139 vlc_mutex_destroy( &lock );
142 /*****************************************************************************
144 *****************************************************************************/
145 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
146 int *pi_x_hint, int *pi_y_hint,
147 unsigned int *pi_width_hint,
148 unsigned int *pi_height_hint )
150 return p_intf->p_sys->p_video_window->GetWindow( p_vout, pi_x_hint,
151 pi_y_hint, pi_width_hint, pi_height_hint );
154 void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
155 int *pi_x_hint, int *pi_y_hint,
156 unsigned int *pi_width_hint,
157 unsigned int *pi_height_hint )
159 vlc_mutex_lock( &lock );
163 vlc_mutex_unlock( &lock );
164 msg_Dbg( p_intf, "Video window already in use" );
170 vlc_mutex_unlock( &lock );
172 ShowWindow( (HWND)p_child_window, SW_SHOW );
173 return p_child_window;
176 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
178 p_intf->p_sys->p_video_window->ReleaseWindow( p_window );
181 void VideoWindow::ReleaseWindow( void *p_window )
183 vlc_mutex_lock( &lock );
185 vlc_mutex_unlock( &lock );
187 ShowWindow( (HWND)p_window, SW_HIDE );
188 SetForegroundWindow( p_parent );
191 /***********************************************************************
197 Processes messages sent to the main window.
199 ***********************************************************************/
200 LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
206 vout_Control( p_vout, VOUT_SET_FOCUS, (bool)false );
211 vout_Control( p_vout, VOUT_SET_FOCUS, (bool)true );
215 return DefWindowProc( hwnd, msg, wp, lp );
220 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
221 int i_query, va_list args )
223 return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
227 int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
229 int i_ret = VLC_EGENERIC;
231 vlc_mutex_lock( &lock );
235 case VOUT_SET_STAY_ON_TOP:
239 msg_Dbg( p_intf, "control query not supported" );
243 vlc_mutex_unlock( &lock );