Commit f574db49 authored by Cyril Deguet's avatar Cyril Deguet

* X11 skins now use imlib2 -> you need to bootstrap

  wxwindows dialogs are not supposed to work yet, if they do you are
  lucky ;)
parent e950e338
...@@ -1706,8 +1706,6 @@ dnl MP4 module ...@@ -1706,8 +1706,6 @@ dnl MP4 module
dnl dnl
AC_CHECK_HEADERS(zlib.h, [ AC_CHECK_HEADERS(zlib.h, [
LDFLAGS_mp4="${LDFLAGS_mp4} -lz" LDFLAGS_mp4="${LDFLAGS_mp4} -lz"
LDFLAGS_skins="${LDFLAGS_skins} -lz"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lz"
] ) ] )
...@@ -2440,9 +2438,11 @@ if test "x${enable_skins}" != "xno"; then ...@@ -2440,9 +2438,11 @@ if test "x${enable_skins}" != "xno"; then
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS" CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ ${GTK2_LIBS}" LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ ${GTK2_LIBS}"
else else
IMLIB2_PATH="${PATH}"
AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
PLUGINS="${PLUGINS} skins" PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} -DX11_SKINS" CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ -L${x_libraries} -lXext -lX11" LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ -L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`"
fi fi
PLUGINS="${PLUGINS} skins" PLUGINS="${PLUGINS} skins"
...@@ -2471,8 +2471,10 @@ if test "x${enable_basic_skins}" = "xyes"; then ...@@ -2471,8 +2471,10 @@ if test "x${enable_basic_skins}" = "xyes"; then
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS" CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ ${GTK2_LIBS}" LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ ${GTK2_LIBS}"
else else
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} -DX11_SKINS" IMLIB2_PATH="${PATH}"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ -L${x_libraries} -lXext -lX11" AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ -L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`"
fi fi
fi fi
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlcproc.cpp: VlcProc class * vlcproc.cpp: VlcProc class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.26 2003/05/29 16:48:29 asmax Exp $ * $Id: vlcproc.cpp,v 1.27 2003/05/29 21:40:27 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>
...@@ -102,7 +102,10 @@ bool VlcProc::EventProc( Event *evt ) ...@@ -102,7 +102,10 @@ bool VlcProc::EventProc( Event *evt )
return true; return true;
case VLC_OPEN: case VLC_OPEN:
// FIXME: just for testing
wxMutexGuiEnter();
OpenFile( true ); OpenFile( true );
wxMutexGuiLeave();
return true; return true;
case VLC_LOAD_SKIN: case VLC_LOAD_SKIN:
...@@ -134,26 +137,38 @@ bool VlcProc::EventProc( Event *evt ) ...@@ -134,26 +137,38 @@ bool VlcProc::EventProc( Event *evt )
return true; return true;
case VLC_PLAYLIST_ADD_FILE: case VLC_PLAYLIST_ADD_FILE:
// FIXME: just for testing
wxMutexGuiEnter();
OpenFile( false ); OpenFile( false );
wxMutexGuiLeave();
return true; return true;
#ifndef BASIC_SKINS #ifndef BASIC_SKINS
case VLC_LOG_SHOW: case VLC_LOG_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->MessagesDlg->Show( p_intf->p_sys->MessagesDlg->Show(
!p_intf->p_sys->MessagesDlg->IsShown() ); !p_intf->p_sys->MessagesDlg->IsShown() );
wxMutexGuiLeave();
return true; return true;
case VLC_LOG_CLEAR: case VLC_LOG_CLEAR:
return true; return true;
case VLC_PREFS_SHOW: case VLC_PREFS_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->PrefsDlg->Show( p_intf->p_sys->PrefsDlg->Show(
!p_intf->p_sys->PrefsDlg->IsShown() ); !p_intf->p_sys->PrefsDlg->IsShown() );
wxMutexGuiLeave();
return true; return true;
case VLC_INFO_SHOW: case VLC_INFO_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->InfoDlg->Show( p_intf->p_sys->InfoDlg->Show(
!p_intf->p_sys->InfoDlg->IsShown() ); !p_intf->p_sys->InfoDlg->IsShown() );
wxMutexGuiLeave();
return true; return true;
#endif #endif
...@@ -394,13 +409,7 @@ void VlcProc::LoadSkin() ...@@ -394,13 +409,7 @@ void VlcProc::LoadSkin()
void VlcProc::OpenFile( bool play ) void VlcProc::OpenFile( bool play )
{ {
#ifndef BASIC_SKINS #ifndef BASIC_SKINS
int iRc; if( p_intf->p_sys->OpenDlg->ShowModal() != wxID_OK )
// FIXME: just for testing
wxMutexGuiEnter();
iRc = p_intf->p_sys->OpenDlg->ShowModal();
wxMutexGuiLeave();
if( iRc != wxID_OK )
{ {
return; return;
} }
...@@ -414,7 +423,6 @@ void VlcProc::OpenFile( bool play ) ...@@ -414,7 +423,6 @@ void VlcProc::OpenFile( bool play )
if( play ) if( play )
{ {
wxMutexGuiEnter();
// Append and play // Append and play
for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ ) for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ )
{ {
...@@ -422,13 +430,10 @@ void VlcProc::OpenFile( bool play ) ...@@ -422,13 +430,10 @@ void VlcProc::OpenFile( bool play )
(const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(), (const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END ); PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
} }
wxMutexGuiLeave();
p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent(); p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
} }
else else
{ {
wxMutexGuiEnter();
// Append only // Append only
for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ ) for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ )
{ {
...@@ -436,7 +441,6 @@ void VlcProc::OpenFile( bool play ) ...@@ -436,7 +441,6 @@ void VlcProc::OpenFile( bool play )
(const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(), (const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND, PLAYLIST_END ); PLAYLIST_APPEND, PLAYLIST_END );
} }
wxMutexGuiLeave();
} }
// Refresh interface ! // Refresh interface !
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
* 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.6 2003/05/24 21:28:29 asmax Exp $ * $Id: x11_bitmap.cpp,v 1.7 2003/05/29 21:40:27 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -28,6 +27,7 @@ ...@@ -28,6 +27,7 @@
//--- X11 ------------------------------------------------------------------- //--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <Imlib2.h>
//--- VLC ------------------------------------------------------------------- //--- VLC -------------------------------------------------------------------
#include <vlc/intf.h> #include <vlc/intf.h>
...@@ -62,24 +62,51 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor ) ...@@ -62,24 +62,51 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
int depth = DefaultDepth( display, screen ); int depth = DefaultDepth( display, screen );
Screen *screenptr = DefaultScreenOfDisplay( display ); Screen *screenptr = DefaultScreenOfDisplay( display );
Visual *visual = DefaultVisualOfScreen( screenptr ); Visual *visual = DefaultVisualOfScreen( screenptr );
char *data = NULL; Img = NULL;
Width = 0; Width = 0;
Height = 0; Height = 0;
// TODO: check for endianness issues if( FileName == "" )
{
return;
}
AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) | AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) |
(AColor & 0xff0000) >> 16; (AColor & 0xff0000) >> 16;
if( FileName != "" ) imlib_context_set_display( display );
imlib_context_set_visual( visual );
imlib_context_set_colormap( DefaultColormap( display, screen ) );
imlib_context_set_dither( 1 );
imlib_context_set_blend( 1 );
Img = imlib_load_image_immediately( FileName.c_str() );
imlib_context_set_image( Img );
Width = imlib_image_get_width();
Height = imlib_image_get_height();
// Add an alpha layer
DATA32 *data = imlib_image_get_data();
DATA32 *ptr = data;
for( int j = 0; j < Height; j++)
{
for( int i = 0; i < Width; i++)
{
if( AlphaColor != 0 && *ptr == 0xff000000 )
{ {
data = LoadFromFile( FileName, depth, AlphaColor, Width, Height ); // Avoid transparency for black pixels
*ptr = 0xff00000c;
} }
else if( (*ptr & 0xffffff) == AlphaColor )
// Create the image {
Bmp = XCreateImage( display, visual, depth, ZPixmap, 0, data, Width, *ptr &= 0x00ffffff;
Height, 32, 4 * Width ); }
XInitImage( Bmp ); ptr++;
}
}
imlib_image_set_has_alpha( 1 );
imlib_image_set_irrelevant_alpha( 0 );
imlib_image_put_back_data( data );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
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,
...@@ -122,15 +149,23 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Bitmap *c ) ...@@ -122,15 +149,23 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Bitmap *c )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
X11Bitmap::~X11Bitmap() X11Bitmap::~X11Bitmap()
{ {
XDestroyImage( Bmp ); if( Img )
{
imlib_context_set_image( Img );
imlib_free_image();
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void X11Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef, void X11Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest ) Graphics *dest )
{ {
if( Img )
{
Drawable destImg = ( (X11Graphics *)dest )->GetImage(); Drawable destImg = ( (X11Graphics *)dest )->GetImage();
GC destGC = ( (X11Graphics *)dest )->GetGC(); imlib_context_set_image( Img );
XPutImage( display, destImg, destGC, Bmp, x, y, xRef, yRef, w, h ); imlib_context_set_drawable( destImg );
imlib_render_image_part_on_drawable_at_size( x, y, w, h, xRef, yRef, w, h );
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool X11Bitmap::Hit( int x, int y) bool X11Bitmap::Hit( int x, int y)
...@@ -145,7 +180,7 @@ bool X11Bitmap::Hit( int x, int y) ...@@ -145,7 +180,7 @@ bool X11Bitmap::Hit( int x, int y)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int X11Bitmap::GetBmpPixel( int x, int y ) int X11Bitmap::GetBmpPixel( int x, int y )
{ {
if( !Bmp || x < 0 || x >= Width || y < 0 || y >= Height ) if( !Img || x < 0 || x >= Width || y < 0 || y >= Height )
return -1; return -1;
return 42; return 42;
...@@ -171,81 +206,5 @@ void X11Bitmap::SetBmpPixel( int x, int y, int color ) ...@@ -171,81 +206,5 @@ void X11Bitmap::SetBmpPixel( int x, int y, int color )
// SetPixelV( bmpDC, x, y, color ); // SetPixelV( bmpDC, x, y, color );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor,
int &width, int &height )
{
// BMP header fields
uint32_t fileSize;
uint32_t dataOffset;
uint32_t headerSize;
uint16_t planes;
uint16_t bpp;
uint32_t compression;
uint32_t dataSize;
uint32_t nColors;
FILE *file = fopen( fileName.c_str(), "ro" );
if( !file )
{
msg_Warn( p_intf, "Cannot open %s", fileName.c_str() );
return NULL;
}
// Read the headers
char headers[54];
fread( headers, 54, 1, file );
fileSize = U32( headers + 2 );
dataOffset = U32( headers + 10 );
headerSize = U32( headers + 14 );
width = (int32_t) U32( headers + 18 );
height = (int32_t) U32( headers + 22 );
planes = U32( headers + 26 );
bpp = U32( headers + 28 );
compression = U32( headers + 30 );
dataSize = U32( headers + 34 );
nColors = U32( headers + 50 );
switch( bpp )
{
case 24:
// 24 bits per pixel
{
// Pad to a 32bit boundary
int pad = ((3 * width - 1) / 4) * 4 + 4 - 3 * width;
uint32_t *data = new uint32_t[height * width];
uint32_t *ptr;
for( int j = 0; j < height; j++ )
{
ptr = data + width * (height - j - 1);
for( int i = 0; i < width; i++ )
{
// Read a pixel
uint32_t pixel = 0;
fread( &pixel, 3, 1, file );
pixel = U32( &pixel );
// Handle transparency
if( pixel == 0 && AColor != 0 )
{
pixel = 10; // slight blue
}
else if( pixel == AColor )
{
pixel = 0; // global alpha color is black
}
*(ptr++) = pixel;
}
fseek( file, pad, SEEK_CUR );
}
return (char*)data;
}
default:
msg_Warn( p_intf, "%s : %d bbp not supported !", fileName.c_str(),
bpp );
return NULL;
}
}
//---------------------------------------------------------------------------
#endif #endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11_bitmap.h: X11 implementation of the Bitmap class * x11_bitmap.h: X11 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: x11_bitmap.h,v 1.3 2003/05/18 17:48:05 asmax Exp $ * $Id: x11_bitmap.h,v 1.4 2003/05/29 21:40:27 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
//--- X11 ------------------------------------------------------------------- //--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <Imlib2.h>
//--- GENERAL --------------------------------------------------------------- //--- GENERAL ---------------------------------------------------------------
#include <string> #include <string>
...@@ -44,7 +45,7 @@ class X11Bitmap : public Bitmap ...@@ -44,7 +45,7 @@ class X11Bitmap : public Bitmap
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
Display *display; Display *display;
XImage *Bmp; Imlib_Image Img;
public: public:
// Constructors // Constructors
...@@ -63,9 +64,6 @@ class X11Bitmap : public Bitmap ...@@ -63,9 +64,6 @@ class X11Bitmap : public Bitmap
virtual int GetBmpPixel( int x, int y ); virtual int GetBmpPixel( int x, int y );
virtual void SetBmpPixel( int x, int y, int color ); virtual void SetBmpPixel( int x, int y, int color );
protected:
char *LoadFromFile( string fileName, int depth, int AColor, int &width,
int &height);
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -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.6 2003/05/29 16:48:29 asmax Exp $ * $Id: x11_theme.cpp,v 1.7 2003/05/29 21:40:27 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -187,7 +187,6 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -187,7 +187,6 @@ 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;
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 ) );
......
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