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 @@
* x11_api.cpp: Various x11-specific functions
*****************************************************************************
* 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>
*
......@@ -28,12 +28,14 @@
#include <X11/Xlib.h>
//--- SKIN ------------------------------------------------------------------
#include <vlc/intf.h>
#include "../src/skin_common.h"
#include "../src/window.h"
#include "../os_window.h"
#include "../os_api.h"
#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
......@@ -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,
long param2 )
{
/* GdkEventClient *event = new GdkEventClient;
XEvent event;
event->type = GDK_CLIENT_EVENT;
event.type = ClientMessage;
event.xclient.display = g_pIntf->p_sys->display;
if( win == NULL )
event->window = NULL;
event.xclient.window = NULL;
else
event->window = (( Window )win)->GetHandle();
event->send_event = 0;
event->message_type = NULL;
event->data_format = 32;
event->data.l[0] = message;
event->data.l[1] = param1;
event->data.l[2] = param2;
gdk_event_put( (GdkEvent *)event );
delete event;*/
event.xclient.window = (( X11Window *)win)->GetHandle();
event.xclient.send_event = 0;
event.xclient.message_type = NULL;
event.xclient.format = 32;
event.xclient.data.l[0] = message;
event.xclient.data.l[1] = param1;
event.xclient.data.l[2] = param2;
XSendEvent( g_pIntf->p_sys->display, event.xclient.window, False, 0, &event );
}
//---------------------------------------------------------------------------
......@@ -117,12 +116,21 @@ void OSAPI_GetScreenSize( int &w, int &h )
//---------------------------------------------------------------------------
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 )
{
/* return ( (GTK2Window *)win )->GetName();*/
return ( (X11Window *)win )->GetName();
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
......
......@@ -2,7 +2,7 @@
* x11_bitmap.cpp: X11 implementation of the Bitmap class
*****************************************************************************
* 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>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -206,7 +206,6 @@ char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor,
dataSize = U32( headers + 34 );
nColors = U32( headers + 50 );
fprintf(stderr,"image %s %x\n", fileName.c_str(), AColor);
switch( bpp )
{
case 24:
......
......@@ -2,7 +2,7 @@
* x11_event.cpp: x11 implementation of the Event class
*****************************************************************************
* 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>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -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,
unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
{
// gWnd = ( (X11Window *)win )->GetHandle();
Wnd = ( (X11Window *)win )->GetHandle();
}
//---------------------------------------------------------------------------
X11Event::~X11Event()
......@@ -70,15 +70,15 @@ X11Event::~X11Event()
//---------------------------------------------------------------------------
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;
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( gWnd == ( (X11Window *)(*win) )->GetHandle() )
if( Wnd == ( (X11Window *)(*win) )->GetHandle() )
{
OSAPI_PostMessage( *win, Message, Param1, Param2 );
PostSynchroMessage();
......@@ -88,40 +88,40 @@ bool X11Event::SendEvent()
OSAPI_PostMessage( NULL, Message, Param1, Param2 );
return true;
}
*/
return false;
}
//---------------------------------------------------------------------------
bool X11Event::IsEqual( Event *evt )
{
/* X11Event *GTKEvt = (X11Event *)evt;
return( GTKEvt->GetWindow() == gWnd && GTKEvt->GetMessage() == Message &&
GTKEvt->GetParam1() == Param1 && GTKEvt->GetParam2() == Param2 );*/
X11Event *XEvt = (X11Event *)evt;
return( XEvt->GetWindow() == Wnd && XEvt->GetMessage() == Message &&
XEvt->GetParam1() == Param1 && XEvt->GetParam2() == Param2 );
}
//---------------------------------------------------------------------------
void X11Event::CreateOSEvent( string para1, string para2, string para3 )
{
// Find Parameters
/* switch( Message )
switch( Message )
{
case WINDOW_MOVE:
gWnd = GetWindowFromName( para1 );
Wnd = GetWindowFromName( para1 );
break;
case WINDOW_CLOSE:
gWnd = GetWindowFromName( para1 );
Wnd = GetWindowFromName( para1 );
break;
case WINDOW_OPEN:
gWnd = GetWindowFromName( para1 );
Wnd = GetWindowFromName( para1 );
break;
}*/
}
}
//---------------------------------------------------------------------------
Window X11Event::GetWindowFromName( string name )
{
/* X11Window *win = (X11Window *)
X11Window *win = (X11Window *)
p_intf->p_sys->p_theme->GetWindow( name );
if( win == NULL )
......@@ -131,7 +131,7 @@ Window X11Event::GetWindowFromName( string name )
else
{
return win->GetHandle();
}*/
}
}
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* x11_font.cpp: X11 implementation of the Font class
*****************************************************************************
* 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>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -91,8 +91,8 @@ void X11Font::AssignFont( Graphics *dest )
//---------------------------------------------------------------------------
void X11Font::GetSize( string text, int &w, int &h )
{
w = 0;
h = 0;
w = 42;
h = 12;
/* pango_layout_set_text( Layout, text.c_str(), text.length() );
pango_layout_get_pixel_size( Layout, &w, &h );*/
}
......
......@@ -2,7 +2,7 @@
* x11_run.cpp:
*****************************************************************************
* 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>
*
......@@ -53,6 +53,8 @@
// include the icon graphic
#include "share/vlc32x32.xpm"
#include <unistd.h>
//---------------------------------------------------------------------------
// Specific method
......@@ -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
......@@ -257,12 +248,11 @@ void ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
// Skin event
if( event->type == ClientMessage )
{
/* msg = ( (GdkEventClient *)event )->data.l[0];
msg = ( (XClientMessageEvent *)event )->data.l[0];
evt = (Event *)new OSEvent( p_intf,
((GdkEventAny *)event)->window,
msg,
( (GdkEventClient *)event )->data.l[1],
( (GdkEventClient *)event )->data.l[2] );*/
((XAnyEvent *)event)->window, msg,
( (XClientMessageEvent *)event )->data.l[1],
( (XClientMessageEvent *)event )->data.l[2] );
}
// System event
else
......@@ -357,18 +347,25 @@ void OSRun( intf_thread_t *p_intf )
/* wxTheApp = new Instance( p_intf, callbackobj );
wxEntry( 1, p_args );*/
Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay();
// Main event loop
int count = 0;
while( 1 )
{
XEvent *event;
XNextEvent( display, event );
ProcessEvent( p_intf, proc, event );
// kludge: add timer
// SkinManage( p_intf );
XEvent event;
while( XPending( display ) > 0 )
{
XNextEvent( display, &event );
ProcessEvent( p_intf, proc, &event );
}
usleep( 1000 );
if( ++count == 100 )
{
count = 0;
SkinManage( p_intf ); // Call every 100 ms
}
}
}
......
......@@ -2,7 +2,7 @@
* x11_theme.cpp: X11 implementation of the Theme class
*****************************************************************************
* 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>
*
......@@ -169,8 +169,9 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
Window root = DefaultRootWindow( display );
Window wnd = XCreateSimpleWindow( display, root, 0, 0, 1, 1, 0, 0, 0 );
XSelectInput( display, wnd, ExposureMask|
KeyPressMask|KeyReleaseMask|ButtonPressMask|PointerMotionMask|
PointerMotionHintMask| EnterWindowMask|LeaveWindowMask);
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|
PointerMotionMask|PointerMotionHintMask|EnterWindowMask|
LeaveWindowMask);
// Changing decorations
struct {
......
......@@ -2,7 +2,7 @@
* x11_window.cpp: X11 implementation of the Window class
*****************************************************************************
* 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>
*
......@@ -148,6 +148,7 @@ void X11Window::OSShow( bool show )
{
/* gdk_window_show( gWnd );
gdk_window_move( gWnd, Left, Top );*/
XMoveWindow( display, Wnd, Left, Top );
}
else
{
......@@ -160,7 +161,7 @@ bool X11Window::ProcessOSEvent( Event *evt )
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
switch( msg )
{
case Expose:
......@@ -168,69 +169,68 @@ bool X11Window::ProcessOSEvent( Event *evt )
return true;
case MotionNotify:
/* if( LButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 );
if( LButtonDown )
MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (XMotionEvent *)p2 )->y, 1 );
else if( RButtonDown )
MouseMove( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 );
MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (XMotionEvent *)p2 )->y, 2 );
else
MouseMove( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 0 );
gdk_window_get_pointer( gWnd, 0, 0, 0 );*/
MouseMove( (int)( (XMotionEvent *)p2 )->x,
(int)( (XMotionEvent *)p2 )->y, 0 );
return true;
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++ )
{
gdk_window_raise( ( (X11Window *)(*win) )->GetHandle() );
XRaiseWindow( display, ( (X11Window *)(*win) )->GetHandle() );
}
switch( ( (GdkEventButton *)p2 )->button )
switch( ( (XButtonEvent *)p2 )->button )
{
case 1:
// Left button
LButtonDown = true;
MouseDown( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 );
MouseDown( (int)( (XButtonEvent *)p2 )->x,
(int)( (XButtonEvent *)p2 )->y, 1 );
break;
case 3:
// Right button
RButtonDown = true;
MouseDown( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 );
MouseDown( (int)( (XButtonEvent *)p2 )->x,
(int)( (XButtonEvent *)p2 )->y, 2 );
break;
default:
break;
}*/
}
return true;
case ButtonRelease:
/* switch( ( (GdkEventButton *)p2 )->button )
switch( ( (XButtonEvent *)p2 )->button )
{
case 1:
// Left button
LButtonDown = false;
MouseUp( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 1 );
MouseUp( (int)( (XButtonEvent *)p2 )->x,
(int)( (XButtonEvent *)p2 )->y, 1 );
break;
case 3:
// Right button
RButtonDown = false;
MouseUp( (int)( (GdkEventButton *)p2 )->x,
(int)( (GdkEventButton *)p2 )->y, 2 );
MouseUp( (int)( (XButtonEvent *)p2 )->x,
(int)( (XButtonEvent *)p2 )->y, 2 );
break;
default:
break;
}*/
}
return true;
case LeaveNotify:
......@@ -332,8 +332,7 @@ void X11Window::WindowManualMove()
//---------------------------------------------------------------------------
void X11Window::WindowManualMoveInit()
{
/* gdk_window_get_pointer( gdk_get_default_root_window(), &CursorX, &CursorY,
NULL );*/
OSAPI_GetMousePos( CursorX, CursorY );
WindowX = Left;
WindowY = Top;
}
......@@ -343,7 +342,6 @@ void X11Window::Move( int left, int top )
Left = left;
Top = top;
XMoveWindow( display, Wnd, left, top );
}
//---------------------------------------------------------------------------
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