Commit c0a203df authored by Olivier Teulière's avatar Olivier Teulière

* basic event handling

parent e989b3be
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class * gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.7 2003/04/14 20:07:49 asmax Exp $ * $Id: gtk2_bitmap.cpp,v 1.8 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_graphics.cpp: GTK2 implementation of the Graphics and Region classes * gtk2_graphics.cpp: GTK2 implementation of the Graphics and Region classes
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_graphics.cpp,v 1.6 2003/04/14 20:07:49 asmax Exp $ * $Id: gtk2_graphics.cpp,v 1.7 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -79,7 +79,6 @@ void GTK2Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src, ...@@ -79,7 +79,6 @@ void GTK2Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
{ {
/* BitBlt( Image, dx, dy, dw, dh, ( (GTK2Graphics *)Src )->GetImageHandle(), /* BitBlt( Image, dx, dy, dw, dh, ( (GTK2Graphics *)Src )->GetImageHandle(),
sx, sy, Flag );*/ sx, sy, Flag );*/
fprintf(stderr, "%d %d %d %d %d %d\n", sx, sy, dx, dy, dw, dh);
gdk_draw_drawable( Image, Gc, (( GTK2Graphics* )Src )->GetImage(), gdk_draw_drawable( Image, Gc, (( GTK2Graphics* )Src )->GetImage(),
sx, sy, dx, dy, dw, dh ); sx, sy, dx, dy, dw, dh );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_run.cpp: * gtk2_run.cpp:
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_run.cpp,v 1.4 2003/04/13 19:09:59 asmax Exp $ * $Id: gtk2_run.cpp,v 1.5 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -63,121 +63,93 @@ int SkinManage( intf_thread_t *p_intf ); ...@@ -63,121 +63,93 @@ int SkinManage( intf_thread_t *p_intf );
}*/ }*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// GTK2 interface // GTK2 interface
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void OSRun( intf_thread_t *p_intf ) void GTK2Proc( GdkEvent *event, gpointer data )
{ {
#if 0 GdkWindow *gwnd = ((GdkEventAny *)event)->window;
VlcProc *Proc = new VlcProc( p_intf );
MSG msg;
list<Window *>::const_iterator win;
Event *ProcessEvent;
int KeyModifier = 0;
// Create refresh timer // Get pointer to thread info
SetTimer( ((OSTheme *)p_intf->p_sys->p_theme)->GetParentWindow(), 42, 200, intf_thread_t *p_intf = (intf_thread_t *)data;
(TIMERPROC)RefreshTimer );
// Compute windows message list // If doesn't exist, treat windows message normally
while( GetMessage( &msg, NULL, 0, 0 ) ) // if( p_intf == NULL )
{ // return DefWindowProc( hwnd, uMsg, wParam, lParam );
// Translate keys
TranslateMessage( &msg );
// Create event // Create event to dispatch in windows
ProcessEvent = (Event *)new OSEvent( p_intf, msg.hwnd, msg.message, Event *evt = (Event *)new OSEvent( p_intf, ((GdkEventAny *)event)->window,
msg.wParam, msg.lParam ); event->type, 0, (long)event );
/***************************** // Find window matching with gwnd
* Process keyboard shortcuts * list<Window *>::const_iterator win;
*****************************/ for( win = p_intf->p_sys->p_theme->WindowList.begin();
if( msg.message == WM_KEYUP ) win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{ {
msg_Err( p_intf, "Key : %i (%i)", msg.wParam, KeyModifier ); // If it is the correct window
// If key is CTRL if( gwnd == ( (GTK2Window *)(*win) )->GetHandle() )
if( msg.wParam == 17 )
KeyModifier = 0;
else if( KeyModifier == 0 )
{ {
p_intf->p_sys->p_theme->EvtBank->TestShortcut( // Send event and check if processed
msg.wParam, 0 ); if( (*win)->ProcessEvent( evt ) )
}
}
else if( msg.message == WM_KEYDOWN )
{ {
// If key is control delete (OSEvent *)evt;
if( msg.wParam == 17 ) return;
KeyModifier = 2;
else if( KeyModifier > 0 )
p_intf->p_sys->p_theme->EvtBank->TestShortcut(
msg.wParam, KeyModifier );
} }
else if( msg.message == WM_SYSKEYDOWN ) else
{ {
// If key is ALT break;
if( msg.wParam == 18 )
KeyModifier = 1;
} }
else if( msg.message == WM_SYSKEYUP )
{
// If key is a system key
KeyModifier = 0;
} }
/************************
* Process timer message *
************************/
else if( msg.message == WM_TIMER )
{
DispatchMessage( &msg );
} }
delete (OSEvent *)evt;
/*********************** #if 0
* VLC specific message * // If Window is parent window
***********************/ if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
else if( IsVLCEvent( msg.message ) )
{ {
if( !Proc->EventProc( ProcessEvent ) ) if( uMsg == WM_SYSCOMMAND )
break; // Exit VLC !
}
/**********************
* Broadcsated message *
**********************/
else if( msg.hwnd == NULL )
{ {
for( win = p_intf->p_sys->p_theme->WindowList.begin(); if( (Event *)wParam != NULL )
win != p_intf->p_sys->p_theme->WindowList.end(); win++ ) ( (Event *)wParam )->SendEvent();
return 0;
}
else if( uMsg == WM_RBUTTONDOWN && wParam == 42 &&
lParam == WM_RBUTTONDOWN )
{ {
(*win)->ProcessEvent( ProcessEvent ); int x, y;
OSAPI_GetMousePos( x, y );
TrackPopupMenu(
( (GTK2Theme *)p_intf->p_sys->p_theme )->GetSysMenu(),
0, x, y, 0, hwnd, NULL );
} }
} }
/***********************
* Process window event * // If closing parent window
***********************/ if( uMsg == WM_CLOSE )
else
{ {
DispatchMessage( &msg ); OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );
return 0;
} }
// Delete event // If hwnd does not match any window or message not processed
ProcessEvent->DestructParameters(); return DefWindowProc( hwnd, uMsg, wParam, lParam );
delete (OSEvent *)ProcessEvent; #endif
}
//---------------------------------------------------------------------------
// Check if vlc is closing
Proc->IsClosing();
} //---------------------------------------------------------------------------
#endif // GTK2 interface
//---------------------------------------------------------------------------
void OSRun( intf_thread_t *p_intf )
{
gdk_event_handler_set( GTK2Proc, (gpointer)p_intf, NULL );
// Main event loop // Main event loop
GMainLoop *loop = g_main_loop_new( NULL, TRUE ); GMainLoop *loop = g_main_loop_new( NULL, TRUE );
g_main_loop_run( loop ); g_main_loop_run( loop );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool IsVLCEvent( unsigned int msg ) bool IsVLCEvent( unsigned int msg )
...@@ -186,5 +158,4 @@ bool IsVLCEvent( unsigned int msg ) ...@@ -186,5 +158,4 @@ bool IsVLCEvent( unsigned int msg )
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif #endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_theme.cpp: GTK2 implementation of the Theme class * gtk2_theme.cpp: GTK2 implementation of the Theme class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_theme.cpp,v 1.9 2003/04/14 20:17:33 asmax Exp $ * $Id: gtk2_theme.cpp,v 1.10 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -49,83 +49,6 @@ ...@@ -49,83 +49,6 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void SkinManage( intf_thread_t *p_intf ); void SkinManage( intf_thread_t *p_intf );
/*
//---------------------------------------------------------------------------
// GTK2 interface
//---------------------------------------------------------------------------
LRESULT CALLBACK GTK2Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// Get pointer to thread info
intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
GWLP_USERDATA );
// If doesn't exist, treat windows message normally
if( p_intf == NULL )
return DefWindowProc( hwnd, uMsg, wParam, lParam );
// Create event to dispatch in windows
Event *evt = (Event *)new OSEvent( p_intf, hwnd, uMsg, wParam, lParam );
// Find window matching with hwnd
list<Window *>::const_iterator win;
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( hwnd == ( (GTK2Window *)(*win) )->GetHandle() )
{
// Send event and check if processed
if( (*win)->ProcessEvent( evt ) )
{
delete (OSEvent *)evt;
return 0;
}
else
{
break;
}
}
}
delete (OSEvent *)evt;
// If Window is parent window
if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
{
if( uMsg == WM_SYSCOMMAND )
{
if( (Event *)wParam != NULL )
( (Event *)wParam )->SendEvent();
return 0;
}
else if( uMsg == WM_RBUTTONDOWN && wParam == 42 &&
lParam == WM_RBUTTONDOWN )
{
int x, y;
OSAPI_GetMousePos( x, y );
TrackPopupMenu(
( (GTK2Theme *)p_intf->p_sys->p_theme )->GetSysMenu(),
0, x, y, 0, hwnd, NULL );
}
}
// If closing parent window
if( uMsg == WM_CLOSE )
{
OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );
return 0;
}
// If hwnd does not match any window or message not processed
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
//---------------------------------------------------------------------------
*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// THEME // THEME
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_window.cpp: GTK2 implementation of the Window class * gtk2_window.cpp: GTK2 implementation of the Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.cpp,v 1.8 2003/04/14 20:17:33 asmax Exp $ * $Id: gtk2_window.cpp,v 1.9 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
//--- GTK2 ------------------------------------------------------------------ //--- GTK2 ------------------------------------------------------------------
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <glib.h>
//--- SKIN ------------------------------------------------------------------ //--- SKIN ------------------------------------------------------------------
#include "os_api.h" #include "os_api.h"
...@@ -47,7 +48,6 @@ ...@@ -47,7 +48,6 @@
#include "theme.h" #include "theme.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Fading API // Fading API
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -71,6 +71,9 @@ GTK2Window::GTK2Window( intf_thread_t *p_intf, GdkWindow *gwnd, int x, int y, ...@@ -71,6 +71,9 @@ GTK2Window::GTK2Window( intf_thread_t *p_intf, GdkWindow *gwnd, int x, int y,
// Set handles // Set handles
gWnd = gwnd; gWnd = gwnd;
gc = gdk_gc_new( gwnd ); gc = gdk_gc_new( gwnd );
LButtonDown = false;
RButtonDown = false;
/* /*
// Set position parameters // Set position parameters
CursorPos = new POINT; CursorPos = new POINT;
...@@ -155,46 +158,80 @@ void GTK2Window::OSShow( bool show ) ...@@ -155,46 +158,80 @@ void GTK2Window::OSShow( bool show )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool GTK2Window::ProcessOSEvent( Event *evt ) bool GTK2Window::ProcessOSEvent( Event *evt )
{ {
/* unsigned int msg = evt->GetMessage(); unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1(); unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2(); int p2 = evt->GetParam2();
fprintf( stderr, "salut %li\n", evt->GetMessage() );
switch( msg ) switch( msg )
{ {
case WM_PAINT: case GDK_EXPOSE:
HDC DC;
PAINTSTRUCT Infos;
DC = BeginPaint( hWnd , &Infos );
EndPaint( hWnd , &Infos );
RefreshFromImage( 0, 0, Width, Height ); RefreshFromImage( 0, 0, Width, Height );
return true; return true;
case WM_MOUSEMOVE:
TRACKMOUSEEVENT TrackEvent; case GDK_MOTION_NOTIFY:
TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT ); // TRACKMOUSEEVENT TrackEvent;
TrackEvent.dwFlags = TME_LEAVE; // TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT );
TrackEvent.hwndTrack = hWnd; // TrackEvent.dwFlags = TME_LEAVE;
TrackEvent.dwHoverTime = 1; // TrackEvent.hwndTrack = hWnd;
TrackMouseEvent( &TrackEvent ); // TrackEvent.dwHoverTime = 1;
if( p1 == MK_LBUTTON ) // TrackMouseEvent( &TrackEvent );
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 1 ); if( LButtonDown )
else if( p1 == MK_RBUTTON ) MouseMove( ((GdkEventButton *)p2)->x_root, ((GdkEventButton *)p2)->y_root,
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 2 ); 1 );
else if( RButtonDown )
MouseMove( ((GdkEventButton *)p2)->x_root, ((GdkEventButton *)p2)->y_root,
2 );
else else
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 0 ); MouseMove( ((GdkEventButton *)p2)->x_root, ((GdkEventButton *)p2)->y_root,
0 );
return true; return true;
case WM_LBUTTONDOWN:
SetCapture( hWnd ); case GDK_BUTTON_PRESS:
MouseDown( LOWORD( p2 ), HIWORD( p2 ), 1 ); switch( ((GdkEventButton *)p2)->button )
{
case 1:
// Left button
LButtonDown = true;
MouseDown( ((GdkEventButton *)p2)->x_root,
((GdkEventButton *)p2)->y_root, 1 );
break;
case 3:
// Right button
RButtonDown = true;
MouseDown( ((GdkEventButton *)p2)->x_root,
((GdkEventButton *)p2)->y_root, 2 );
break;
default:
break;
}
return true; return true;
case WM_LBUTTONUP: case GDK_BUTTON_RELEASE:
ReleaseCapture(); switch( ((GdkEventButton *)p2)->button )
MouseUp( LOWORD( p2 ), HIWORD( p2 ), 1 ); {
case 1:
// Left button
LButtonDown = false;
MouseUp( ((GdkEventButton *)p2)->x_root,
((GdkEventButton *)p2)->y_root, 1 );
break;
case 3:
// Right button
RButtonDown = false;
MouseUp( ((GdkEventButton *)p2)->x_root,
((GdkEventButton *)p2)->y_root, 2 );
break;
default:
break;
}
return true; return true;
/*
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
MouseDown( LOWORD( p2 ), HIWORD( p2 ), 2 ); MouseDown( LOWORD( p2 ), HIWORD( p2 ), 2 );
return true; return true;
...@@ -210,10 +247,10 @@ bool GTK2Window::ProcessOSEvent( Event *evt ) ...@@ -210,10 +247,10 @@ bool GTK2Window::ProcessOSEvent( Event *evt )
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 ); OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
return true; return true;
*/
default: default:
return false; return false;
}*/ }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Window::SetTransparency( int Value ) void GTK2Window::SetTransparency( int Value )
...@@ -245,25 +282,23 @@ void GTK2Window::RefreshFromImage( int x, int y, int w, int h ) ...@@ -245,25 +282,23 @@ void GTK2Window::RefreshFromImage( int x, int y, int w, int h )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Window::WindowManualMove() void GTK2Window::WindowManualMove()
{ {
/* // Get mouse cursor position // Get mouse cursor position
LPPOINT NewPos = new POINT; int x, y;
GetCursorPos( NewPos ); gdk_display_get_pointer( gdk_display_get_default(), NULL, &x, &y, NULL );
// Move window and chek for magnetism // Move window and chek for magnetism
p_intf->p_sys->p_theme->MoveSkinMagnet( this, p_intf->p_sys->p_theme->MoveSkinMagnet( this,
WindowPos->x + NewPos->x - CursorPos->x, WindowX + x - CursorX, WindowY + y - CursorY );
WindowPos->y + NewPos->y - CursorPos->y );
// Free memory fprintf( stderr, "---------\n" );
delete[] NewPos;
*/
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Window::WindowManualMoveInit() void GTK2Window::WindowManualMoveInit()
{ {
/* GetCursorPos( CursorPos ); gdk_display_get_pointer( gdk_display_get_default(), NULL, &CursorX,
WindowPos->x = Left; &CursorY, NULL );
WindowPos->y = Top;*/ WindowX = Left;
WindowY = Top;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Window::Move( int left, int top ) void GTK2Window::Move( int left, int top )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_window.h: GTK2 implementation of the Window class * gtk2_window.h: GTK2 implementation of the Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.h,v 1.3 2003/04/14 20:07:49 asmax Exp $ * $Id: gtk2_window.h,v 1.4 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -40,8 +40,10 @@ class GTK2Window : public Window ...@@ -40,8 +40,10 @@ class GTK2Window : public Window
// General parameters // General parameters
GdkWindow *gWnd; GdkWindow *gWnd;
GdkGC *gc; GdkGC *gc;
// LPPOINT CursorPos; int CursorX;
// LPPOINT WindowPos; int CursorY;
int WindowX;
int WindowY;
// Tooltip texts // Tooltip texts
GdkWindow *ToolTipWindow; GdkWindow *ToolTipWindow;
...@@ -50,6 +52,10 @@ class GTK2Window : public Window ...@@ -50,6 +52,10 @@ class GTK2Window : public Window
// Drag & drop // Drag & drop
// LPDROPTARGET DropTarget; // LPDROPTARGET DropTarget;
// Left button down
bool LButtonDown;
bool RButtonDown;
public: public:
// Cosntructors // Cosntructors
GTK2Window( intf_thread_t *_p_intf, GdkWindow *gwnd, int x, int y, GTK2Window( intf_thread_t *_p_intf, GdkWindow *gwnd, int x, int y,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* window.cpp: Window class * window.cpp: Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: window.cpp,v 1.8 2003/04/14 20:07:49 asmax Exp $ * $Id: window.cpp,v 1.9 2003/04/15 01:19:11 ipkiss Exp $
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -322,6 +322,8 @@ void Window::MouseMove( int x, int y, int button ) ...@@ -322,6 +322,8 @@ void Window::MouseMove( int x, int y, int button )
{ {
int i; int i;
fprintf( stderr, "pouet %i\n", button );
// Move window if selected ! // Move window if selected !
if( WindowMoving ) if( WindowMoving )
{ {
......
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