* x11_bitmap.cpp: X11 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_bitmap.cpp,v 1.3 2003/05/18 11:25:00 asmax Exp $
+ * $Id: x11_bitmap.cpp,v 1.4 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
Width = 0;
Height = 0;
- AlphaColor = AColor;
+ // TODO: check for endianness issues
+ AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) |
+ (AColor & 0xff0000) >> 16;
if( FileName != "" )
{
- data = LoadFromFile( FileName, depth, Width, Height );
+ data = LoadFromFile( FileName, depth, AlphaColor, Width, Height );
}
// Create the image
Height, 32, 4 * Width );
XInitImage( Bmp );
- // Load the bitmap image
-/* if( rc != BitmapSuccess )
- {
- if( FileName != "" )
- msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() );
- Width = 0;
- Height = 0;
- }*/
-/* else
- {
- Width = gdk_pixbuf_get_width( Bmp );
- Height = gdk_pixbuf_get_height( Bmp );
-
- if( AColor != 0 )
- {
- // Change black pixels to another color to avoid transparency
- int rowstride = gdk_pixbuf_get_rowstride( Bmp );
- guchar *pixel = gdk_pixbuf_get_pixels( Bmp );
- int pix_size = ( gdk_pixbuf_get_has_alpha( Bmp ) ? 4 : 3 );
-
- for( int y = 0; y < Height; y++ )
- {
- for( int x = 0; x < Width; x++ )
- {
- guint32 r = pixel[0];
- guint32 g = pixel[1]<<8;
- guint32 b = pixel[2]<<16;
- if( r+g+b == 0 )
- {
- pixel[2] = 10; // slight blue
- }
- pixel += pix_size;
- }
- }
- }
-
- Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff,
- (AColor>>16) & 0xff );
- }*/
}
//---------------------------------------------------------------------------
X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
return false;
else
return true;*/
+ return true;
}
//---------------------------------------------------------------------------
int X11Bitmap::GetBmpPixel( int x, int y )
// SetPixelV( bmpDC, x, y, color );
}
//---------------------------------------------------------------------------
-char *X11Bitmap::LoadFromFile( string fileName, int depth, int &width, int &height )
+char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor,
+ int &width, int &height )
{
// BMP header fields
uint32_t fileSize;
dataSize = U32( headers + 34 );
nColors = U32( headers + 50 );
-// fprintf(stderr,"image %d %d\n", width, height);
+ fprintf(stderr,"image %s %x\n", fileName.c_str(), AColor);
switch( bpp )
{
case 24:
// Read a pixel
uint32_t pixel = 0;
fread( &pixel, 3, 1, file );
- *(ptr++) = U32( &pixel );
+ 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 );
}
* x11_bitmap.h: X11 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_bitmap.h,v 1.2 2003/05/18 11:25:00 asmax Exp $
+ * $Id: x11_bitmap.h,v 1.3 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
virtual void SetBmpPixel( int x, int y, int color );
protected:
- char *LoadFromFile( string fileName, int depth, int &width, int &height);
+ char *LoadFromFile( string fileName, int depth, int AColor, int &width,
+ int &height);
};
//---------------------------------------------------------------------------
* x11_font.cpp: X11 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_font.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $
+ * $Id: x11_font.cpp,v 1.2 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
//---------------------------------------------------------------------------
void X11Font::GetSize( string text, int &w, int &h )
{
+ w = 0;
+ h = 0;
/* pango_layout_set_text( Layout, text.c_str(), text.length() );
pango_layout_get_pixel_size( Layout, &w, &h );*/
}
* x11_graphics.cpp: X11 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_graphics.cpp,v 1.2 2003/04/30 21:16:24 asmax Exp $
+ * $Id: x11_graphics.cpp,v 1.3 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
Image = XCreatePixmap( display, root, w, h,
DefaultDepth( display, screen ) );
Gc = DefaultGC( display, screen );
- }
+ }
// Set the background color to black
- // gdk_draw_rectangle( Image, Gc, TRUE, 0, 0, w, h );
+ XFillRectangle( display, Image, Gc, 0, 0, w, h );
}
//---------------------------------------------------------------------------
X11Graphics::~X11Graphics()
{
-/* g_object_unref( Gc );
- g_object_unref( Image );*/
+ XFreePixmap( display, Image );
}
//---------------------------------------------------------------------------
void X11Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
* x11_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_run.cpp,v 1.4 2003/05/18 11:25:00 asmax Exp $
+ * $Id: x11_run.cpp,v 1.5 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
ProcessEvent( p_intf, proc, event );
// kludge: add timer
- SkinManage( p_intf );
+ // SkinManage( p_intf );
}
}
* x11_theme.cpp: X11 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_theme.cpp,v 1.1 2003/04/28 14:32:57 asmax Exp $
+ * $Id: x11_theme.cpp,v 1.2 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
gdk_window_show( gwnd );*/
+ // Create the window
Window root = DefaultRootWindow( display );
- Window wnd = XCreateSimpleWindow( display, root, 0, 0, 200, 100, 0, 0, 0 );
+ Window wnd = XCreateSimpleWindow( display, root, 0, 0, 1, 1, 0, 0, 0 );
XSelectInput( display, wnd, ExposureMask|
KeyPressMask|KeyReleaseMask|ButtonPressMask|PointerMotionMask|
PointerMotionHintMask| EnterWindowMask|LeaveWindowMask);
+ // Changing decorations
+ struct {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long input_mode;
+ unsigned long status;
+ } motifWmHints;
+
+ Atom hints_atom = XInternAtom( display, "_MOTIF_WM_HINTS", False );
+
+ motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS;
+ motifWmHints.decorations = 0;
+
+ XChangeProperty( display, wnd, hints_atom, hints_atom, 32,
+ PropModeReplace, (unsigned char *)&motifWmHints,
+ sizeof( motifWmHints ) / sizeof( long ) );
+
+ // Display the window
XMapRaised( display, wnd );
XFlush( display );
- WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y, visible,
- fadetime, alpha, movealpha, dragdrop, name ) ) ;
+ WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y,
+ visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
}
//---------------------------------------------------------------------------
void X11Theme::ChangeTray()
* x11_window.cpp: X11 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_window.cpp,v 1.3 2003/05/18 11:25:00 asmax Exp $
+ * $Id: x11_window.cpp,v 1.4 2003/05/18 17:48:05 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
//--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h>
+#include <X11/extensions/shape.h>
//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
//---------------------------------------------------------------------------
void X11Window::RefreshFromImage( int x, int y, int w, int h )
{
- // Initialize painting
-/* HDC DC = GetWindowDC( hWnd );
-
- // Draw image on window
- BitBlt( DC, x, y, w, h, ( (X11Graphics *)Image )->GetImageHandle(),
- x, y, SRCCOPY );
-
- // Release window device context
- ReleaseDC( hWnd, DC );
-
-*/
Drawable drawable = (( X11Graphics* )Image )->GetImage();
XCopyArea( display, drawable, Wnd, Gc, x, y, w, h, x, y );
- XSync( display, 0);
-/*
+
+ XImage *image = XGetImage( display, drawable, 0, 0, Width, Height,
+ AllPlanes, ZPixmap );
+
// Mask for transparency
- GdkRegion *region = gdk_region_new();
+ Region region = XCreateRegion();
for( int line = 0; line < Height; line++ )
{
int start = 0, end = 0;
while( start < Width )
{
- while( start < Width && gdk_image_get_pixel( image, start, line ) == 0 )
+ while( start < Width && XGetPixel( image, start, line ) == 0 )
{
start++;
}
end = start;
- while( end < Width && gdk_image_get_pixel( image, end, line ) != 0)
+ while( end < Width && XGetPixel( image, end, line ) != 0)
{
end++;
}
- GdkRectangle rect;
+ XRectangle rect;
rect.x = start;
rect.y = line;
rect.width = end - start + 1;
rect.height = 1;
- GdkRegion *rectReg = gdk_region_rectangle( &rect );
- gdk_region_union( region, rectReg );
- gdk_region_destroy( rectReg );
+ Region newRegion = XCreateRegion();
+ XUnionRectWithRegion( &rect, region, newRegion );
+ XDestroyRegion( region );
+ region = newRegion;
start = end + 1;
}
}
- gdk_window_shape_combine_region( gWnd, region, 0, 0 );
- gdk_region_destroy( region );*/
+ XShapeCombineRegion( display, Wnd, ShapeBounding, 0, 0, region, ShapeSet );
+ XDestroyRegion( region );
+
+ XSync( display, 0);
}
//---------------------------------------------------------------------------
void X11Window::WindowManualMove()
{
Left = left;
Top = top;
-/* gdk_window_move( gWnd, left, top );*/
+ XMoveWindow( display, Wnd, left, top );
+
}
//---------------------------------------------------------------------------
void X11Window::Size( int width, int height )
{
Width = width;
Height = height;
-/* gdk_window_resize( gWnd, width, height );*/
+ XResizeWindow( display, Wnd, width, height );
}
//---------------------------------------------------------------------------
void X11Window::ChangeToolTipText( string text )