Commit 3570e616 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/*: implemented VOUT_SET_STAY_ON_TOP in ControlWindow()

* modules/video_output/directx and x11: implemented VOUT_SET_STAY_ON_TOP in Control()
* src/video_output/vout_intf.c: moved the video-on-top variable there.
parent 3a8f5790
......@@ -242,7 +242,8 @@ static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... )
enum output_query_e
{
VOUT_SET_ZOOM, /* arg1= double * res= */
VOUT_SET_ZOOM, /* arg1= double res= */
VOUT_SET_STAY_ON_TOP, /* arg1= vlc_bool_t res= */
VOUT_REPARENT,
VOUT_CLOSE
};
......
......@@ -201,7 +201,8 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
/* Custom events */
EVT_COMMAND(0, wxEVT_INTF, Interface::UpdateSizeEvent)
EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
END_EVENT_TABLE()
......@@ -290,10 +291,22 @@ Interface::~Interface()
delete timer;
}
void Interface::UpdateSizeEvent( wxCommandEvent& event )
void Interface::OnControlEvent( wxCommandEvent& event )
{
frame_sizer->Layout();
frame_sizer->Fit(this);
switch( event.GetId() )
{
case 0:
frame_sizer->Layout();
frame_sizer->Fit(this);
break;
case 1:
long i_style = GetWindowStyle();
if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;
else i_style &= ~wxSTAY_ON_TOP;
SetWindowStyle( i_style );
break;
}
}
/*****************************************************************************
......
......@@ -342,11 +342,7 @@ wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "crop";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "directx-on-top";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "xvideo-on-top";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "x11-on-top";
ppsz_varnames[i] = "video-on-top";
pi_objects[i++] = p_object->i_object_id;
p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
......
......@@ -45,7 +45,8 @@ static int ControlWindow( intf_thread_t *p_intf, void *p_window,
enum
{
UpdateSize_Event = wxID_HIGHEST + 1,
UpdateHide_Event
UpdateHide_Event,
SetStayOnTop_Event,
};
class VideoWindow: public wxWindow
......@@ -70,13 +71,18 @@ private:
void UpdateSize( wxSizeEvent & );
void UpdateHide( wxSizeEvent & );
void OnControlEvent( wxCommandEvent & );
DECLARE_EVENT_TABLE();
};
DEFINE_LOCAL_EVENT_TYPE( wxEVT_VLC_VIDEO );
BEGIN_EVENT_TABLE(VideoWindow, wxWindow)
EVT_CUSTOM( wxEVT_SIZE, UpdateSize_Event, VideoWindow::UpdateSize )
EVT_CUSTOM( wxEVT_SIZE, UpdateHide_Event, VideoWindow::UpdateHide )
EVT_COMMAND( SetStayOnTop_Event, wxEVT_VLC_VIDEO,
VideoWindow::OnControlEvent )
END_EVENT_TABLE()
/*****************************************************************************
......@@ -242,6 +248,18 @@ void VideoWindow::UpdateHide( wxSizeEvent &event )
p_parent->AddPendingEvent( intf_event );
}
void VideoWindow::OnControlEvent( wxCommandEvent &event )
{
switch( event.GetId() )
{
case SetStayOnTop_Event:
wxCommandEvent intf_event( wxEVT_INTF, 1 );
intf_event.SetInt( event.GetInt() );
p_parent->AddPendingEvent( intf_event );
break;
}
}
static int ControlWindow( intf_thread_t *p_intf, void *p_window,
int i_query, va_list args )
{
......@@ -271,6 +289,17 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
}
break;
case VOUT_SET_STAY_ON_TOP:
{
int i_arg = va_arg( args, int );
wxCommandEvent event( wxEVT_VLC_VIDEO, SetStayOnTop_Event );
event.SetInt( i_arg );
AddPendingEvent( event );
i_ret = VLC_SUCCESS;
}
break;
default:
msg_Dbg( p_intf, "control query not supported" );
break;
......
......@@ -94,8 +94,6 @@ static int DirectXUnlockSurface ( vout_thread_t *p_vout, picture_t *p_pic );
static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color );
/* Object variables callbacks */
static int OnTopCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int FindDevicesCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
......@@ -262,12 +260,8 @@ static int OpenVideo( vlc_object_t *p_this )
}
/* Add a variable to indicate if the window should be on top of others */
var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
text.psz_string = _("Always on top");
var_Change( p_vout, "video-on-top", VLC_VAR_SETTEXT, &text, NULL );
var_Get( p_vout, "video-on-top", &val );
p_vout->p_sys->b_on_top_change = val.b_bool;
var_AddCallback( p_vout, "video-on-top", OnTopCallback, NULL );
return VLC_SUCCESS;
......@@ -409,8 +403,6 @@ static void CloseVideo( vlc_object_t *p_this )
msg_Dbg( p_vout, "CloseVideo" );
var_Destroy( p_vout, "video-on-top" );
if( p_vout->p_sys->p_event )
{
vlc_object_detach( p_vout->p_sys->p_event );
......@@ -1785,18 +1777,6 @@ static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color )
return i_rgb;
}
/*****************************************************************************
* object variables callbacks: a bunch of object variables are used by the
* interfaces to interact with the vout.
*****************************************************************************/
static int OnTopCallback( 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;
p_vout->p_sys->b_on_top_change = VLC_TRUE;
return VLC_SUCCESS;
}
/*****************************************************************************
* config variable callback
*****************************************************************************/
......
......@@ -948,6 +948,14 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
case VOUT_CLOSE:
return VLC_SUCCESS;
case VOUT_SET_STAY_ON_TOP:
if( p_vout->p_sys->hparent )
return vout_ControlWindow( p_vout,
(void *)p_vout->p_sys->hparent, i_query, args );
p_vout->p_sys->b_on_top_change = VLC_TRUE;
return VLC_SUCCESS;
default:
msg_Dbg( p_vout, "control query not supported" );
return VLC_EGENERIC;
......
......@@ -122,9 +122,7 @@ static void SetPalette ( vout_thread_t *,
static void TestNetWMSupport( vout_thread_t * );
static int ConvertKey( int );
/* Object variables callbacks */
static int OnTopCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int WindowOnTop( vout_thread_t *, vlc_bool_t );
/*****************************************************************************
* Activate: allocate X11 video thread output method
......@@ -283,11 +281,7 @@ int E_(Activate) ( vlc_object_t *p_this )
TestNetWMSupport( p_vout );
/* Add a variable to indicate if the window should be on top of others */
var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
text.psz_string = _("Always on top");
var_Change( p_vout, "video-on-top", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "video-on-top", OnTopCallback, NULL );
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_Get( p_vout, "video-on-top", &val );
var_Set( p_vout, "video-on-top", val );
......@@ -2122,6 +2116,7 @@ static void SetPalette( vout_thread_t *p_vout,
static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{
double f_arg;
vlc_bool_t b_arg;
switch( i_query )
{
......@@ -2149,6 +2144,15 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
p_vout->p_sys->p_win->owner_window = 0;
return VLC_SUCCESS;
case VOUT_SET_STAY_ON_TOP:
if( p_vout->p_sys->p_win->owner_window )
return vout_ControlWindow( p_vout,
(void *)p_vout->p_sys->p_win->owner_window, i_query, args);
b_arg = va_arg( args, vlc_bool_t );
WindowOnTop( p_vout, b_arg );
return VLC_SUCCESS;
default:
msg_Dbg( p_vout, "control query not supported" );
return VLC_EGENERIC;
......@@ -2275,14 +2279,10 @@ static int ConvertKey( int i_key )
}
/*****************************************************************************
* object variables callbacks: a bunch of object variables are used by the
* interfaces to interact with the vout.
* WindowOnTop: Switches the "always on top" state of the video window.
*****************************************************************************/
static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int WindowOnTop( vout_thread_t *p_vout, vlc_bool_t b_on_top )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
if( p_vout->p_sys->b_net_wm_state_stays_on_top )
{
XClientMessageEvent event;
......@@ -2294,7 +2294,7 @@ static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
event.display = p_vout->p_sys->p_display;
event.window = p_vout->p_sys->p_win->base_window;
event.format = 32;
event.data.l[ 0 ] = newval.b_bool; /* set property */
event.data.l[ 0 ] = b_on_top; /* set property */
event.data.l[ 1 ] = p_vout->p_sys->net_wm_state_stays_on_top;
XSendEvent( p_vout->p_sys->p_display,
......
......@@ -39,6 +39,8 @@
/* Object variables callbacks */
static int ZoomCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int OnTopCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* vout_RequestWindow: Create/Get a video window if possible.
......@@ -169,6 +171,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Set( p_vout, "zoom", old_val );
var_AddCallback( p_vout, "zoom", ZoomCallback, NULL );
/* Add a variable to indicate if the window should be on top of others */
var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
text.psz_string = _("Always on top");
var_Change( p_vout, "video-on-top", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "video-on-top", OnTopCallback, NULL );
}
/*****************************************************************************
......@@ -181,3 +189,11 @@ static int ZoomCallback( vlc_object_t *p_this, char const *psz_cmd,
vout_Control( p_vout, VOUT_SET_ZOOM, newval.f_float );
return VLC_SUCCESS;
}
static int OnTopCallback( 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;
vout_Control( p_vout, VOUT_SET_STAY_ON_TOP, newval.b_bool );
return VLC_SUCCESS;
}
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