]> git.sesse.net Git - vlc/commitdiff
* beginning of event processing in X11 skins
authorCyril Deguet <asmax@videolan.org>
Tue, 13 May 2003 20:36:29 +0000 (20:36 +0000)
committerCyril Deguet <asmax@videolan.org>
Tue, 13 May 2003 20:36:29 +0000 (20:36 +0000)
* graphics should work, but....

modules/gui/skins/x11/x11_run.cpp
modules/gui/skins/x11/x11_window.cpp
modules/gui/skins/x11/x11_window.h

index 2c1eaa4b313095a0a954a9dd66a487a811338508..4ce3546001ce100336ce652772e4295130ad0f70 100644 (file)
@@ -2,7 +2,7 @@
  * 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
@@ -70,14 +64,13 @@ class Instance: public wxApp
 {
 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;
 };
 
 
@@ -211,11 +204,10 @@ Instance::Instance( )
 {
 }
 
-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)
@@ -241,18 +233,121 @@ bool Instance::OnInit()
 
 
 //---------------------------------------------------------------------------
-// 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();
@@ -262,10 +357,10 @@ void OSRun( intf_thread_t *p_intf )
     {
         XEvent *event;
         XNextEvent( display, event );
-        fprintf(stderr,"event %d\n", event->type);
+        
+        ProcessEvent( p_intf, proc, event );
     }
     
-    delete callbackobj;
 }
 //---------------------------------------------------------------------------
 bool IsVLCEvent( unsigned int msg )
index 90850a88cfd7463db82d05e659019c0ccd59c03c..031b08b55dd796197c8456bfdf66f6d56deaa9f3 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -58,7 +58,11 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
 {
     // 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;
 
@@ -155,15 +159,15 @@ bool X11Window::ProcessOSEvent( Event *evt )
     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 )
@@ -172,13 +176,13 @@ bool X11Window::ProcessOSEvent( Event *evt )
             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++ )
             {
@@ -203,11 +207,11 @@ bool X11Window::ProcessOSEvent( Event *evt )
 
                 default:
                     break;
-            }
+            }*/
             return true;
 
-        case GDK_BUTTON_RELEASE:
-            switch( ( (GdkEventButton *)p2 )->button )
+        case ButtonRelease:
+/*            switch( ( (GdkEventButton *)p2 )->button )
             {
                 case 1:
                     // Left button
@@ -225,14 +229,14 @@ bool X11Window::ProcessOSEvent( Event *evt )
 
                 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;
@@ -256,10 +260,10 @@ bool X11Window::ProcessOSEvent( Event *evt )
                     break;
             }
             return true;
-
+*/
         default:
             return false;
-    }*/
+    }
 }
 //---------------------------------------------------------------------------
 void X11Window::SetTransparency( int Value )
@@ -283,11 +287,12 @@ void X11Window::RefreshFromImage( int x, int y, int w, int h )
     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++ )
index f2f37b48467925d5ffaccd6d1ff43b31d2a34f81..2de92e27e9c86ac4e31d604ca2585eb1997f2d9e 100644 (file)
@@ -2,7 +2,7 @@
  * x11_window.h: X11 implementation of the Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_window.h,v 1.1 2003/04/28 14:32:57 asmax Exp $
+ * $Id: x11_window.h,v 1.2 2003/05/13 20:36:29 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -39,7 +39,8 @@ class X11Window : public SkinWindow
     private:
         // General parameters
         Window Wnd;
-//        GdkGC *gc;
+        Display *display;
+        GC Gc;
         int CursorX;
         int CursorY;
         int WindowX;
@@ -80,7 +81,7 @@ class X11Window : public SkinWindow
         virtual void Move( int left, int top );
         virtual void Size( int width, int height );
 
-        // Specific gtk2 methods
+        // Specific X11 methods
         Window GetHandle() { return Wnd; };
 
         // Tooltip texts