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 p_intf->pf_request_window = ::GetWindow;
104 p_intf->pf_release_window = ::ReleaseWindow;
105 p_intf->pf_control_window = ::ControlWindow;
107 p_intf->p_sys->p_video_window = this;
109 GetClientRect( p_parent, &rect );
111 wc.style = CS_HREDRAW | CS_VREDRAW ;
112 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
116 wc.hInstance = GetModuleHandle(0);
118 wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
119 wc.lpszMenuName = NULL;
120 wc.lpszClassName = _T("VIDEOWINDOW");
121 RegisterClass( &wc );
123 p_child_window = CreateWindow (
124 _T("VIDEOWINDOW"), _T(""),
125 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_BORDER,
126 0, 20, rect.right - rect.left,
127 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT - 20,
128 p_parent, NULL, GetModuleHandle(0), (void *)this );
130 ShowWindow( p_child_window, SW_SHOW );
131 UpdateWindow( p_child_window );
133 ReleaseWindow( (void*)p_child_window );
136 VideoWindow::~VideoWindow()
138 vlc_mutex_destroy( &lock );
141 /*****************************************************************************
143 *****************************************************************************/
144 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
145 int *pi_x_hint, int *pi_y_hint,
146 unsigned int *pi_width_hint,
147 unsigned int *pi_height_hint )
149 return p_intf->p_sys->p_video_window->GetWindow( p_vout, pi_x_hint,
150 pi_y_hint, pi_width_hint, pi_height_hint );
153 void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
154 int *pi_x_hint, int *pi_y_hint,
155 unsigned int *pi_width_hint,
156 unsigned int *pi_height_hint )
158 vlc_mutex_lock( &lock );
162 vlc_mutex_unlock( &lock );
163 msg_Dbg( p_intf, "Video window already in use" );
169 vlc_mutex_unlock( &lock );
171 ShowWindow( (HWND)p_child_window, SW_SHOW );
172 return p_child_window;
175 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
177 p_intf->p_sys->p_video_window->ReleaseWindow( p_window );
180 void VideoWindow::ReleaseWindow( void *p_window )
182 vlc_mutex_lock( &lock );
184 vlc_mutex_unlock( &lock );
186 ShowWindow( (HWND)p_window, SW_HIDE );
187 SetForegroundWindow( p_parent );
190 /***********************************************************************
196 Processes messages sent to the main window.
198 ***********************************************************************/
199 LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
205 vout_Control( p_vout, VOUT_SET_FOCUS, (bool)false );
210 vout_Control( p_vout, VOUT_SET_FOCUS, (bool)true );
214 return DefWindowProc( hwnd, msg, wp, lp );
219 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
220 int i_query, va_list args )
222 return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
226 int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
228 int i_ret = VLC_EGENERIC;
230 vlc_mutex_lock( &lock );
234 case VOUT_SET_STAY_ON_TOP:
238 msg_Dbg( p_intf, "control query not supported" );
242 vlc_mutex_unlock( &lock );