Commit 4c0e43c1 authored by Cyril Deguet's avatar Cyril Deguet

* modules/gui/skins/x11/x11_api.cpp: fixed OSAPI_GetScreenSize

* all: added locks around X calls to make them thread safe (will be
  useful in the next commit ;-)
parent 2c90cd6d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* skin_common.h: Private Skin interface description * skin_common.h: Private Skin interface description
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: skin_common.h,v 1.11 2003/06/01 16:39:49 asmax Exp $ * $Id: skin_common.h,v 1.12 2003/06/01 22:11:24 asmax 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>
...@@ -88,6 +88,7 @@ struct intf_sys_t ...@@ -88,6 +88,7 @@ struct intf_sys_t
#ifdef X11_SKINS #ifdef X11_SKINS
Display *display; Display *display;
Window mainWin; // Window which receives "broadcast" events Window mainWin; // Window which receives "broadcast" events
vlc_mutex_t xlock;
#endif #endif
#ifdef WIN32 #ifdef WIN32
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* skin-main.cpp: skins plugin for VLC * skin-main.cpp: skins plugin for VLC
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: skin_main.cpp,v 1.29 2003/06/01 16:39:49 asmax Exp $ * $Id: skin_main.cpp,v 1.30 2003/06/01 22:11:24 asmax 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>
...@@ -128,6 +128,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -128,6 +128,7 @@ static int Open ( vlc_object_t *p_this )
#elif defined X11_SKINS #elif defined X11_SKINS
// Initialize X11 // Initialize X11
p_intf->p_sys->display = XOpenDisplay( NULL ); p_intf->p_sys->display = XOpenDisplay( NULL );
vlc_mutex_init( p_intf, &p_intf->p_sys->xlock );
#elif defined WIN32 #elif defined WIN32
// We dynamically load msimg32.dll to get a pointer to TransparentBlt() // We dynamically load msimg32.dll to get a pointer to TransparentBlt()
...@@ -191,6 +192,8 @@ static void Close ( vlc_object_t *p_this ) ...@@ -191,6 +192,8 @@ static void Close ( vlc_object_t *p_this )
FreeLibrary( p_intf->p_sys->h_msimg32_dll ); FreeLibrary( p_intf->p_sys->h_msimg32_dll );
if( p_intf->p_sys->h_user32_dll ) if( p_intf->p_sys->h_user32_dll )
FreeLibrary( p_intf->p_sys->h_user32_dll ); FreeLibrary( p_intf->p_sys->h_user32_dll );
#elif defined X11_SKINS
vlc_mutex_destroy( &p_intf->p_sys->xlock );
#endif #endif
// Destroy structure // Destroy structure
......
...@@ -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.4 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_api.cpp,v 1.5 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "../src/skin_common.h" #include "../src/skin_common.h"
#include "../src/theme.h" #include "../src/theme.h"
#include "../src/window.h" #include "../src/window.h"
#include "../os_theme.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
...@@ -74,7 +75,10 @@ void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int para ...@@ -74,7 +75,10 @@ void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int para
{ {
event.xclient.window = (( X11Window *)win)->GetHandle(); event.xclient.window = (( X11Window *)win)->GetHandle();
} }
XSendEvent( g_pIntf->p_sys->display, event.xclient.window, False, 0, &event ); XLOCK;
XSendEvent( g_pIntf->p_sys->display, event.xclient.window, False, 0,
&event );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -117,8 +121,10 @@ int OSAPI_GetTime() ...@@ -117,8 +121,10 @@ int OSAPI_GetTime()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h ) void OSAPI_GetScreenSize( int &w, int &h )
{ {
/* w = GetSystemMetrics(SM_CXSCREEN); Display *display = g_pIntf->p_sys->display;
h = GetSystemMetrics(SM_CYSCREEN);*/ int screen = DefaultScreen( display );
w = DisplayWidth( display, screen );
h = DisplayHeight( display, screen );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y ) void OSAPI_GetMousePos( int &x, int &y )
...@@ -129,8 +135,10 @@ void OSAPI_GetMousePos( int &x, int &y ) ...@@ -129,8 +135,10 @@ void OSAPI_GetMousePos( int &x, int &y )
unsigned int xmask; unsigned int xmask;
Window root = DefaultRootWindow( g_pIntf->p_sys->display ); Window root = DefaultRootWindow( g_pIntf->p_sys->display );
XLOCK;
XQueryPointer( g_pIntf->p_sys->display, root, &rootReturn, &childReturn, XQueryPointer( g_pIntf->p_sys->display, root, &rootReturn, &childReturn,
&rootx, &rooty, &winx, &winy, &xmask ); &rootx, &rooty, &winx, &winy, &xmask );
XUNLOCK;
x = rootx; x = rootx;
y = rooty; y = rooty;
} }
......
...@@ -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.8 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_bitmap.cpp,v 1.9 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -74,6 +74,7 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor ) ...@@ -74,6 +74,7 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) | AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) |
(AColor & 0xff0000) >> 16; (AColor & 0xff0000) >> 16;
XLOCK;
imlib_context_set_display( display ); imlib_context_set_display( display );
imlib_context_set_visual( visual ); imlib_context_set_visual( visual );
imlib_context_set_colormap( DefaultColormap( display, screen ) ); imlib_context_set_colormap( DefaultColormap( display, screen ) );
...@@ -107,6 +108,7 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor ) ...@@ -107,6 +108,7 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
imlib_image_set_has_alpha( 1 ); imlib_image_set_has_alpha( 1 );
imlib_image_set_irrelevant_alpha( 0 ); imlib_image_set_irrelevant_alpha( 0 );
imlib_image_put_back_data( data ); imlib_image_put_back_data( data );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y, X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
...@@ -151,8 +153,10 @@ X11Bitmap::~X11Bitmap() ...@@ -151,8 +153,10 @@ X11Bitmap::~X11Bitmap()
{ {
if( Img ) if( Img )
{ {
XLOCK;
imlib_context_set_image( Img ); imlib_context_set_image( Img );
imlib_free_image(); imlib_free_image();
XUNLOCK;
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -161,10 +165,12 @@ void X11Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef, ...@@ -161,10 +165,12 @@ void X11Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
{ {
if( Img ) if( Img )
{ {
XLOCK;
Drawable destImg = ( (X11Graphics *)dest )->GetImage(); Drawable destImg = ( (X11Graphics *)dest )->GetImage();
imlib_context_set_image( Img ); imlib_context_set_image( Img );
imlib_context_set_drawable( destImg ); imlib_context_set_drawable( destImg );
imlib_render_image_part_on_drawable_at_size( x, y, w, h, xRef, yRef, w, h ); imlib_render_image_part_on_drawable_at_size( x, y, w, h, xRef, yRef, w, h );
XUNLOCK;
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -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.4 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_font.cpp,v 1.5 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -36,9 +36,8 @@ ...@@ -36,9 +36,8 @@
#include "../os_graphics.h" #include "../os_graphics.h"
#include "../src/font.h" #include "../src/font.h"
#include "../os_font.h" #include "../os_font.h"
#include "../src/theme.h"
// FIXME ... #include "../os_theme.h"
extern intf_thread_t *g_pIntf;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Font object // Font object
...@@ -50,7 +49,9 @@ X11Font::X11Font( intf_thread_t *_p_intf, string fontname, int size, ...@@ -50,7 +49,9 @@ X11Font::X11Font( intf_thread_t *_p_intf, string fontname, int size,
display = g_pIntf->p_sys->display; display = g_pIntf->p_sys->display;
// FIXME: just a beginning... // FIXME: just a beginning...
XLOCK;
font = XLoadFont( display, "-misc-fixed-*-*-*-*-*-*-*-*-*-*-*-*" ); font = XLoadFont( display, "-misc-fixed-*-*-*-*-*-*-*-*-*-*-*-*" );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Font::~X11Font() X11Font::~X11Font()
...@@ -66,8 +67,10 @@ void X11Font::GetSize( string text, int &w, int &h ) ...@@ -66,8 +67,10 @@ void X11Font::GetSize( string text, int &w, int &h )
int direction, fontAscent, fontDescent; int direction, fontAscent, fontDescent;
XCharStruct overall; XCharStruct overall;
XQueryTextExtents( display, font, text.c_str(), text.size(), &direction, XLOCK;
&fontAscent, &fontDescent, &overall ); XQueryTextExtents( display, font, text.c_str(), text.size(),
&direction, &fontAscent, &fontDescent, &overall );
XUNLOCK;
w = overall.rbearing - overall.lbearing; w = overall.rbearing - overall.lbearing;
h = overall.ascent + overall.descent; h = overall.ascent + overall.descent;
...@@ -83,10 +86,13 @@ void X11Font::GenericPrint( Graphics *dest, string text, int x, int y, ...@@ -83,10 +86,13 @@ void X11Font::GenericPrint( Graphics *dest, string text, int x, int y,
XGCValues gcVal; XGCValues gcVal;
gcVal.foreground = (color == 0 ? 10 : color); gcVal.foreground = (color == 0 ? 10 : color);
gcVal.font = font; gcVal.font = font;
XChangeGC( display, gc, GCForeground|GCFont, &gcVal );
// Render text on buffer // Render text on buffer
XDrawString( display, drawable, gc, x, y+h, text.c_str(), text.size()); XLOCK;
XChangeGC( display, gc, GCForeground|GCFont, &gcVal );
XDrawString( display, drawable, gc, x, y+h, text.c_str(),
text.size());
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_graphics.cpp: X11 implementation of the Graphics and Region classes * x11_graphics.cpp: X11 implementation of the Graphics and Region classes
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_graphics.cpp,v 1.5 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_graphics.cpp,v 1.6 2003/06/01 22:11:24 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>
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "../src/graphics.h" #include "../src/graphics.h"
#include "../src/window.h" #include "../src/window.h"
#include "../os_window.h" #include "../os_window.h"
#include "../src/theme.h"
#include "../os_theme.h"
#include "x11_graphics.h" #include "x11_graphics.h"
#include "../src/skin_common.h" #include "../src/skin_common.h"
...@@ -55,36 +57,45 @@ X11Graphics::X11Graphics( intf_thread_t *p_intf, int w, int h, ...@@ -55,36 +57,45 @@ X11Graphics::X11Graphics( intf_thread_t *p_intf, int w, int h,
Window fromWnd = ( (X11Window *)from )->GetHandle(); Window fromWnd = ( (X11Window *)from )->GetHandle();
XWindowAttributes attr; XWindowAttributes attr;
XLOCK;
XGetWindowAttributes( display, fromWnd, &attr); XGetWindowAttributes( display, fromWnd, &attr);
Image = XCreatePixmap( display, fromWnd, w, h, attr.depth ); Image = XCreatePixmap( display, fromWnd, w, h, attr.depth );
XUNLOCK;
Gc = DefaultGC( display, screen ); Gc = DefaultGC( display, screen );
} }
else else
{ {
Window root = DefaultRootWindow( display ); Window root = DefaultRootWindow( display );
XLOCK;
Image = XCreatePixmap( display, root, w, h, Image = XCreatePixmap( display, root, w, h,
DefaultDepth( display, screen ) ); DefaultDepth( display, screen ) );
XUNLOCK;
Gc = DefaultGC( display, screen ); Gc = DefaultGC( display, screen );
} }
// Set the background color to black // Set the background color to black
XGCValues gcVal; XGCValues gcVal;
gcVal.foreground = 0; gcVal.foreground = 0;
XLOCK;
XChangeGC( display, Gc, GCForeground, &gcVal ); XChangeGC( display, Gc, GCForeground, &gcVal );
XFillRectangle( display, Image, Gc, 0, 0, w, h ); XFillRectangle( display, Image, Gc, 0, 0, w, h );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Graphics::~X11Graphics() X11Graphics::~X11Graphics()
{ {
XLOCK;
XFreePixmap( display, Image ); XFreePixmap( display, Image );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src, void X11Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
int sx, int sy, int Flag ) int sx, int sy, int Flag )
{ {
XLOCK;
XCopyArea( display, (( X11Graphics* )Src )->GetImage(), Image, Gc, XCopyArea( display, (( X11Graphics* )Src )->GetImage(), Image, Gc,
sx, sy, dw, dh, dx, dy ); sx, sy, dw, dh, dx, dy );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Graphics::DrawRect( int x, int y, int w, int h, int color ) void X11Graphics::DrawRect( int x, int y, int w, int h, int color )
......
...@@ -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.12 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_run.cpp,v 1.13 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -276,10 +276,19 @@ void OSRun( intf_thread_t *p_intf ) ...@@ -276,10 +276,19 @@ void OSRun( intf_thread_t *p_intf )
while( !close ) while( !close )
{ {
XEvent event; XEvent event;
while( !close && XPending( display ) > 0 ) int nPending;
XLOCK;
nPending = XPending( display );
XUNLOCK;
while( !close && nPending > 0 )
{ {
XLOCK;
XNextEvent( display, &event ); XNextEvent( display, &event );
XUNLOCK;
close = ProcessEvent( p_intf, proc, &event ); close = ProcessEvent( p_intf, proc, &event );
XLOCK;
nPending = XPending( display );
XUNLOCK;
} }
msleep( 1000 ); msleep( 1000 );
......
...@@ -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.8 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_theme.cpp,v 1.9 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -90,9 +90,11 @@ void X11Theme::OnLoadTheme() ...@@ -90,9 +90,11 @@ void X11Theme::OnLoadTheme()
CreateSystemMenu(); CreateSystemMenu();
*/ */
Window root = DefaultRootWindow( display ); Window root = DefaultRootWindow( display );
p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0, 1, 1, XLOCK;
0, 0, 0 ); p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0,
1, 1, 0, 0, 0 );
XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" ); XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Theme::AddSystemMenu( string name, Event *event ) void X11Theme::AddSystemMenu( string name, Event *event )
...@@ -110,7 +112,9 @@ void X11Theme::AddSystemMenu( string name, Event *event ) ...@@ -110,7 +112,9 @@ void X11Theme::AddSystemMenu( string name, Event *event )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Theme::ChangeClientWindowName( string name ) void X11Theme::ChangeClientWindowName( string name )
{ {
XLOCK;
XStoreName( display, p_intf->p_sys->mainWin, name.c_str() ); XStoreName( display, p_intf->p_sys->mainWin, name.c_str() );
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Theme::AddWindow( string name, int x, int y, bool visible, void X11Theme::AddWindow( string name, int x, int y, bool visible,
...@@ -119,11 +123,14 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -119,11 +123,14 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
// Create the window // Create the window
Window root = DefaultRootWindow( display ); Window root = DefaultRootWindow( display );
XSetWindowAttributes attr; XSetWindowAttributes attr;
XLOCK;
Window wnd = XCreateWindow( display, root, 0, 0, 1, 1, 0, 0, InputOutput, Window wnd = XCreateWindow( display, root, 0, 0, 1, 1, 0, 0, InputOutput,
CopyFromParent, 0, &attr ); CopyFromParent, 0, &attr );
XSelectInput( display, wnd, ExposureMask|StructureNotifyMask| XSelectInput( display, wnd, ExposureMask|StructureNotifyMask|
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask| KeyPressMask|KeyReleaseMask|ButtonPressMask|
PointerMotionMask|EnterWindowMask|LeaveWindowMask); ButtonReleaseMask|PointerMotionMask|EnterWindowMask|
LeaveWindowMask);
XUNLOCK;
// Changing decorations // Changing decorations
struct { struct {
...@@ -138,6 +145,7 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -138,6 +145,7 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS; motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS;
motifWmHints.decorations = 0; motifWmHints.decorations = 0;
XLOCK;
XChangeProperty( display, wnd, hints_atom, hints_atom, 32, XChangeProperty( display, wnd, hints_atom, hints_atom, 32,
PropModeReplace, (unsigned char *)&motifWmHints, PropModeReplace, (unsigned char *)&motifWmHints,
sizeof( motifWmHints ) / sizeof( long ) ); sizeof( motifWmHints ) / sizeof( long ) );
...@@ -153,6 +161,7 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -153,6 +161,7 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
{ {
XNextEvent( display, &evt ); XNextEvent( display, &evt );
} while( evt.type != MapNotify ); } while( evt.type != MapNotify );
XUNLOCK;
WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y, WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y,
visible, fadetime, alpha, movealpha, dragdrop, name ) ) ; visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_theme.h: X11 implementation of the Theme class * x11_theme.h: X11 implementation of the Theme class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_theme.h,v 1.2 2003/06/01 16:39:49 asmax Exp $ * $Id: x11_theme.h,v 1.3 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -33,6 +33,12 @@ using namespace std; ...@@ -33,6 +33,12 @@ using namespace std;
//--- X11 ------------------------------------------------------------------- //--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h> #include <X11/Xlib.h>
// macros to make X calls thread safe
extern intf_thread_t *g_pIntf;
#define XLOCK vlc_mutex_lock( &g_pIntf->p_sys->xlock )
#define XUNLOCK vlc_mutex_unlock( &g_pIntf->p_sys->xlock )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
struct intf_thread_t; struct intf_thread_t;
class SkinWindow; class SkinWindow;
...@@ -40,6 +46,7 @@ class EventBank; ...@@ -40,6 +46,7 @@ class EventBank;
class BitmapBank; class BitmapBank;
class FontBank; class FontBank;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class X11Theme : public Theme class X11Theme : public Theme
{ {
......
...@@ -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.8 2003/06/01 17:13:04 asmax Exp $ * $Id: x11_window.cpp,v 1.9 2003/06/01 22:11:24 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "../os_graphics.h" #include "../os_graphics.h"
#include "../src/skin_common.h" #include "../src/skin_common.h"
#include "../src/theme.h" #include "../src/theme.h"
#include "../os_theme.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -112,10 +113,6 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y, ...@@ -112,10 +113,6 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
attr.wclass = GDK_INPUT_OUTPUT; attr.wclass = GDK_INPUT_OUTPUT;
gint mask = 0; gint mask = 0;
ToolTipWindow = gdk_window_new( gwnd, &attr, mask);*/ ToolTipWindow = gdk_window_new( gwnd, &attr, mask);*/
Open();
//fprintf(stderr, "kludge in x11_window.cpp\n");
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Window::~X11Window() X11Window::~X11Window()
...@@ -149,13 +146,16 @@ void X11Window::OSShow( bool show ) ...@@ -149,13 +146,16 @@ void X11Window::OSShow( bool show )
{ {
if( show ) if( show )
{ {
XLOCK;
XMapWindow( display, Wnd ); XMapWindow( display, Wnd );
XMoveWindow( display, Wnd, Left, Top ); XMoveWindow( display, Wnd, Left, Top );
XUNLOCK;
} }
else else
{ {
//XWithdrawWindow( display, Wnd, 0 ); XLOCK;
XUnmapWindow( display, Wnd ); XUnmapWindow( display, Wnd );
XUNLOCK;
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -190,7 +190,9 @@ bool X11Window::ProcessOSEvent( Event *evt ) ...@@ -190,7 +190,9 @@ bool X11Window::ProcessOSEvent( Event *evt )
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++ )
{ {
XLOCK;
XRaiseWindow( display, ( (X11Window *)(*win) )->GetHandle() ); XRaiseWindow( display, ( (X11Window *)(*win) )->GetHandle() );
XUNLOCK;
} }
switch( ( (XButtonEvent *)p2 )->button ) switch( ( (XButtonEvent *)p2 )->button )
...@@ -280,6 +282,7 @@ void X11Window::RefreshFromImage( int x, int y, int w, int h ) ...@@ -280,6 +282,7 @@ void X11Window::RefreshFromImage( int x, int y, int w, int h )
{ {
Drawable drawable = (( X11Graphics* )Image )->GetImage(); Drawable drawable = (( X11Graphics* )Image )->GetImage();
XLOCK;
XCopyArea( display, drawable, Wnd, Gc, x, y, w, h, x, y ); XCopyArea( display, drawable, Wnd, Gc, x, y, w, h, x, y );
XImage *image = XGetImage( display, drawable, 0, 0, Width, Height, XImage *image = XGetImage( display, drawable, 0, 0, Width, Height,
...@@ -317,6 +320,7 @@ void X11Window::RefreshFromImage( int x, int y, int w, int h ) ...@@ -317,6 +320,7 @@ void X11Window::RefreshFromImage( int x, int y, int w, int h )
XDestroyRegion( region ); XDestroyRegion( region );
XSync( display, 0); XSync( display, 0);
XUNLOCK;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Window::WindowManualMove() void X11Window::WindowManualMove()
......
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