/*****************************************************************************
* events.c: Windows DirectX video output events handler
*****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Preamble: This file contains the functions related to the creation of
* a window and the handling of its messages (events).
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <errno.h> /* ENOMEM */
#include <ctype.h> /* tolower() */
# define _WIN32_WINNT 0x0500
#endif
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_vout.h>
+#include <vlc_vout_window.h>
#include <windows.h>
+#include <tchar.h>
#include <windowsx.h>
#include <shellapi.h>
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
#include <ddraw.h>
#endif
#ifdef MODULE_NAME_IS_direct3d
#include <GL/gl.h>
#endif
-#include "vlc_keys.h"
+#include <vlc_keys.h>
#include "vout.h"
-#if defined(UNDER_CE) && !defined(__PLUGIN__) /*FIXME*/
-# define SHFS_SHOWSIPBUTTON 0x0004
+#ifndef UNDER_CE
+#include <vlc_windows_interfaces.h>
+#endif
+
+#ifdef UNDER_CE
+#include <aygshell.h>
+ //WINSHELLAPI BOOL WINAPI SHFullScreen(HWND hwndRequester, DWORD dwState);
+#endif
+
+/*#if defined(UNDER_CE) && !defined(__PLUGIN__) --FIXME*/
+/*# define SHFS_SHOWSIPBUTTON 0x0004
# define SHFS_HIDESIPBUTTON 0x0008
# define MENU_HEIGHT 26
BOOL SHFullScreen(HWND hwndRequester, DWORD dwState);
-#endif
+#endif*/
+
/*****************************************************************************
* Local prototypes.
static long FAR PASCAL DirectXEventProc( HWND, UINT, WPARAM, LPARAM );
static int Control( vout_thread_t *p_vout, int i_query, va_list args );
+static int vaControlParentWindow( vout_thread_t *, int, va_list );
static void DirectXPopupMenu( event_thread_t *p_event, bool b_open )
{
- playlist_t *p_playlist =
- vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- if( p_playlist != NULL )
- {
- vlc_value_t val;
- val.b_bool = b_open;
- var_Set( p_playlist, "intf-popupmenu", val );
- vlc_object_release( p_playlist );
- }
+ vlc_value_t val;
+ val.b_bool = b_open;
+ var_Set( p_event->p_libvlc, "intf-popupmenu", val );
}
static int DirectXConvertKey( int i_key );
* The main goal of this thread is to isolate the Win32 PeekMessage function
* because this one can block for a long time.
*****************************************************************************/
-void EventThread( event_thread_t *p_event )
+void* EventThread( vlc_object_t *p_this )
{
+ event_thread_t *p_event = (event_thread_t *)p_this;
MSG msg;
POINT old_mouse_pos = {0,0}, mouse_pos;
vlc_value_t val;
- int i_width, i_height, i_x, i_y;
+ unsigned int i_width, i_height, i_x, i_y;
HMODULE hkernel32;
+ int canc = vlc_savecancel ();
/* Initialisation */
p_event->p_vout->pf_control = Control;
* message queue */
if( DirectXCreateWindow( p_event->p_vout ) )
{
- msg_Err( p_event, "out of memory" );
- p_event->b_dead = true;
+ vlc_restorecancel (canc);
+ return NULL;
}
/* Signal the creation of the window */
- vlc_thread_ready( p_event );
+ SetEvent( p_event->window_ready );
#ifndef UNDER_CE
/* Set power management stuff */
/* Main loop */
/* GetMessage will sleep if there's no message in the queue */
- while( !p_event->b_die && GetMessage( &msg, 0, 0, 0 ) )
+ while( vlc_object_alive (p_event) && GetMessage( &msg, 0, 0, 0 ) )
{
/* Check if we are asked to exit */
- if( p_event->b_die )
+ if( !vlc_object_alive (p_event) )
break;
switch( msg.message )
p_event->p_vout->fmt_in.i_y_offset;
var_Set( p_event->p_vout, "mouse-y", val );
- val.b_bool = true;
- var_Set( p_event->p_vout, "mouse-moved", val );
+ var_SetBool( p_event->p_vout, "mouse-moved", true );
}
case WM_NCMOUSEMOVE:
val.i_int &= ~1;
var_Set( p_event->p_vout, "mouse-button-down", val );
- val.b_bool = true;
- var_Set( p_event->p_vout, "mouse-clicked", val );
+ var_SetBool( p_event->p_vout, "mouse-clicked", true );
break;
case WM_LBUTTONDBLCLK:
#ifdef MODULE_NAME_IS_direct3d
val.psz_string = strdup( VOUT_TITLE " (Direct3D output)" );
#endif
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
if( p_event->p_vout->p_sys->b_using_overlay ) val.psz_string =
strdup( VOUT_TITLE " (hardware YUV overlay DirectX output)" );
else if( p_event->p_vout->p_sys->b_hw_yuv ) val.psz_string =
#endif
}
-#ifdef UNICODE
{
wchar_t *psz_title = malloc( strlen(val.psz_string) * 2 + 2 );
- mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
- psz_title[strlen(val.psz_string)] = 0;
- free( val.psz_string ); val.psz_string = (char *)psz_title;
+ if( psz_title )
+ {
+ mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
+ psz_title[strlen(val.psz_string)] = 0;
+ free( val.psz_string ); val.psz_string = (char *)psz_title;
+ }
}
-#endif
SetWindowText( p_event->p_vout->p_sys->hwnd,
(LPCTSTR)val.psz_string );
msg_Dbg( p_event, "DirectXEventThread terminating" );
- /* clear the changes formerly signaled */
- p_event->p_vout->p_sys->i_changes = 0;
-
DirectXCloseWindow( p_event->p_vout );
+ vlc_restorecancel (canc);
+
+ /* clear the changes formerly signaled */
+ p_event->p_vout->p_sys->i_changes = EVENT_THREAD_ENDED;
+ return NULL;
}
/* Get this module's instance */
hInstance = GetModuleHandle(NULL);
- /* If an external window was specified, we'll draw in it. */
- p_vout->p_sys->hparent =
- vout_RequestWindow( p_vout, &p_vout->p_sys->i_window_x,
- &p_vout->p_sys->i_window_y,
- &p_vout->p_sys->i_window_width,
- &p_vout->p_sys->i_window_height );
+ #ifdef MODULE_NAME_IS_direct3d
+ if( !p_vout->p_sys->b_desktop )
+ {
+ #endif
+ vout_window_cfg_t wnd_cfg;
+ memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
+ wnd_cfg.type = VOUT_WINDOW_TYPE_HWND;
+ wnd_cfg.x = p_vout->p_sys->i_window_x;
+ wnd_cfg.y = p_vout->p_sys->i_window_y;
+ wnd_cfg.width = p_vout->p_sys->i_window_width;
+ wnd_cfg.height = p_vout->p_sys->i_window_height;
+
+ /* If an external window was specified, we'll draw in it. */
+ p_vout->p_sys->parent_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &wnd_cfg );
+ if( p_vout->p_sys->parent_window )
+ p_vout->p_sys->hparent = p_vout->p_sys->parent_window->handle.hwnd;
+ #ifdef MODULE_NAME_IS_direct3d
+ }
+ else
+ {
+ /* Find Program Manager */
+ HWND hwnd = FindWindow( _T("Progman"), NULL );
+ if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, _T("SHELLDLL_DefView"), NULL );
+ if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, _T("SysListView32"), NULL );
+ if( !hwnd )
+ msg_Err( p_vout, "Couldn't find desktop icon window. Desktop mode can't be established." );
+ p_vout->p_sys->hparent = hwnd;
+ }
+ #endif
/* We create the window ourself, there is no previous window proc. */
p_vout->p_sys->pf_wndproc = NULL;
DestroyWindow( p_vout->p_sys->hwnd );
if( p_vout->p_sys->hfswnd ) DestroyWindow( p_vout->p_sys->hfswnd );
- if( p_vout->p_sys->hparent )
- vout_ReleaseWindow( p_vout, (void *)p_vout->p_sys->hparent );
-
+ #ifdef MODULE_NAME_IS_direct3d
+ if( !p_vout->p_sys->b_desktop )
+ #endif
+ vout_window_Delete( p_vout->p_sys->parent_window );
p_vout->p_sys->hwnd = NULL;
/* We don't unregister the Window Class because it could lead to race
#define rect_dest p_vout->p_sys->rect_dest
#define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
- int i_width, i_height, i_x, i_y;
+ unsigned int i_width, i_height, i_x, i_y;
RECT rect;
POINT point;
rect_dest.top = point.y + i_y;
rect_dest.bottom = rect_dest.top + i_height;
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
/* Apply overlay hardware constraints */
if( p_vout->p_sys->b_using_overlay )
{
return;
}
-#if 0
+#ifndef NDEBUG
msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
- " %i,%i,%i,%i",
+ " %li,%li,%li,%li",
rect_dest_clipped.left, rect_dest_clipped.top,
rect_dest_clipped.right, rect_dest_clipped.bottom );
#endif
-#else /* MODULE_NAME_IS_vout_directx */
+#else /* MODULE_NAME_IS_directx */
/* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
rect_dest_clipped = rect_dest;
(rect_dest.bottom - rect_dest_clipped.bottom) *
p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
/* Apply overlay hardware constraints */
if( p_vout->p_sys->b_using_overlay )
{
}
#endif
-#if 0
+#ifndef NDEBUG
msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
- " coords: %i,%i,%i,%i",
+ " coords: %li,%li,%li,%li",
rect_src_clipped.left, rect_src_clipped.top,
rect_src_clipped.right, rect_src_clipped.bottom );
#endif
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
/* The destination coordinates need to be relative to the current
* directdraw primary surface (display) */
rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
DirectDrawUpdateOverlay( p_vout );
#endif
+#ifndef UNDER_CE
+ /* Windows 7 taskbar thumbnail code */
+ LPTASKBARLIST3 p_taskbl;
+ OSVERSIONINFO winVer;
+ winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
+ {
+ CoInitialize( 0 );
+
+ if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+ NULL, CLSCTX_INPROC_SERVER,
+ &IID_ITaskbarList3,
+ &p_taskbl) )
+ {
+ RECT rect_video, rect_parent, rect_relative;
+ HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
+
+ p_taskbl->vt->HrInit(p_taskbl);
+ GetWindowRect(p_vout->p_sys->hvideownd, &rect_video);
+ GetWindowRect(hroot, &rect_parent);
+ rect_relative.left = rect_video.left - rect_parent.left - 8;
+ rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
+ rect_relative.top = rect_video.top - rect_parent.top - 10;
+ rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
+
+ if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
+ msg_Err( p_vout, "SetThumbNailClip failed");
+
+ p_taskbl->vt->Release(p_taskbl);
+ }
+ CoUninitialize();
+ }
+#endif
/* Signal the change in size/position */
p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
}
else
{
- p_vout = (vout_thread_t *)GetWindowLongPtr( hwnd, GWLP_USERDATA );
+ LONG_PTR p_user_data = GetWindowLongPtr( hwnd, GWLP_USERDATA );
+ p_vout = (vout_thread_t *)p_user_data;
if( !p_vout )
{
/* Hmmm mozilla does manage somehow to save the pointer to our
{
switch( message )
{
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
case WM_ERASEBKGND:
/* For overlay, we need to erase background */
return !p_vout->p_sys->b_using_overlay ?
/* the user wants to close the window */
case WM_CLOSE:
{
- playlist_t * p_playlist =
- (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
+ playlist_t * p_playlist = pl_Hold( p_vout );
+ if( p_playlist )
{
- return 0;
+ playlist_Stop( p_playlist );
+ pl_Release( p_vout );
}
-
- playlist_Stop( p_playlist );
- vlc_object_release( p_playlist );
return 0;
}
if( !p_vout->p_sys->b_parent_focus ) GXSuspend();
#endif
#ifdef UNDER_CE
- if( hWnd == p_vout->p_sys->hfswnd )
+ if( hwnd == p_vout->p_sys->hfswnd )
{
HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
ShowWindow( htbar, SW_SHOW );
}
if( !p_vout->p_sys->hparent ||
- hWnd == p_vout->p_sys->hfswnd )
+ hwnd == p_vout->p_sys->hfswnd )
{
- SHFullScreen( hWnd, SHFS_SHOWSIPBUTTON );
+ SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
}
#endif
return 0;
#endif
#ifdef UNDER_CE
if( p_vout->p_sys->hparent &&
- hWnd != p_vout->p_sys->hfswnd && p_vout->b_fullscreen )
+ hwnd != p_vout->p_sys->hfswnd && p_vout->b_fullscreen )
p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE;
- if( hWnd == p_vout->p_sys->hfswnd )
+ if( hwnd == p_vout->p_sys->hfswnd )
{
HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
ShowWindow( htbar, SW_HIDE );
}
if( !p_vout->p_sys->hparent ||
- hWnd == p_vout->p_sys->hfswnd )
+ hwnd == p_vout->p_sys->hfswnd )
{
- SHFullScreen( hWnd, SHFS_HIDESIPBUTTON );
+ SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
}
#endif
return 0;
*****************************************************************************/
static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{
- unsigned int *pi_width, *pi_height;
RECT rect_window;
- POINT point;
switch( i_query )
{
- case VOUT_GET_SIZE:
- if( p_vout->p_sys->hparent )
- return vout_ControlWindow( p_vout,
- (void *)p_vout->p_sys->hparent, i_query, args );
-
- pi_width = va_arg( args, unsigned int * );
- pi_height = va_arg( args, unsigned int * );
-
- GetClientRect( p_vout->p_sys->hwnd, &rect_window );
-
- *pi_width = rect_window.right - rect_window.left;
- *pi_height = rect_window.bottom - rect_window.top;
- return VLC_SUCCESS;
-
case VOUT_SET_SIZE:
- if( p_vout->p_sys->hparent )
- return vout_ControlWindow( p_vout,
- (void *)p_vout->p_sys->hparent, i_query, args );
+ if( p_vout->p_sys->parent_window )
+ return vaControlParentWindow( p_vout, i_query, args );
/* Update dimensions */
rect_window.top = rect_window.left = 0;
return VLC_SUCCESS;
- case VOUT_CLOSE:
- ShowWindow( p_vout->p_sys->hwnd, SW_HIDE );
- case VOUT_REPARENT:
- /* Retrieve the window position */
- point.x = point.y = 0;
- ClientToScreen( p_vout->p_sys->hwnd, &point );
-
- HWND d = 0;
-
- if( i_query == VOUT_REPARENT ) d = (HWND)va_arg( args, int );
- if( !d )
- {
- vlc_mutex_lock( &p_vout->p_sys->lock );
- p_vout->p_sys->hparent = 0;
- vlc_mutex_unlock( &p_vout->p_sys->lock );
- SetParent( p_vout->p_sys->hwnd, 0 );
- p_vout->p_sys->i_window_style =
- WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
- SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
- p_vout->p_sys->i_window_style |
- (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
- SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
- SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
- SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
- }
- else
- {
- vlc_mutex_lock( &p_vout->p_sys->lock );
- p_vout->p_sys->hparent = d;
- vlc_mutex_unlock( &p_vout->p_sys->lock );
-
- SetParent( p_vout->p_sys->hwnd, d );
- p_vout->p_sys->i_window_style = WS_CLIPCHILDREN;
- SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
- p_vout->p_sys->i_window_style |
- (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
- SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
-
- /* Retrieve the parent size */
- RECT rect;
- GetClientRect( d, &rect );
- SetWindowPos( p_vout->p_sys->hwnd, d, point.x, point.y, rect.right, rect.bottom,
- SWP_FRAMECHANGED );
- }
-
- return vout_vaControlDefault( p_vout, i_query, args );
-
case VOUT_SET_STAY_ON_TOP:
if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
- return vout_ControlWindow( p_vout,
- (void *)p_vout->p_sys->hparent, i_query, args );
+ return vaControlParentWindow( p_vout, i_query, args );
p_vout->p_sys->b_on_top_change = true;
return VLC_SUCCESS;
-#ifdef MODULE_NAME_IS_wingapi
- case VOUT_SET_FOCUS:
- b_bool = (bool) va_arg( args, int );
- p_vout->p_sys->b_parent_focus = b_bool;
- if( b_bool ) GXResume();
- else if( !p_vout->p_sys->b_focus ) GXSuspend();
- return VLC_SUCCESS;
-#endif
-
default:
- return vout_vaControlDefault( p_vout, i_query, args );
+ return VLC_EGENERIC;
}
}
-/* Internal wrapper over GetWindowPlacement / SetWindowPlacement */
-static void SetWindowState(HWND hwnd, int nShowCmd)
+/* Internal wrapper over GetWindowPlacement */
+static WINDOWPLACEMENT getWindowState(HWND hwnd)
{
WINDOWPLACEMENT window_placement;
window_placement.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement( hwnd, &window_placement );
- window_placement.showCmd = nShowCmd;
- SetWindowPlacement( hwnd, &window_placement );
- SetWindowPos( hwnd, 0, 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
+ return window_placement;
}
/* Internal wrapper to call vout_ControlWindow for hparent */
-static void ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
+static int vaControlParentWindow( vout_thread_t *p_vout, int i_query,
+ va_list args )
+{
+ switch( i_query )
+ {
+ case VOUT_SET_SIZE:
+ {
+ const unsigned i_width = va_arg(args, unsigned);
+ const unsigned i_height = va_arg(args, unsigned);
+ return vout_window_SetSize( p_vout->p_sys->parent_window, i_width, i_height );
+ }
+ case VOUT_SET_STAY_ON_TOP:
+ {
+ const bool is_on_top = va_arg(args, int);
+ return vout_window_SetOnTop( p_vout->p_sys->parent_window, is_on_top );
+ }
+ default:
+ return VLC_EGENERIC;
+ }
+}
+
+#if 0
+static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
{
va_list args;
+ int ret;
+
va_start( args, i_query );
- vout_ControlWindow( p_vout,
- (void *)p_vout->p_sys->hparent, i_query, args );
+ ret = vaControlParentWindow( p_vout, i_query, args );
va_end( args );
+ return ret;
}
+#endif
void Win32ToggleFullscreen( vout_thread_t *p_vout )
{
HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
+ /* Save the current windows placement/placement to restore
+ when fullscreen is over */
+ WINDOWPLACEMENT window_placement = getWindowState( hwnd );
+
p_vout->b_fullscreen = ! p_vout->b_fullscreen;
+ /* We want to go to Fullscreen */
if( p_vout->b_fullscreen )
{
msg_Dbg( p_vout, "entering fullscreen mode" );
+
/* Change window style, no borders and no title bar */
int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
SetWindowLong( hwnd, GWL_STYLE, i_style );
if( p_vout->p_sys->hparent )
{
- /* Retrieve current window position so fullscreen will happen
- * on the right screen */
+#ifdef UNDER_CE
POINT point = {0,0};
RECT rect;
ClientToScreen( p_vout->p_sys->hwnd, &point );
SetWindowPos( hwnd, 0, point.x, point.y,
rect.right, rect.bottom,
SWP_NOZORDER|SWP_FRAMECHANGED );
+#else
+ /* Retrieve current window position so fullscreen will happen
+ *on the right screen */
+ HMONITOR hmon = MonitorFromWindow(p_vout->p_sys->hparent,
+ MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
+ if (GetMonitorInfo(hmon, &mi))
+ SetWindowPos( hwnd, 0,
+ mi.rcMonitor.left,
+ mi.rcMonitor.top,
+ mi.rcMonitor.right - mi.rcMonitor.left,
+ mi.rcMonitor.bottom - mi.rcMonitor.top,
+ SWP_NOZORDER|SWP_FRAMECHANGED );
+#endif
+ }
+ else
+ {
+ /* Maximize non embedded window */
+ ShowWindow( hwnd, SW_SHOWMAXIMIZED );
}
-
- /* Maximize window */
- SetWindowState( hwnd, SW_SHOWMAXIMIZED );
if( p_vout->p_sys->hparent )
{
+ /* Hide the previous window */
RECT rect;
GetClientRect( hwnd, &rect );
SetParent( p_vout->p_sys->hwnd, hwnd );
rect.right, rect.bottom,
SWP_NOZORDER|SWP_FRAMECHANGED );
+#ifdef UNDER_CE
+ HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
+#else
HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
+#endif
ShowWindow( topLevelParent, SW_HIDE );
}
/* Change window style, no borders and no title bar */
SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
- /* Normal window */
- SetWindowState( hwnd, SW_SHOWNORMAL );
-
if( p_vout->p_sys->hparent )
{
RECT rect;
rect.right, rect.bottom,
SWP_NOZORDER|SWP_FRAMECHANGED );
+#ifdef UNDER_CE
+ HWND topLevelParent = GetParent( p_vout->p_sys->hparent );
+#else
HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
+#endif
ShowWindow( topLevelParent, SW_SHOW );
SetForegroundWindow( p_vout->p_sys->hparent );
ShowWindow( hwnd, SW_HIDE );
}
+ else
+ {
+ /* return to normal window for non embedded vout */
+ SetWindowPlacement( hwnd, &window_placement );
+ ShowWindow( hwnd, SW_SHOWNORMAL );
+ }
/* Make sure the mouse cursor is displayed */
PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
}
- vlc_value_t val;
/* Update the object variable and trigger callback */
- val.b_bool = p_vout->b_fullscreen;
- var_Set( p_vout, "fullscreen", val );
+ var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
+}
+
+#ifndef UNDER_CE
+void DisableScreensaver( vout_thread_t *p_vout )
+{
+ /* disable screensaver by temporarily changing system settings */
+ p_vout->p_sys->i_spi_lowpowertimeout = 0;
+ p_vout->p_sys->i_spi_powerofftimeout = 0;
+ p_vout->p_sys->i_spi_screensavetimeout = 0;
+ if( var_GetBool( p_vout, "disable-screensaver" ) )
+ {
+ msg_Dbg(p_vout, "disabling screen saver");
+ SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
+ 0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
+ if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
+ SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
+ }
+ SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
+ &(p_vout->p_sys->i_spi_powerofftimeout), 0);
+ if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
+ SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
+ }
+ SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
+ &(p_vout->p_sys->i_spi_screensavetimeout), 0);
+ if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
+ SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
+ }
+ }
+}
+
+void RestoreScreensaver( vout_thread_t *p_vout )
+{
+ /* restore screensaver system settings */
+ if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
+ SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
+ p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
+ }
+ if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
+ SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
+ p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
+ }
+ if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
+ SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
+ p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);
+ }
+}
+#endif
+
+int CreateEventThread( vout_thread_t *p_vout )
+{
+ if( !( p_vout->p_sys->i_changes & SWITCHING_MODE_FLAG ) )
+ vlc_mutex_init( &p_vout->p_sys->lock );
+
+ /* Create the Vout EventThread, this thread is created by us to isolate
+ * the Win32 PeekMessage function calls. We want to do this because
+ * Windows can stay blocked inside this call for a long time, and when
+ * this happens it thus blocks vlc's video_output thread.
+ * Vout EventThread will take care of the creation of the video
+ * window (because PeekMessage has to be called from the same thread which
+ * created the window). */
+ msg_Dbg( p_vout, "creating Vout EventThread" );
+ p_vout->p_sys->p_event =
+ vlc_object_create( p_vout, sizeof(event_thread_t) );
+ p_vout->p_sys->p_event->p_vout = p_vout;
+ p_vout->p_sys->p_event->window_ready = CreateEvent( NULL, TRUE, FALSE, NULL );
+ if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
+ EventThread, 0 ) )
+ {
+ msg_Err( p_vout, "cannot create Vout EventThread" );
+ CloseHandle( p_vout->p_sys->p_event->window_ready );
+ vlc_object_release( p_vout->p_sys->p_event );
+ p_vout->p_sys->p_event = NULL;
+ return 0;
+ }
+ WaitForSingleObject( p_vout->p_sys->p_event->window_ready, INFINITE );
+ CloseHandle( p_vout->p_sys->p_event->window_ready );
+
+ if( p_vout->p_sys->p_event->b_error )
+ {
+ msg_Err( p_vout, "Vout EventThread failed" );
+ return 0;
+ }
+
+ vlc_object_attach( p_vout->p_sys->p_event, p_vout );
+
+ msg_Dbg( p_vout, "Vout EventThread running" );
+ return 1;
+}
+
+void StopEventThread( vout_thread_t *p_vout )
+{
+ if( p_vout->b_fullscreen )
+ {
+ msg_Dbg( p_vout, "Quitting fullscreen" );
+ Win32ToggleFullscreen( p_vout );
+ /* Force fullscreen in the core for the next video */
+ var_SetBool( p_vout, "fullscreen", true );
+ }
+
+ if( p_vout->p_sys->p_event )
+ {
+ vlc_object_detach( p_vout->p_sys->p_event );
+
+ /* Kill Vout EventThread */
+ vlc_object_kill( p_vout->p_sys->p_event );
+
+ /* we need to be sure Vout EventThread won't stay stuck in
+ * GetMessage, so we send a fake message */
+ if( p_vout->p_sys->hwnd )
+ {
+ PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0);
+ }
+
+ vlc_thread_join( p_vout->p_sys->p_event );
+ vlc_object_release( p_vout->p_sys->p_event );
+ }
+
+ if( !( p_vout->p_sys->i_changes & SWITCHING_MODE_FLAG ) )
+ vlc_mutex_destroy( &p_vout->p_sys->lock );
}