1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: x11_run.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $
7 * Authors: Cyril Deguet <asmax@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
23 *****************************************************************************/
27 //--- X11 -------------------------------------------------------------------
30 //--- WWWINDOWS -------------------------------------------------------------
33 //--- VLC -------------------------------------------------------------------
36 //--- SKIN ------------------------------------------------------------------
37 #include "../os_api.h"
38 #include "../src/event.h"
39 #include "../os_event.h"
40 #include "../src/banks.h"
41 #include "../src/window.h"
42 #include "../os_window.h"
43 #include "../src/theme.h"
44 #include "../os_theme.h"
45 #include "../src/skin_common.h"
46 #include "../src/vlcproc.h"
47 #include "../src/wxdialogs.h"
49 // include the icon graphic
50 #include "share/vlc32x32.xpm"
52 //---------------------------------------------------------------------------
59 //---------------------------------------------------------------------------
61 //---------------------------------------------------------------------------
62 bool IsVLCEvent( unsigned int msg );
63 int SkinManage( intf_thread_t *p_intf );
66 //---------------------------------------------------------------------------
67 // Local classes declarations.
68 //---------------------------------------------------------------------------
69 class Instance: public wxApp
73 Instance( intf_thread_t *_p_intf, CallBackObjects *callback );
79 intf_thread_t *p_intf;
80 CallBackObjects *callbackobj;
84 //---------------------------------------------------------------------------
86 //---------------------------------------------------------------------------
87 /*void GTK2Proc( GdkEvent *event, gpointer data )
89 // Get objects from data
90 CallBackObjects *obj = (CallBackObjects *)data;
91 VlcProc *proc = obj->Proc;
93 // Get pointer to thread info
94 intf_thread_t *p_intf = proc->GetpIntf();
99 list<SkinWindow *>::const_iterator win;
100 GdkWindow *gwnd = ((GdkEventAny *)event)->window;
102 // Create event to dispatch in windows
104 if( event->type == GDK_CLIENT_EVENT )
106 msg = ( (GdkEventClient *)event )->data.l[0];
107 evt = (Event *)new OSEvent( p_intf,
108 ((GdkEventAny *)event)->window,
110 ( (GdkEventClient *)event )->data.l[1],
111 ( (GdkEventClient *)event )->data.l[2] );
117 evt = (Event *)new OSEvent( p_intf,
118 ((GdkEventAny *)event)->window, msg, 0, (long)event );
121 // Process keyboard shortcuts
122 if( msg == GDK_KEY_PRESS )
126 if( ((GdkEventKey *)event)->state & GDK_MOD1_MASK )
131 else if( ((GdkEventKey *)event)->state & GDK_CONTROL_MASK )
135 int key = ((GdkEventKey *)event)->keyval;
136 // Translate into lower case
137 if( key >= 'a' && key <= 'z' )
141 if( KeyModifier > 0 )
142 p_intf->p_sys->p_theme->EvtBank->TestShortcut( key , KeyModifier );
146 else if( IsVLCEvent( msg ) )
148 if( !proc->EventProc( evt ) )
151 return; // Exit VLC !
154 else if( gwnd == NULL )
156 for( win = p_intf->p_sys->p_theme->WindowList.begin();
157 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
159 (*win)->ProcessEvent( evt );
164 // Find window matching with gwnd
165 for( win = p_intf->p_sys->p_theme->WindowList.begin();
166 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
168 // If it is the correct window
169 if( gwnd == ( (GTK2Window *)(*win) )->GetHandle() )
171 // Send event and check if processed
172 if( (*win)->ProcessEvent( evt ) )
174 delete (OSEvent *)evt;
185 evt->DestructParameters();
186 delete (OSEvent *)evt;
188 // Check if vlc is closing
191 gtk_main_do_event( event )
193 //---------------------------------------------------------------------------
195 //---------------------------------------------------------------------------
196 // REFRESH TIMER CALLBACK
197 //---------------------------------------------------------------------------
198 /*gboolean RefreshTimer( gpointer data )
200 intf_thread_t *p_intf = (intf_thread_t *)data;
201 SkinManage( p_intf );
204 //---------------------------------------------------------------------------
207 //---------------------------------------------------------------------------
208 // Implementation of Instance class
209 //---------------------------------------------------------------------------
210 Instance::Instance( )
214 Instance::Instance( intf_thread_t *_p_intf, CallBackObjects *callback )
218 callbackobj = callback;
221 IMPLEMENT_APP_NO_MAIN(Instance)
223 bool Instance::OnInit()
225 // Set event callback. Yes, it's a big hack ;)
226 // gdk_event_handler_set( GTK2Proc, (gpointer)callbackobj, NULL );
228 p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
229 p_intf->p_sys->OpenDlg = new OpenDialog( p_intf, NULL, FILE_ACCESS );
230 p_intf->p_sys->MessagesDlg = new Messages( p_intf, NULL );
231 p_intf->p_sys->SoutDlg = new SoutDialog( p_intf, NULL );
232 p_intf->p_sys->PrefsDlg = new PrefsDialog( p_intf, NULL );
233 p_intf->p_sys->InfoDlg = new FileInfo( p_intf, NULL );
236 // g_timeout_add( 200, (GSourceFunc)RefreshTimer, (gpointer)p_intf );
243 //---------------------------------------------------------------------------
245 //---------------------------------------------------------------------------
246 void OSRun( intf_thread_t *p_intf )
248 static char *p_args[] = { "" };
250 // Create VLC event object processing
251 CallBackObjects *callbackobj = new CallBackObjects();
252 callbackobj->Proc = new VlcProc( p_intf );
254 /* wxTheApp = new Instance( p_intf, callbackobj );
256 wxEntry( 1, p_args );*/
258 Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay();
264 XNextEvent( display, event );
265 fprintf(stderr,"event %d\n", event->type);
270 //---------------------------------------------------------------------------
271 bool IsVLCEvent( unsigned int msg )
273 return( msg > VLC_MESSAGE && msg < VLC_WINDOW );
275 //---------------------------------------------------------------------------