* x11_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_run.cpp,v 1.2 2003/05/12 17:33:19 gbazin Exp $
+ * $Id: x11_run.cpp,v 1.3 2003/05/13 20:36:29 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
// include the icon graphic
#include "share/vlc32x32.xpm"
-//---------------------------------------------------------------------------
-class CallBackObjects
-{
- public:
- VlcProc *Proc;
-};
//---------------------------------------------------------------------------
// Specific method
{
public:
Instance();
- Instance( intf_thread_t *_p_intf, CallBackObjects *callback );
+ Instance( intf_thread_t *_p_intf );
bool OnInit();
OpenDialog *open;
private:
intf_thread_t *p_intf;
- CallBackObjects *callbackobj;
};
{
}
-Instance::Instance( intf_thread_t *_p_intf, CallBackObjects *callback )
+Instance::Instance( intf_thread_t *_p_intf )
{
// Initialization
p_intf = _p_intf;
- callbackobj = callback;
}
IMPLEMENT_APP_NO_MAIN(Instance)
//---------------------------------------------------------------------------
-// GTK2 interface
+// X11 event processing
+//---------------------------------------------------------------------------
+void ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
+{
+ // Variables
+ list<SkinWindow *>::const_iterator win;
+ unsigned int msg;
+ Event *evt;
+
+ Window wnd = ((XAnyEvent *)event)->window;
+
+ fprintf(stderr,"event %d %x\n", event->type, wnd);
+
+ // Create event to dispatch in windows
+ // Skin event
+ if( event->type == ClientMessage )
+ {
+/* msg = ( (GdkEventClient *)event )->data.l[0];
+ evt = (Event *)new OSEvent( p_intf,
+ ((GdkEventAny *)event)->window,
+ msg,
+ ( (GdkEventClient *)event )->data.l[1],
+ ( (GdkEventClient *)event )->data.l[2] );*/
+ }
+ // System event
+ else
+ {
+ msg = event->type;
+ evt = (Event *)new OSEvent( p_intf,
+ ((XAnyEvent *)event)->window, msg, 0, (long)event );
+ }
+
+ // Process keyboard shortcuts
+ if( msg == KeyPress )
+ {
+/* int KeyModifier = 0;
+ // If key is ALT
+ if( ((GdkEventKey *)event)->state & GDK_MOD1_MASK )
+ {
+ KeyModifier = 1;
+ }
+ // If key is CTRL
+ else if( ((GdkEventKey *)event)->state & GDK_CONTROL_MASK )
+ {
+ KeyModifier = 2;
+ }
+ int key = ((GdkEventKey *)event)->keyval;
+ // Translate into lower case
+ if( key >= 'a' && key <= 'z' )
+ {
+ key -= ('a' - 'A');
+ }
+ if( KeyModifier > 0 )
+ p_intf->p_sys->p_theme->EvtBank->TestShortcut( key , KeyModifier );*/
+ }
+
+ // Send event
+ else if( IsVLCEvent( msg ) )
+ {
+ if( !proc->EventProc( evt ) )
+ {
+// wxExit();
+ return; // Exit VLC !
+ }
+ }
+ else if( wnd == NULL )
+ {
+ for( win = p_intf->p_sys->p_theme->WindowList.begin();
+ win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
+ {
+ (*win)->ProcessEvent( evt );
+ }
+ }
+ else
+ {
+ // Find window matching with gwnd
+ for( win = p_intf->p_sys->p_theme->WindowList.begin();
+ win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
+ {
+ // If it is the correct window
+ if( wnd == ( (X11Window *)(*win) )->GetHandle() )
+ {
+ // Send event and check if processed
+ if( (*win)->ProcessEvent( evt ) )
+ {
+ delete (OSEvent *)evt;
+ return;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ evt->DestructParameters();
+ delete (OSEvent *)evt;
+
+// Check if vlc is closing
+ proc->IsClosing();
+
+}
+
+
+//---------------------------------------------------------------------------
+// X11 interface
//---------------------------------------------------------------------------
void OSRun( intf_thread_t *p_intf )
{
static char *p_args[] = { "" };
- // Create VLC event object processing
- CallBackObjects *callbackobj = new CallBackObjects();
- callbackobj->Proc = new VlcProc( p_intf );
-
+ VlcProc *proc = new VlcProc( p_intf );
+
/* wxTheApp = new Instance( p_intf, callbackobj );
-
wxEntry( 1, p_args );*/
Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay();
{
XEvent *event;
XNextEvent( display, event );
- fprintf(stderr,"event %d\n", event->type);
+
+ ProcessEvent( p_intf, proc, event );
}
- delete callbackobj;
}
//---------------------------------------------------------------------------
bool IsVLCEvent( unsigned int msg )
* x11_window.cpp: X11 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_window.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $
+ * $Id: x11_window.cpp,v 1.2 2003/05/13 20:36:29 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
{
// Set handles
Wnd = wnd;
-// gc = gdk_gc_new( gwnd );
+
+ display = p_intf->p_sys->display;
+ int screen = DefaultScreen( display );
+
+ Gc = DefaultGC( display, screen );
Name = name;
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
-/*
+
switch( msg )
{
- case GDK_EXPOSE:
+ case Expose:
RefreshFromImage( 0, 0, Width, Height );
return true;
- case GDK_MOTION_NOTIFY:
- if( LButtonDown )
+ case MotionNotify:
+ /* if( LButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 );
else if( RButtonDown )
else
MouseMove( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 0 );
- gdk_window_get_pointer( gWnd, 0, 0, 0 );
+ gdk_window_get_pointer( gWnd, 0, 0, 0 );*/
return true;
- case GDK_BUTTON_PRESS:
+ case ButtonPress:
// Raise all the windows
- for( list<SkinWindow *>::const_iterator win =
+/* for( list<SkinWindow *>::const_iterator win =
p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
default:
break;
- }
+ }*/
return true;
- case GDK_BUTTON_RELEASE:
- switch( ( (GdkEventButton *)p2 )->button )
+ case ButtonRelease:
+/* switch( ( (GdkEventButton *)p2 )->button )
{
case 1:
// Left button
default:
break;
- }
+ }*/
return true;
- case GDK_LEAVE_NOTIFY:
+ case LeaveNotify:
OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
return true;
- case GDK_2BUTTON_PRESS:
+/* case GDK_2BUTTON_PRESS:
MouseDblClick( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 );
return true;
break;
}
return true;
-
+*/
default:
return false;
- }*/
+ }
}
//---------------------------------------------------------------------------
void X11Window::SetTransparency( int Value )
ReleaseDC( hWnd, DC );
*/
-/* GdkDrawable *drawable = (( X11Graphics* )Image )->GetImage();
- GdkImage *image = gdk_drawable_get_image( drawable, 0, 0, Width, Height );
+ Drawable drawable = (( X11Graphics* )Image )->GetImage();
- gdk_draw_drawable( gWnd, gc, drawable, x, y, x, y, w, h );
-
+ fprintf(stderr, "prout\n");
+ XCopyArea( display, drawable, Wnd, Gc, x, y, w, h, x, y );
+ XSync( display, 0);
+/*
// Mask for transparency
GdkRegion *region = gdk_region_new();
for( int line = 0; line < Height; line++ )