Commit 4a6468f3 authored by Gildas Bazin's avatar Gildas Bazin

* modules/video_output/directx/*: added a "wallpaper" mode (only when overlay is available).

* modules/gui/wxwindows/menus.cpp: wallpaper entry in the menu.
parent 32bbb393
......@@ -178,6 +178,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "video-on-top";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "directx-wallpaper";
pi_objects[i++] = p_object->i_object_id;
p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
VLC_OBJECT_DECODER,
......@@ -344,6 +346,8 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "video-on-top";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "directx-wallpaper";
pi_objects[i++] = p_object->i_object_id;
p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
VLC_OBJECT_DECODER,
......@@ -858,6 +862,8 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
return;
}
msg_Err( p_intf, "received event: %i", event.GetId() );
/* Check if this is an hotkey event */
if( event.GetId() >= i_hotkey_event &&
event.GetId() < i_hotkey_event + i_hotkeys )
......@@ -869,6 +875,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
/* Get the key combination and send it to the hotkey handler */
var_Set( p_intf->p_vlc, "key-pressed", val );
msg_Err( p_intf, "received key event: %i", event.GetId() );
return;
}
......
......@@ -44,6 +44,7 @@
#include <windows.h>
#include <ddraw.h>
#include <commctrl.h>
#include <multimon.h>
#undef GetSystemMetrics
......@@ -93,9 +94,13 @@ static int DirectXUnlockSurface ( vout_thread_t *p_vout, picture_t *p_pic );
static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color );
void SwitchWallpaperMode( vout_thread_t *, vlc_bool_t );
/* Object variables callbacks */
static int FindDevicesCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int WallpaperCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* Module descriptor
......@@ -123,6 +128,12 @@ static int FindDevicesCallback( vlc_object_t *, char const *,
"window to open on. For example, \"\\\\.\\DISPLAY1\" or " \
"\"\\\\.\\DISPLAY2\"." )
#define WALLPAPER_TEXT N_("Enable wallpaper mode ")
#define WALLPAPER_LONGTEXT N_( \
"The wallpaper mode allows you to display the video as the desktop " \
"background. Note that this feature only works in overlay mode and " \
"the desktop must not already have a wallpaper." )
static char *ppsz_dev[] = { "" };
static char *ppsz_dev_text[] = { N_("Default") };
......@@ -139,6 +150,9 @@ vlc_module_begin();
change_string_list( ppsz_dev, ppsz_dev_text, FindDevicesCallback );
change_action_add( FindDevicesCallback, N_("Refresh list") );
add_bool( "directx-wallpaper", 0, NULL, WALLPAPER_TEXT, WALLPAPER_LONGTEXT,
VLC_TRUE );
set_description( _("DirectX video output") );
set_capability( "video output", 100 );
add_shortcut( "directx" );
......@@ -187,6 +201,7 @@ static int OpenVideo( vlc_object_t *p_this )
p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;
p_vout->p_sys->hparent = NULL;
p_vout->p_sys->i_changes = 0;
p_vout->p_sys->b_wallpaper = 0;
vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
SetRectEmpty( &p_vout->p_sys->rect_display );
SetRectEmpty( &p_vout->p_sys->rect_parent );
......@@ -267,6 +282,15 @@ static int OpenVideo( vlc_object_t *p_this )
var_Get( p_vout, "video-on-top", &val );
var_Set( p_vout, "video-on-top", val );
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_Create( p_vout, "directx-wallpaper", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
val.psz_string = _("Wallpaper");
var_Change( p_vout, "directx-wallpaper", VLC_VAR_SETTEXT, &val, NULL );
var_AddCallback( p_vout, "directx-wallpaper", WallpaperCallback, NULL );
var_Get( p_vout, "directx-wallpaper", &val );
var_Set( p_vout, "directx-wallpaper", val );
return VLC_SUCCESS;
error:
......@@ -426,6 +450,9 @@ static void CloseVideo( vlc_object_t *p_this )
vlc_mutex_destroy( &p_vout->p_sys->lock );
/* Make sure the wallpaper is restored */
SwitchWallpaperMode( p_vout, VLC_FALSE );
if( p_vout->p_sys )
{
free( p_vout->p_sys );
......@@ -501,6 +528,13 @@ static int Manage( vout_thread_t *p_vout )
* long time (for example when you move your window on the screen), I
* decided to isolate PeekMessage in another thread. */
if( p_vout->p_sys->i_changes & DX_WALLPAPER_CHANGE )
{
SwitchWallpaperMode( p_vout, !p_vout->p_sys->b_wallpaper );
p_vout->p_sys->i_changes &= ~DX_WALLPAPER_CHANGE;
DirectXUpdateOverlay( p_vout );
}
/*
* Fullscreen change
*/
......@@ -1155,6 +1189,24 @@ int DirectXUpdateOverlay( vout_thread_t *p_vout )
if( !p_vout->p_sys->b_using_overlay ) return VLC_EGENERIC;
if( p_vout->p_sys->b_wallpaper )
{
int i_x, i_y, i_width, i_height;
rect_src.left = rect_src.top = 0;
rect_src.right = p_vout->render.i_width;
rect_src.bottom = p_vout->render.i_height;
rect_dest = p_vout->p_sys->rect_display;
vout_PlacePicture( p_vout, rect_dest.right, rect_dest.bottom,
&i_x, &i_y, &i_width, &i_height );
rect_dest.left += i_x;
rect_dest.right = rect_dest.left + i_width;
rect_dest.top += i_y;
rect_dest.bottom = rect_dest.top + i_height;
}
vlc_mutex_lock( &p_vout->p_sys->lock );
if( p_vout->p_sys->p_current_surface == NULL )
{
......@@ -1858,6 +1910,48 @@ static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color )
return i_rgb;
}
/*****************************************************************************
* A few toolbox functions
*****************************************************************************/
void SwitchWallpaperMode( vout_thread_t *p_vout, vlc_bool_t b_on )
{
HWND hwnd;
if( p_vout->p_sys->b_wallpaper == b_on ) return; /* Nothing to do */
hwnd = FindWindow( "Progman", NULL );
if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, "SHELLDLL_DefView", NULL );
if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, "SysListView32", NULL );
if( !hwnd )
{
msg_Warn( p_vout, "couldn't find \"SysListView32\" window, "
"wallpaper mode not supported" );
return;
}
p_vout->p_sys->b_wallpaper = b_on;
msg_Dbg( p_vout, "wallpaper mode %s", b_on ? "enabled" : "disabled" );
if( p_vout->p_sys->b_wallpaper )
{
p_vout->p_sys->color_bkg = ListView_GetBkColor( hwnd );
p_vout->p_sys->color_bkgtxt = ListView_GetTextBkColor( hwnd );
ListView_SetBkColor( hwnd, p_vout->p_sys->i_rgb_colorkey );
ListView_SetTextBkColor( hwnd, p_vout->p_sys->i_rgb_colorkey );
}
else if( hwnd )
{
ListView_SetBkColor( hwnd, p_vout->p_sys->color_bkg );
ListView_SetTextBkColor( hwnd, p_vout->p_sys->color_bkgtxt );
}
/* Update desktop */
InvalidateRect( hwnd, NULL, TRUE );
UpdateWindow( hwnd );
}
/*****************************************************************************
* config variable callback
*****************************************************************************/
......@@ -1932,3 +2026,33 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
return VLC_SUCCESS;
}
static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
if( (newval.b_bool && !p_vout->p_sys->b_wallpaper) ||
(!newval.b_bool && p_vout->p_sys->b_wallpaper) )
{
playlist_t *p_playlist;
p_playlist =
(playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_PARENT );
if( p_playlist )
{
/* Modify playlist as well because the vout might have to be
* restarted */
var_Create( p_playlist, "directx-wallpaper", VLC_VAR_BOOL );
var_Set( p_playlist, "directx-wallpaper", newval );
vlc_object_release( p_playlist );
}
p_vout->p_sys->i_changes |= DX_WALLPAPER_CHANGE;
}
return VLC_SUCCESS;
}
......@@ -100,6 +100,10 @@ struct vout_sys_t
/* Misc */
vlc_bool_t b_on_top_change;
vlc_bool_t b_wallpaper;
COLORREF color_bkg;
COLORREF color_bkgtxt;
event_thread_t *p_event;
vlc_mutex_t lock;
};
......@@ -137,3 +141,4 @@ void DirectXUpdateRects ( vout_thread_t *p_vout, vlc_bool_t b_force );
#define WM_VLC_CHANGE_TEXT WM_APP + 3
#define IDM_TOGGLE_ON_TOP WM_USER + 1
#define DX_POSITION_CHANGE 0x1000
#define DX_WALLPAPER_CHANGE 0x2000
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