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

* basic event handling

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