]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwindows/*: implemented VOUT_SET_STAY_ON_TOP in ControlWindow()
authorGildas Bazin <gbazin@videolan.org>
Thu, 8 Apr 2004 15:40:32 +0000 (15:40 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 8 Apr 2004 15:40:32 +0000 (15:40 +0000)
* 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.

include/video_output.h
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/menus.cpp
modules/gui/wxwindows/video.cpp
modules/video_output/directx/directx.c
modules/video_output/directx/events.c
modules/video_output/x11/xcommon.c
src/video_output/vout_intf.c

index 70cd8369f85bcee25bc5febdcffd932269bc5e55..add6be1077f7120496e93360c5b0461f334ca8a7 100644 (file)
@@ -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
 };
index b7299bb004e88f504c1a589252e2426678b69a57..4e24699c76153d60bb2e44705a3e180f9806db67 100644 (file)
@@ -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;
+    }
 }
 
 /*****************************************************************************
index 4e4f62b27cfd7ec5504291bfabe1622409aabf12..a4a840d9ee5c36f58382e69574cef539f17c4563 100644 (file)
@@ -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,
index 99c255142a65a74de8d09353b839ee7d962a99bf..acad16cfd9c6da34a9030f3b49159cdb5cae5420 100644 (file)
@@ -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;
index e37f2a1fc19acff060949ec3fe558c7e7b95a269..1cc32c4210decc316ec45552f8de57fc4c5dc22a 100644 (file)
@@ -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
  *****************************************************************************/
index 6d5387f55f10c35c63dfed3c2828ba3ac55e931f..cea3fbac7f1ad8856be92f370faf9af9b3318df2 100644 (file)
@@ -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;
index e58330c10dbc63688f4d3502f1dd66ab2e628428..a110a0fecff165756a0f5880fa78089d3fde91ca 100644 (file)
@@ -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,
index dd4676aaeccd9563a8325117e932f5fd4c599cec..2e290dbac3c86493e6204f12ab24a0a9203ff0ae 100644 (file)
@@ -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;
+}