Commit 1377f497 authored by Emmanuel Puig's avatar Emmanuel Puig

* Events are even better, not yet perfect !

parent 33eaee68
......@@ -2,7 +2,7 @@
* button.cpp: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.cpp,v 1.5 2003/04/11 21:19:49 videolan Exp $
* $Id: button.cpp,v 1.6 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -170,6 +170,7 @@ bool ControlButton::MouseDown( int x, int y, int button )
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
fprintf( stderr, "button\n" );
}
return false;
......
......@@ -2,7 +2,7 @@
* image.cpp: Image control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: image.cpp,v 1.3 2003/04/13 22:55:15 asmax Exp $
* $Id: image.cpp,v 1.4 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -84,7 +84,7 @@ void ControlImage::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn(x, y, w, h, Left, Top, Width, Height, xI, yI, wI, hI ) )
Img[0]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
......
......@@ -2,7 +2,7 @@
* gtk2_api.cpp: Various gtk2-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_api.cpp,v 1.6 2003/04/15 17:55:49 ipkiss Exp $
* $Id: gtk2_api.cpp,v 1.7 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -65,7 +65,10 @@ void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
event->data.l[1] = param1;
event->data.l[2] = param2;
fprintf( stderr, "======= message %i\n", message );
if( message == VLC_HIDE )
{
fprintf( stderr, "======= message %i\n", message );
}
gdk_event_put( (GdkEvent *)event );
......@@ -127,14 +130,7 @@ void OSAPI_GetMousePos( int &x, int &y )
//---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( Window *win )
{
// char *buffer = new char[MAX_PARAM_SIZE];
// GetWindowText( ((GTK2Window *)win)->GetHandle(), buffer, MAX_PARAM_SIZE );
// string Title = buffer;
/* FIXME */
string Title = "";
// delete buffer;
return Title;
return ( (GTK2Window *)win )->GetName();
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
......
......@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.8 2003/04/15 01:19:11 ipkiss Exp $
* $Id: gtk2_bitmap.cpp,v 1.9 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -172,12 +172,30 @@ void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
//---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y)
{
/* unsigned int c = GetPixel( bmpDC, x, y );
if( c == AlphaColor || c == CLR_INVALID )
if( x < 0 || x >= Width || y < 0 || y >= Height )
return false;
guchar *pixels;
int rowstride, offset;
gboolean has_alpha;
rowstride = gdk_pixbuf_get_rowstride( Bmp );
pixels = gdk_pixbuf_get_pixels( Bmp );
has_alpha = gdk_pixbuf_get_has_alpha( Bmp );
offset = y * rowstride + ( x * (has_alpha ? 4 : 3) );
int r = pixels [offset];
int g = pixels [offset + 1];
int b = pixels [offset + 2];
unsigned int c = r + g * 256 + b * 65536;
/* If has_alpha == TRUE, then the alpha component is in
pixels [offset + 3] */
if( c == AlphaColor )
return false;
else
return true;
*/
}
//---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y )
......
......@@ -2,7 +2,7 @@
* gtk2_event.cpp: GTK2 implementation of the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_event.cpp,v 1.5 2003/04/15 17:55:49 ipkiss Exp $
* $Id: gtk2_event.cpp,v 1.6 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -68,7 +68,6 @@ GTK2Event::~GTK2Event()
//---------------------------------------------------------------------------
bool GTK2Event::SendEvent()
{
fprintf( stderr, "++++++++++++++++ %i\n", Message );
if( Message != VLC_NOTHING )
{
// Find window matching with gwnd
......@@ -120,11 +119,13 @@ GdkWindow *GTK2Event::GetWindowFromName( string name )
{
GTK2Window *win = (GTK2Window *)
p_intf->p_sys->p_theme->GetWindow( name );
if( win == NULL )
if( win == NULL )
{
return NULL;
}
else {
else
{
return win->GetHandle();
}
}
......
......@@ -2,7 +2,7 @@
* gtk2_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_run.cpp,v 1.6 2003/04/15 17:55:49 ipkiss Exp $
* $Id: gtk2_run.cpp,v 1.7 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -69,25 +69,25 @@ int SkinManage( intf_thread_t *p_intf );
void GTK2Proc( GdkEvent *event, gpointer data )
{
// Get pointer to thread info
intf_thread_t *p_intf = (intf_thread_t *)data;
VlcProc *Proc = new VlcProc( p_intf );
unsigned int msg;
VlcProc *proc = (VlcProc *)data;
intf_thread_t *p_intf = proc->GetpIntf();
list<Window *>::const_iterator win;
GdkWindow *gwnd = ((GdkEventAny *)event)->window;
fprintf( stderr, "------ %li\n", (long int)gwnd );
// If doesn't exist, treat windows message normally
// if( p_intf == NULL )
// return DefWindowProc( hwnd, uMsg, wParam, lParam );
if( event->type == GDK_CLIENT_EVENT )
msg = ( (GdkEventClient *)event )->data.l[0];
else
msg = event->type;
// Create event to dispatch in windows
Event *evt = (Event *)new OSEvent( p_intf, ((GdkEventAny *)event)->window,
event->type, 0, (long)event );
msg, 0, (long)event );
if( IsVLCEvent( event->type ) )
if( IsVLCEvent( msg ) )
{
if( !Proc->EventProc( evt ) )
if( !proc->EventProc( evt ) )
return; // Exit VLC !
}
else if( gwnd == NULL )
......@@ -122,7 +122,6 @@ void GTK2Proc( GdkEvent *event, gpointer data )
}
delete (OSEvent *)evt;
delete Proc;
#if 0
// If Window is parent window
......@@ -166,7 +165,10 @@ void GTK2Proc( GdkEvent *event, gpointer data )
//---------------------------------------------------------------------------
void OSRun( intf_thread_t *p_intf )
{
gdk_event_handler_set( GTK2Proc, (gpointer)p_intf, NULL );
// Create VLC event object processing
VlcProc *proc = new VlcProc( p_intf );
gdk_event_handler_set( GTK2Proc, (gpointer)proc, NULL );
// Main event loop
GMainLoop *loop = g_main_loop_new( NULL, TRUE );
......
......@@ -2,7 +2,7 @@
* gtk2_theme.cpp: GTK2 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_theme.cpp,v 1.11 2003/04/15 16:42:02 karibu Exp $
* $Id: gtk2_theme.cpp,v 1.12 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -242,15 +242,16 @@ void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
fadetime, alpha, movealpha, dragdrop ) ) ;*/
GdkWindowAttr attr;
attr.title = (gchar *)name.c_str();
attr.event_mask = GDK_ALL_EVENTS_MASK;
attr.width = 0;
attr.height = 0;
attr.window_type = GDK_WINDOW_TOPLEVEL;
attr.wclass = GDK_INPUT_OUTPUT;
attr.override_redirect = TRUE;
gint mask = GDK_WA_NOREDIR;
// Create the window
GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
if( !gwnd )
......@@ -258,11 +259,11 @@ void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
msg_Err( p_intf, "CreateWindow failed" );
return;
}
gdk_window_show( gwnd );
WindowList.push_back( (Window *)new OSWindow( p_intf, gwnd, x, y, visible,
fadetime, alpha, movealpha, dragdrop ) ) ;
fadetime, alpha, movealpha, dragdrop, name ) ) ;
}
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* gtk2_window.cpp: GTK2 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.cpp,v 1.14 2003/04/15 17:55:49 ipkiss Exp $
* $Id: gtk2_window.cpp,v 1.15 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -64,7 +64,7 @@ SLWA SetLayeredWindowAttributes =
//---------------------------------------------------------------------------
GTK2Window::GTK2Window( intf_thread_t *p_intf, GdkWindow *gwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
bool dragdrop )
bool dragdrop, string name )
: Window( p_intf, x, y, visible, transition, normalalpha, movealpha,
dragdrop )
{
......@@ -72,6 +72,8 @@ GTK2Window::GTK2Window( intf_thread_t *p_intf, GdkWindow *gwnd, int x, int y,
gWnd = gwnd;
gc = gdk_gc_new( gwnd );
Name = name;
LButtonDown = false;
RButtonDown = false;
/*
......@@ -168,7 +170,6 @@ bool GTK2Window::ProcessOSEvent( Event *evt )
RefreshFromImage( 0, 0, Width, Height );
return true;
case GDK_MOTION_NOTIFY:
if( LButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x,
......@@ -231,14 +232,6 @@ bool GTK2Window::ProcessOSEvent( Event *evt )
OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
return true;
/*
case WM_RBUTTONDOWN:
MouseDown( LOWORD( p2 ), HIWORD( p2 ), 2 );
return true;
case WM_RBUTTONUP:
MouseUp( LOWORD( p2 ), HIWORD( p2 ), 2 );
return true;
case WM_LBUTTONDBLCLK:
MouseDblClick( LOWORD( p2 ), HIWORD( p2 ), 1 );
return true;
......@@ -285,7 +278,6 @@ void GTK2Window::WindowManualMove()
p_intf->p_sys->p_theme->MoveSkinMagnet( this,
WindowX + x - CursorX, WindowY + y - CursorY );
fprintf( stderr, "---------\n" );
}
//---------------------------------------------------------------------------
void GTK2Window::WindowManualMoveInit()
......
......@@ -2,7 +2,7 @@
* gtk2_window.h: GTK2 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.h,v 1.4 2003/04/15 01:19:11 ipkiss Exp $
* $Id: gtk2_window.h,v 1.5 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -44,6 +44,7 @@ class GTK2Window : public Window
int CursorY;
int WindowX;
int WindowY;
string Name;
// Tooltip texts
GdkWindow *ToolTipWindow;
......@@ -60,7 +61,7 @@ class GTK2Window : public Window
// Cosntructors
GTK2Window( intf_thread_t *_p_intf, GdkWindow *gwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
bool dragdrop );
bool dragdrop, string name );
// Destructors
virtual ~GTK2Window();
......@@ -84,6 +85,9 @@ class GTK2Window : public Window
// Tooltip texts
virtual void ChangeToolTipText( string text );
// Getters
string GetName() { return Name; }
};
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* vlcproc.h: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.h,v 1.3 2003/04/14 10:00:39 karibu Exp $
* $Id: vlcproc.h,v 1.4 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -69,6 +69,9 @@ class VlcProc
bool EventProc( Event *evt );
bool EventProcEnd();
bool IsClosing();
// Getters
intf_thread_t *GetpIntf() { return p_intf; };
};
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.cpp,v 1.10 2003/04/15 16:42:02 karibu Exp $
* $Id: window.cpp,v 1.11 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -309,9 +309,6 @@ void Window::RefreshAll()
void Window::MouseDown( int x, int y, int button )
{
// Checking event in controls
fprintf( stderr, " -> mousedown\n" );
for( int i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->MouseDown( x, y, button ) )
......@@ -319,6 +316,7 @@ void Window::MouseDown( int x, int y, int button )
return;
}
}
}
//---------------------------------------------------------------------------
void Window::MouseMove( int x, int y, int button )
......@@ -384,8 +382,6 @@ void Window::MouseUp( int x, int y, int button )
WindowMoving = false;
}
fprintf( stderr, " -> mouseup\n" );
// Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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