Commit f0208594 authored by Cyril Deguet's avatar Cyril Deguet

* a lot of cleaning in X11 skins, but some problems remain with

  event handling :(
parent 52783dae
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_api.cpp: Various x11-specific functions * x11_api.cpp: Various x11-specific functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_api.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $ * $Id: x11_api.cpp,v 1.2 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -28,12 +28,14 @@ ...@@ -28,12 +28,14 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
//--- SKIN ------------------------------------------------------------------ //--- SKIN ------------------------------------------------------------------
#include <vlc/intf.h>
#include "../src/skin_common.h"
#include "../src/window.h" #include "../src/window.h"
#include "../os_window.h" #include "../os_window.h"
#include "../os_api.h" #include "../os_api.h"
#include "../src/event.h" // for MAX_PARAM_SIZE #include "../src/event.h" // for MAX_PARAM_SIZE
#include <stdio.h> extern intf_thread_t *g_pIntf; // ugly, but it's not my fault ;)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Event API // Event API
...@@ -51,24 +53,21 @@ void OSAPI_SendMessage( SkinWindow *win, unsigned int message, unsigned int para ...@@ -51,24 +53,21 @@ void OSAPI_SendMessage( SkinWindow *win, unsigned int message, unsigned int para
void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int param1, void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int param1,
long param2 ) long param2 )
{ {
XEvent event;
/* GdkEventClient *event = new GdkEventClient; event.type = ClientMessage;
event.xclient.display = g_pIntf->p_sys->display;
event->type = GDK_CLIENT_EVENT;
if( win == NULL ) if( win == NULL )
event->window = NULL; event.xclient.window = NULL;
else else
event->window = (( Window )win)->GetHandle(); event.xclient.window = (( X11Window *)win)->GetHandle();
event->send_event = 0; event.xclient.send_event = 0;
event->message_type = NULL; event.xclient.message_type = NULL;
event->data_format = 32; event.xclient.format = 32;
event->data.l[0] = message; event.xclient.data.l[0] = message;
event->data.l[1] = param1; event.xclient.data.l[1] = param1;
event->data.l[2] = param2; event.xclient.data.l[2] = param2;
XSendEvent( g_pIntf->p_sys->display, event.xclient.window, False, 0, &event );
gdk_event_put( (GdkEvent *)event );
delete event;*/
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -117,12 +116,21 @@ void OSAPI_GetScreenSize( int &w, int &h ) ...@@ -117,12 +116,21 @@ void OSAPI_GetScreenSize( int &w, int &h )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y ) void OSAPI_GetMousePos( int &x, int &y )
{ {
/* gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );*/ Window rootReturn, childReturn;
int rootx, rooty;
int winx, winy;
unsigned int xmask;
Window root = DefaultRootWindow( g_pIntf->p_sys->display );
XQueryPointer( g_pIntf->p_sys->display, root, &rootReturn, &childReturn,
&rootx, &rooty, &winx, &winy, &xmask );
x = rootx;
y = rooty;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( SkinWindow *win ) string OSAPI_GetWindowTitle( SkinWindow *win )
{ {
/* return ( (GTK2Window *)win )->GetName();*/ return ( (X11Window *)win )->GetName();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool OSAPI_RmDir( string path ) bool OSAPI_RmDir( string path )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_bitmap.cpp: X11 implementation of the Bitmap class * x11_bitmap.cpp: X11 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_bitmap.cpp,v 1.4 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_bitmap.cpp,v 1.5 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -206,7 +206,6 @@ char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor, ...@@ -206,7 +206,6 @@ char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor,
dataSize = U32( headers + 34 ); dataSize = U32( headers + 34 );
nColors = U32( headers + 50 ); nColors = U32( headers + 50 );
fprintf(stderr,"image %s %x\n", fileName.c_str(), AColor);
switch( bpp ) switch( bpp )
{ {
case 24: case 24:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_event.cpp: x11 implementation of the Event class * x11_event.cpp: x11 implementation of the Event class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_event.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $ * $Id: x11_event.cpp,v 1.2 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -61,7 +61,7 @@ X11Event::X11Event( intf_thread_t *p_intf, Window wnd, unsigned int msg, ...@@ -61,7 +61,7 @@ X11Event::X11Event( intf_thread_t *p_intf, Window wnd, unsigned int msg,
X11Event::X11Event( intf_thread_t *p_intf, SkinWindow *win, unsigned int msg, X11Event::X11Event( intf_thread_t *p_intf, SkinWindow *win, unsigned int msg,
unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 ) unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
{ {
// gWnd = ( (X11Window *)win )->GetHandle(); Wnd = ( (X11Window *)win )->GetHandle();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Event::~X11Event() X11Event::~X11Event()
...@@ -70,15 +70,15 @@ X11Event::~X11Event() ...@@ -70,15 +70,15 @@ X11Event::~X11Event()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool X11Event::SendEvent() bool X11Event::SendEvent()
{ {
/* if( Message != VLC_NOTHING ) if( Message != VLC_NOTHING )
{ {
// Find window matching with gwnd // Find window matching with Wnd
list<SkinWindow *>::const_iterator win; list<SkinWindow *>::const_iterator win;
for( win = p_intf->p_sys->p_theme->WindowList.begin(); for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ ) win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{ {
// If it is the correct window // If it is the correct window
if( gWnd == ( (X11Window *)(*win) )->GetHandle() ) if( Wnd == ( (X11Window *)(*win) )->GetHandle() )
{ {
OSAPI_PostMessage( *win, Message, Param1, Param2 ); OSAPI_PostMessage( *win, Message, Param1, Param2 );
PostSynchroMessage(); PostSynchroMessage();
...@@ -88,40 +88,40 @@ bool X11Event::SendEvent() ...@@ -88,40 +88,40 @@ bool X11Event::SendEvent()
OSAPI_PostMessage( NULL, Message, Param1, Param2 ); OSAPI_PostMessage( NULL, Message, Param1, Param2 );
return true; return true;
} }
*/
return false; return false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool X11Event::IsEqual( Event *evt ) bool X11Event::IsEqual( Event *evt )
{ {
/* X11Event *GTKEvt = (X11Event *)evt; X11Event *XEvt = (X11Event *)evt;
return( GTKEvt->GetWindow() == gWnd && GTKEvt->GetMessage() == Message && return( XEvt->GetWindow() == Wnd && XEvt->GetMessage() == Message &&
GTKEvt->GetParam1() == Param1 && GTKEvt->GetParam2() == Param2 );*/ XEvt->GetParam1() == Param1 && XEvt->GetParam2() == Param2 );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Event::CreateOSEvent( string para1, string para2, string para3 ) void X11Event::CreateOSEvent( string para1, string para2, string para3 )
{ {
// Find Parameters // Find Parameters
/* switch( Message ) switch( Message )
{ {
case WINDOW_MOVE: case WINDOW_MOVE:
gWnd = GetWindowFromName( para1 ); Wnd = GetWindowFromName( para1 );
break; break;
case WINDOW_CLOSE: case WINDOW_CLOSE:
gWnd = GetWindowFromName( para1 ); Wnd = GetWindowFromName( para1 );
break; break;
case WINDOW_OPEN: case WINDOW_OPEN:
gWnd = GetWindowFromName( para1 ); Wnd = GetWindowFromName( para1 );
break; break;
}*/ }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Window X11Event::GetWindowFromName( string name ) Window X11Event::GetWindowFromName( string name )
{ {
/* X11Window *win = (X11Window *) X11Window *win = (X11Window *)
p_intf->p_sys->p_theme->GetWindow( name ); p_intf->p_sys->p_theme->GetWindow( name );
if( win == NULL ) if( win == NULL )
...@@ -131,7 +131,7 @@ Window X11Event::GetWindowFromName( string name ) ...@@ -131,7 +131,7 @@ Window X11Event::GetWindowFromName( string name )
else else
{ {
return win->GetHandle(); return win->GetHandle();
}*/ }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_font.cpp: X11 implementation of the Font class * x11_font.cpp: X11 implementation of the Font class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_font.cpp,v 1.2 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_font.cpp,v 1.3 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -91,8 +91,8 @@ void X11Font::AssignFont( Graphics *dest ) ...@@ -91,8 +91,8 @@ void X11Font::AssignFont( Graphics *dest )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Font::GetSize( string text, int &w, int &h ) void X11Font::GetSize( string text, int &w, int &h )
{ {
w = 0; w = 42;
h = 0; h = 12;
/* pango_layout_set_text( Layout, text.c_str(), text.length() ); /* pango_layout_set_text( Layout, text.c_str(), text.length() );
pango_layout_get_pixel_size( Layout, &w, &h );*/ pango_layout_get_pixel_size( Layout, &w, &h );*/
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_run.cpp: * x11_run.cpp:
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_run.cpp,v 1.5 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_run.cpp,v 1.6 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
// include the icon graphic // include the icon graphic
#include "share/vlc32x32.xpm" #include "share/vlc32x32.xpm"
#include <unistd.h>
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Specific method // Specific method
...@@ -191,17 +193,6 @@ private: ...@@ -191,17 +193,6 @@ private:
}*/ }*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// REFRESH TIMER CALLBACK
//---------------------------------------------------------------------------
/*gboolean RefreshTimer( gpointer data )
{
intf_thread_t *p_intf = (intf_thread_t *)data;
SkinManage( p_intf );
return true;
}*/
//---------------------------------------------------------------------------
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Implementation of Instance class // Implementation of Instance class
...@@ -257,12 +248,11 @@ void ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event ) ...@@ -257,12 +248,11 @@ void ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
// Skin event // Skin event
if( event->type == ClientMessage ) if( event->type == ClientMessage )
{ {
/* msg = ( (GdkEventClient *)event )->data.l[0]; msg = ( (XClientMessageEvent *)event )->data.l[0];
evt = (Event *)new OSEvent( p_intf, evt = (Event *)new OSEvent( p_intf,
((GdkEventAny *)event)->window, ((XAnyEvent *)event)->window, msg,
msg, ( (XClientMessageEvent *)event )->data.l[1],
( (GdkEventClient *)event )->data.l[1], ( (XClientMessageEvent *)event )->data.l[2] );
( (GdkEventClient *)event )->data.l[2] );*/
} }
// System event // System event
else else
...@@ -357,18 +347,25 @@ void OSRun( intf_thread_t *p_intf ) ...@@ -357,18 +347,25 @@ void OSRun( intf_thread_t *p_intf )
/* wxTheApp = new Instance( p_intf, callbackobj ); /* wxTheApp = new Instance( p_intf, callbackobj );
wxEntry( 1, p_args );*/ wxEntry( 1, p_args );*/
Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay(); Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay();
// Main event loop // Main event loop
int count = 0;
while( 1 ) while( 1 )
{ {
XEvent *event; XEvent event;
XNextEvent( display, event ); while( XPending( display ) > 0 )
{
ProcessEvent( p_intf, proc, event ); XNextEvent( display, &event );
ProcessEvent( p_intf, proc, &event );
// kludge: add timer }
// SkinManage( p_intf ); usleep( 1000 );
if( ++count == 100 )
{
count = 0;
SkinManage( p_intf ); // Call every 100 ms
}
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_theme.cpp: X11 implementation of the Theme class * x11_theme.cpp: X11 implementation of the Theme class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_theme.cpp,v 1.2 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_theme.cpp,v 1.3 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -169,8 +169,9 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -169,8 +169,9 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
Window root = DefaultRootWindow( display ); Window root = DefaultRootWindow( display );
Window wnd = XCreateSimpleWindow( display, root, 0, 0, 1, 1, 0, 0, 0 ); Window wnd = XCreateSimpleWindow( display, root, 0, 0, 1, 1, 0, 0, 0 );
XSelectInput( display, wnd, ExposureMask| XSelectInput( display, wnd, ExposureMask|
KeyPressMask|KeyReleaseMask|ButtonPressMask|PointerMotionMask| KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|
PointerMotionHintMask| EnterWindowMask|LeaveWindowMask); PointerMotionMask|PointerMotionHintMask|EnterWindowMask|
LeaveWindowMask);
// Changing decorations // Changing decorations
struct { struct {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_window.cpp: X11 implementation of the Window class * x11_window.cpp: X11 implementation of the Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_window.cpp,v 1.4 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_window.cpp,v 1.5 2003/05/19 21:39:34 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -148,6 +148,7 @@ void X11Window::OSShow( bool show ) ...@@ -148,6 +148,7 @@ void X11Window::OSShow( bool show )
{ {
/* gdk_window_show( gWnd ); /* gdk_window_show( gWnd );
gdk_window_move( gWnd, Left, Top );*/ gdk_window_move( gWnd, Left, Top );*/
XMoveWindow( display, Wnd, Left, Top );
} }
else else
{ {
...@@ -168,69 +169,68 @@ bool X11Window::ProcessOSEvent( Event *evt ) ...@@ -168,69 +169,68 @@ bool X11Window::ProcessOSEvent( Event *evt )
return true; return true;
case MotionNotify: case MotionNotify:
/* if( LButtonDown ) if( LButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x, MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 ); (int)( (XMotionEvent *)p2 )->y, 1 );
else if( RButtonDown ) else if( RButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x, MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 ); (int)( (XMotionEvent *)p2 )->y, 2 );
else else
MouseMove( (int)( (GdkEventButton *)p2 )->x, MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 0 ); (int)( (XMotionEvent *)p2 )->y, 0 );
gdk_window_get_pointer( gWnd, 0, 0, 0 );*/
return true; return true;
case ButtonPress: case ButtonPress:
// Raise all the windows // Raise all the windows
/* for( list<SkinWindow *>::const_iterator win = for( list<SkinWindow *>::const_iterator win =
p_intf->p_sys->p_theme->WindowList.begin(); p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ ) win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{ {
gdk_window_raise( ( (X11Window *)(*win) )->GetHandle() ); XRaiseWindow( display, ( (X11Window *)(*win) )->GetHandle() );
} }
switch( ( (GdkEventButton *)p2 )->button ) switch( ( (XButtonEvent *)p2 )->button )
{ {
case 1: case 1:
// Left button // Left button
LButtonDown = true; LButtonDown = true;
MouseDown( (int)( (GdkEventButton *)p2 )->x, MouseDown( (int)( (XButtonEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 ); (int)( (XButtonEvent *)p2 )->y, 1 );
break; break;
case 3: case 3:
// Right button // Right button
RButtonDown = true; RButtonDown = true;
MouseDown( (int)( (GdkEventButton *)p2 )->x, MouseDown( (int)( (XButtonEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 ); (int)( (XButtonEvent *)p2 )->y, 2 );
break; break;
default: default:
break; break;
}*/ }
return true; return true;
case ButtonRelease: case ButtonRelease:
/* switch( ( (GdkEventButton *)p2 )->button ) switch( ( (XButtonEvent *)p2 )->button )
{ {
case 1: case 1:
// Left button // Left button
LButtonDown = false; LButtonDown = false;
MouseUp( (int)( (GdkEventButton *)p2 )->x, MouseUp( (int)( (XButtonEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 ); (int)( (XButtonEvent *)p2 )->y, 1 );
break; break;
case 3: case 3:
// Right button // Right button
RButtonDown = false; RButtonDown = false;
MouseUp( (int)( (GdkEventButton *)p2 )->x, MouseUp( (int)( (XButtonEvent *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 ); (int)( (XButtonEvent *)p2 )->y, 2 );
break; break;
default: default:
break; break;
}*/ }
return true; return true;
case LeaveNotify: case LeaveNotify:
...@@ -332,8 +332,7 @@ void X11Window::WindowManualMove() ...@@ -332,8 +332,7 @@ void X11Window::WindowManualMove()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Window::WindowManualMoveInit() void X11Window::WindowManualMoveInit()
{ {
/* gdk_window_get_pointer( gdk_get_default_root_window(), &CursorX, &CursorY, OSAPI_GetMousePos( CursorX, CursorY );
NULL );*/
WindowX = Left; WindowX = Left;
WindowY = Top; WindowY = Top;
} }
...@@ -343,7 +342,6 @@ void X11Window::Move( int left, int top ) ...@@ -343,7 +342,6 @@ void X11Window::Move( int left, int top )
Left = left; Left = left;
Top = top; Top = top;
XMoveWindow( display, Wnd, left, top ); XMoveWindow( display, Wnd, left, top );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Window::Size( int width, int height ) void X11Window::Size( int width, int height )
......
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