Commit 0f601455 authored by Sam Hocevar's avatar Sam Hocevar

* removed useless includes in intf_gnome.c

 * made the vout_sdl.c functions static
 * ported vout_x11.c to the modules API; code isn't very nice yet though
parent 2ba056f2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf_gnome.c: Gnome interface * intf_gnome.c: Gnome interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_gnome.c,v 1.11 2001/02/14 07:48:18 sam Exp $ * $Id: intf_gnome.c,v 1.12 2001/02/15 07:59:38 sam Exp $
* *
* Authors: * Authors:
* *
...@@ -31,12 +31,6 @@ ...@@ -31,12 +31,6 @@
#include <string.h> /* strerror() */ #include <string.h> /* strerror() */
#include <stdio.h> #include <stdio.h>
#include "glib.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <gnome.h> #include <gnome.h>
#include "config.h" #include "config.h"
......
...@@ -90,6 +90,8 @@ static void vout_End ( struct vout_thread_s * ); ...@@ -90,6 +90,8 @@ static void vout_End ( struct vout_thread_s * );
static void vout_Destroy ( struct vout_thread_s * ); static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * ); static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( struct vout_thread_s * ); static void vout_Display ( struct vout_thread_s * );
static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
u16 *blue, u16 *transp );
static int SDLOpenDisplay ( vout_thread_t *p_vout ); static int SDLOpenDisplay ( vout_thread_t *p_vout );
static void SDLCloseDisplay ( vout_thread_t *p_vout ); static void SDLCloseDisplay ( vout_thread_t *p_vout );
...@@ -107,7 +109,7 @@ void vout_getfunctions( function_list_t * p_function_list ) ...@@ -107,7 +109,7 @@ void vout_getfunctions( function_list_t * p_function_list )
p_function_list->functions.vout.pf_destroy = vout_Destroy; p_function_list->functions.vout.pf_destroy = vout_Destroy;
p_function_list->functions.vout.pf_manage = vout_Manage; p_function_list->functions.vout.pf_manage = vout_Manage;
p_function_list->functions.vout.pf_display = vout_Display; p_function_list->functions.vout.pf_display = vout_Display;
p_function_list->functions.vout.pf_setpalette = NULL; p_function_list->functions.vout.pf_setpalette = vout_SetPalette;
} }
/***************************************************************************** /*****************************************************************************
...@@ -133,7 +135,7 @@ static int vout_Probe( probedata_t *p_data ) ...@@ -133,7 +135,7 @@ static int vout_Probe( probedata_t *p_data )
* vout properties to choose the correct mode, and change them according to the * vout properties to choose the correct mode, and change them according to the
* mode actually used. * mode actually used.
*****************************************************************************/ *****************************************************************************/
int vout_Create( vout_thread_t *p_vout ) static int vout_Create( vout_thread_t *p_vout )
{ {
/* Allocate structure */ /* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
...@@ -212,7 +214,7 @@ int vout_Create( vout_thread_t *p_vout ) ...@@ -212,7 +214,7 @@ int vout_Create( vout_thread_t *p_vout )
***************************************************************************** *****************************************************************************
* This function initialize the SDL display device. * This function initialize the SDL display device.
*****************************************************************************/ *****************************************************************************/
int vout_Init( vout_thread_t *p_vout ) static int vout_Init( vout_thread_t *p_vout )
{ {
return( 0 ); return( 0 );
} }
...@@ -222,7 +224,7 @@ int vout_Init( vout_thread_t *p_vout ) ...@@ -222,7 +224,7 @@ int vout_Init( vout_thread_t *p_vout )
***************************************************************************** *****************************************************************************
* Terminate an output method created by vout_SDLCreate * Terminate an output method created by vout_SDLCreate
*****************************************************************************/ *****************************************************************************/
void vout_End( vout_thread_t *p_vout ) static void vout_End( vout_thread_t *p_vout )
{ {
SDLCloseDisplay( p_vout ); SDLCloseDisplay( p_vout );
SDL_Quit(); SDL_Quit();
...@@ -233,7 +235,7 @@ void vout_End( vout_thread_t *p_vout ) ...@@ -233,7 +235,7 @@ void vout_End( vout_thread_t *p_vout )
***************************************************************************** *****************************************************************************
* Terminate an output method created by vout_SDLCreate * Terminate an output method created by vout_SDLCreate
*****************************************************************************/ *****************************************************************************/
void vout_Destroy( vout_thread_t *p_vout ) static void vout_Destroy( vout_thread_t *p_vout )
{ {
free( p_vout->p_sys ); free( p_vout->p_sys );
} }
...@@ -244,7 +246,7 @@ void vout_Destroy( vout_thread_t *p_vout ) ...@@ -244,7 +246,7 @@ void vout_Destroy( vout_thread_t *p_vout )
* This function should be called regularly by video output thread. It returns * This function should be called regularly by video output thread. It returns
* a non null value if an error occured. * a non null value if an error occured.
*****************************************************************************/ *****************************************************************************/
int vout_Manage( vout_thread_t *p_vout ) static int vout_Manage( vout_thread_t *p_vout )
{ {
SDL_Event event; /* SDL event */ SDL_Event event; /* SDL event */
Uint8 i_key; Uint8 i_key;
...@@ -411,7 +413,7 @@ int vout_Manage( vout_thread_t *p_vout ) ...@@ -411,7 +413,7 @@ int vout_Manage( vout_thread_t *p_vout )
* anything, but could later send information on which colors it was unable * anything, but could later send information on which colors it was unable
* to set. * to set.
*****************************************************************************/ *****************************************************************************/
void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green, static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
u16 *blue, u16 *transp) u16 *blue, u16 *transp)
{ {
/* Create a display surface with a grayscale palette */ /* Create a display surface with a grayscale palette */
...@@ -440,7 +442,7 @@ void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green, ...@@ -440,7 +442,7 @@ void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
* This function send the currently rendered image to the display, wait until * This function send the currently rendered image to the display, wait until
* it is displayed and switch the two rendering buffer, preparing next frame. * it is displayed and switch the two rendering buffer, preparing next frame.
*****************************************************************************/ *****************************************************************************/
void vout_Display( vout_thread_t *p_vout ) static void vout_Display( vout_thread_t *p_vout )
{ {
SDL_Rect disp; SDL_Rect disp;
if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display) if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_x11.c: X11 video output display method * vout_x11.c: X11 video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout_x11.c,v 1.11 2001/02/15 03:01:20 sam Exp $ * $Id: vout_x11.c,v 1.12 2001/02/15 07:59:38 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -92,7 +92,6 @@ typedef struct vout_sys_s ...@@ -92,7 +92,6 @@ typedef struct vout_sys_s
int i_height; /* height of main window */ int i_height; /* height of main window */
/* Screen saver properties */ /* Screen saver properties */
int i_ss_count; /* enabling/disabling count */
int i_ss_timeout; /* timeout */ int i_ss_timeout; /* timeout */
int i_ss_interval; /* interval between changes */ int i_ss_interval; /* interval between changes */
int i_ss_blanking; /* blanking mode */ int i_ss_blanking; /* blanking mode */
...@@ -115,8 +114,7 @@ static int vout_Manage ( struct vout_thread_s * ); ...@@ -115,8 +114,7 @@ static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( struct vout_thread_s * ); static void vout_Display ( struct vout_thread_s * );
static void vout_SetPalette( struct vout_thread_s *, u16*, u16*, u16*, u16* ); static void vout_SetPalette( struct vout_thread_s *, u16*, u16*, u16*, u16* );
static int X11OpenDisplay ( vout_thread_t *p_vout, char *psz_display ); static int X11InitDisplay ( vout_thread_t *p_vout, char *psz_display );
static int X11CreateWindowVOUT ( vout_thread_t *p_vout );
static int X11CreateImage ( vout_thread_t *p_vout, XImage **pp_ximage ); static int X11CreateImage ( vout_thread_t *p_vout, XImage **pp_ximage );
static void X11DestroyImage ( XImage *p_ximage ); static void X11DestroyImage ( XImage *p_ximage );
static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage, static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage,
...@@ -125,10 +123,11 @@ static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage, ...@@ -125,10 +123,11 @@ static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage,
XShmSegmentInfo *p_shm_info ); XShmSegmentInfo *p_shm_info );
static int X11CreateWindow ( vout_thread_t *p_vout ); static int X11CreateWindow ( vout_thread_t *p_vout );
static void X11ManageWindow ( vout_thread_t *p_vout );
/* local prototypes */
static void X11TogglePointer ( vout_thread_t *p_vout );
static void X11EnableScreenSaver ( vout_thread_t *p_vout ); static void X11EnableScreenSaver ( vout_thread_t *p_vout );
static void X11DisableScreenSaver ( vout_thread_t *p_vout ); static void X11DisableScreenSaver ( vout_thread_t *p_vout );
static void X11TogglePointer ( vout_thread_t *p_vout );
/***************************************************************************** /*****************************************************************************
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
...@@ -185,7 +184,7 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -185,7 +184,7 @@ static int vout_Create( vout_thread_t *p_vout )
psz_display = XDisplayName( main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) ); psz_display = XDisplayName( main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) );
p_vout->p_sys->p_display = XOpenDisplay( psz_display ); p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( !p_vout->p_sys->p_display ) /* error */ if( p_vout->p_sys->p_display == NULL ) /* error */
{ {
intf_ErrMsg("error: can't open display %s\n", psz_display ); intf_ErrMsg("error: can't open display %s\n", psz_display );
free( p_vout->p_sys ); free( p_vout->p_sys );
...@@ -207,7 +206,7 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -207,7 +206,7 @@ static int vout_Create( vout_thread_t *p_vout )
* Since XLib is usually not thread-safe, we can't use the same display * Since XLib is usually not thread-safe, we can't use the same display
* pointer than the interface or another thread. However, the root window * pointer than the interface or another thread. However, the root window
* id is still valid. */ * id is still valid. */
if( X11OpenDisplay( p_vout, psz_display ) ) if( X11InitDisplay( p_vout, psz_display ) )
{ {
intf_ErrMsg("error: can't initialize X11 display" ); intf_ErrMsg("error: can't initialize X11 display" );
XCloseDisplay( p_vout->p_sys->p_display ); XCloseDisplay( p_vout->p_sys->p_display );
...@@ -218,7 +217,6 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -218,7 +217,6 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->b_mouse = 1; p_vout->p_sys->b_mouse = 1;
/* Disable screen saver and return */ /* Disable screen saver and return */
p_vout->p_sys->i_ss_count = 1;
X11DisableScreenSaver( p_vout ); X11DisableScreenSaver( p_vout );
return( 0 ); return( 0 );
...@@ -254,7 +252,7 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -254,7 +252,7 @@ static int vout_Init( vout_thread_t *p_vout )
} }
if( i_err ) /* an error occured */ if( i_err ) /* an error occured */
{ {
intf_Msg("vout: XShm video sextension deactivated" ); intf_Msg("vout: XShm video extension unavailable" );
p_vout->p_sys->b_shm = 0; p_vout->p_sys->b_shm = 0;
} }
} }
...@@ -344,6 +342,130 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -344,6 +342,130 @@ static void vout_Destroy( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int vout_Manage( vout_thread_t *p_vout ) static int vout_Manage( vout_thread_t *p_vout )
{ {
XEvent xevent; /* X11 event */
boolean_t b_resized; /* window has been resized */
char i_key; /* ISO Latin-1 key */
/* Handle X11 events: ConfigureNotify events are parsed to know if the
* output window's size changed, MapNotify and UnmapNotify to know if the
* window is mapped (and if the display is useful), and ClientMessages
* to intercept window destruction requests */
b_resized = 0;
while( XCheckWindowEvent( p_vout->p_sys->p_display, p_vout->p_sys->window,
StructureNotifyMask | KeyPressMask |
ButtonPressMask, &xevent ) == True )
{
/* ConfigureNotify event: prepare */
if( (xevent.type == ConfigureNotify)
&& ((xevent.xconfigure.width != p_vout->p_sys->i_width)
|| (xevent.xconfigure.height != p_vout->p_sys->i_height)) )
{
/* Update dimensions */
b_resized = 1;
p_vout->p_sys->i_width = xevent.xconfigure.width;
p_vout->p_sys->i_height = xevent.xconfigure.height;
}
/* MapNotify event: change window status and disable screen saver */
else if( xevent.type == MapNotify)
{
if( (p_vout != NULL) && !p_vout->b_active )
{
X11DisableScreenSaver( p_vout );
p_vout->b_active = 1;
}
}
/* UnmapNotify event: change window status and enable screen saver */
else if( xevent.type == UnmapNotify )
{
if( (p_vout != NULL) && p_vout->b_active )
{
X11EnableScreenSaver( p_vout );
p_vout->b_active = 0;
}
}
/* Keyboard event */
else if( xevent.type == KeyPress )
{
if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
{
/* FIXME: handle stuff here */
switch( i_key )
{
case 'q':
/* FIXME: need locking ! */
p_main->p_intf->b_die = 1;
break;
}
}
}
/* Mouse click */
else if( xevent.type == ButtonPress )
{
switch( ((XButtonEvent *)&xevent)->button )
{
case Button1:
/* in this part we will eventually manage
* clicks for DVD navigation for instance */
break;
case Button2:
X11TogglePointer( p_vout );
break;
case Button3:
/* FIXME: need locking ! */
p_main->p_intf->b_menu_change = 1;
break;
}
}
#ifdef DEBUG
/* Other event */
else
{
intf_DbgMsg( "%p -> unhandled event type %d received",
p_vout, xevent.type );
}
#endif
}
/* ClientMessage event - only WM_PROTOCOLS with WM_DELETE_WINDOW data
* are handled - according to the man pages, the format is always 32
* in this case */
while( XCheckTypedEvent( p_vout->p_sys->p_display,
ClientMessage, &xevent ) )
{
if( (xevent.xclient.message_type == p_vout->p_sys->wm_protocols)
&& (xevent.xclient.data.l[0] == p_vout->p_sys->wm_delete_window ) )
{
p_main->p_intf->b_die = 1;
}
else
{
intf_DbgMsg( "%p -> unhandled ClientMessage received", p_vout );
}
}
/*
* Handle vout window resizing
*/
if( b_resized )
{
/* If interface window has been resized, change vout size */
intf_DbgMsg( "resizing output window" );
p_vout->i_width = p_vout->p_sys->i_width;
p_vout->i_height = p_vout->p_sys->i_height;
p_vout->i_changes |= VOUT_SIZE_CHANGE;
}
else if( (p_vout->i_width != p_vout->p_sys->i_width) ||
(p_vout->i_height != p_vout->p_sys->i_height) )
{
/* If video output size has changed, change interface window size */
intf_DbgMsg( "resizing output window" );
p_vout->p_sys->i_width = p_vout->i_width;
p_vout->p_sys->i_height = p_vout->i_height;
XResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->window,
p_vout->p_sys->i_width, p_vout->p_sys->i_height );
}
/* /*
* Color/Grayscale or gamma change: in 8bpp, just change the colormap * Color/Grayscale or gamma change: in 8bpp, just change the colormap
*/ */
...@@ -382,8 +504,6 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -382,8 +504,6 @@ static int vout_Manage( vout_thread_t *p_vout )
intf_Msg("vout: video display resized (%dx%d)", p_vout->i_width, p_vout->i_height); intf_Msg("vout: video display resized (%dx%d)", p_vout->i_width, p_vout->i_height);
} }
X11ManageWindow( p_vout );
return 0; return 0;
} }
...@@ -430,53 +550,47 @@ static void vout_Display( vout_thread_t *p_vout ) ...@@ -430,53 +550,47 @@ static void vout_Display( vout_thread_t *p_vout )
static void vout_SetPalette( p_vout_thread_t p_vout, static void vout_SetPalette( p_vout_thread_t p_vout,
u16 *red, u16 *green, u16 *blue, u16 *transp ) u16 *red, u16 *green, u16 *blue, u16 *transp )
{ {
int i; int i, j;
XColor color[255]; XColor p_colors[255];
intf_DbgMsg( "Palette change called" ); intf_DbgMsg( "Palette change called" );
/* allocate palette */ /* allocate palette */
for( i = 0; i < 255; i++ ) for( i = 0, j = 255; i < 255; i++, j-- )
{ {
/* kludge: colors are indexed reversely because color 255 seems /* kludge: colors are indexed reversely because color 255 seems
* to be reserved for black even if we try to set it to white */ * to be reserved for black even if we try to set it to white */
color[i].pixel = 255-i; p_colors[ i ].pixel = j;
color[i].pad = 0; p_colors[ i ].pad = 0;
color[i].flags = DoRed|DoGreen|DoBlue; p_colors[ i ].flags = DoRed | DoGreen | DoBlue;
color[i].red = red[255-i]; p_colors[ i ].red = red[ j ];
color[i].blue = blue[255-i]; p_colors[ i ].blue = blue[ j ];
color[i].green = green[255-i]; p_colors[ i ].green = green[ j ];
} }
XStoreColors( p_vout->p_sys->p_display, p_vout->p_sys->colormap, color, 256 ); XStoreColors( p_vout->p_sys->p_display,
p_vout->p_sys->colormap, p_colors, 256 );
} }
/* following functions are local */ /* following functions are local */
/***************************************************************************** /*****************************************************************************
* X11OpenDisplay: open and initialize X11 device * X11InitDisplay: open and initialize X11 device
***************************************************************************** *****************************************************************************
* Create a window according to video output given size, and set other * Create a window according to video output given size, and set other
* properties according to the display properties. * properties according to the display properties.
*****************************************************************************/ *****************************************************************************/
static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display ) static int X11InitDisplay( vout_thread_t *p_vout, char *psz_display )
{ {
XPixmapFormatValues * p_xpixmap_format; /* pixmap formats */ XPixmapFormatValues * p_xpixmap_format; /* pixmap formats */
XVisualInfo * p_xvisual; /* visuals informations */ XVisualInfo * p_xvisual; /* visuals informations */
XVisualInfo xvisual_template; /* visual template */ XVisualInfo xvisual_template; /* visual template */
int i_count; /* array size */ int i_count; /* array size */
/* Open display */
p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( p_vout->p_sys->p_display == NULL )
{
intf_ErrMsg("error: can't open display %s", psz_display );
return( 1 );
}
/* Initialize structure */ /* Initialize structure */
p_vout->p_sys->b_shm = (XShmQueryExtension(p_vout->p_sys->p_display) == True);
p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display ); p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display );
p_vout->p_sys->b_shm = ( XShmQueryExtension( p_vout->p_sys->p_display )
== True );
if( !p_vout->p_sys->b_shm ) if( !p_vout->p_sys->b_shm )
{ {
intf_Msg("vout: XShm video extension is not available"); intf_Msg("vout: XShm video extension is not available");
...@@ -496,8 +610,7 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display ) ...@@ -496,8 +610,7 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display )
&xvisual_template, &i_count ); &xvisual_template, &i_count );
if( p_xvisual == NULL ) if( p_xvisual == NULL )
{ {
intf_ErrMsg("error: no PseudoColor visual available"); intf_ErrMsg("vout error: no PseudoColor visual available");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 ); return( 1 );
} }
p_vout->i_bytes_per_pixel = 1; p_vout->i_bytes_per_pixel = 1;
...@@ -515,8 +628,7 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display ) ...@@ -515,8 +628,7 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display )
&xvisual_template, &i_count ); &xvisual_template, &i_count );
if( p_xvisual == NULL ) if( p_xvisual == NULL )
{ {
intf_ErrMsg("error: no TrueColor visual available"); intf_ErrMsg("vout error: no TrueColor visual available");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 ); return( 1 );
} }
p_vout->i_red_mask = p_xvisual->red_mask; p_vout->i_red_mask = p_xvisual->red_mask;
...@@ -528,7 +640,6 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display ) ...@@ -528,7 +640,6 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display )
* formats. */ * formats. */
p_xpixmap_format = XListPixmapFormats( p_vout->p_sys->p_display, &i_count ); p_xpixmap_format = XListPixmapFormats( p_vout->p_sys->p_display, &i_count );
/* Under XFree4.0, the list contains pixmap formats available through /* Under XFree4.0, the list contains pixmap formats available through
* all video depths ; so we have to check against current depth. */ * all video depths ; so we have to check against current depth. */
p_vout->i_bytes_per_pixel = 0; p_vout->i_bytes_per_pixel = 0;
...@@ -547,77 +658,6 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display ) ...@@ -547,77 +658,6 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display )
p_vout->p_sys->p_visual = p_xvisual->visual; p_vout->p_sys->p_visual = p_xvisual->visual;
XFree( p_xvisual ); XFree( p_xvisual );
/* Create a window */
if( X11CreateWindowVOUT( p_vout ) )
{
intf_ErrMsg("error: can't open a window");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
}
return( 0 );
}
/*****************************************************************************
* X11CreateWindowVOUT: create X11 vout window
*****************************************************************************
* The video output window will be created. Normally, this window is wether
* full screen or part of a parent window. Therefore, it does not need a
* title or other hints. Thery are still supplied in case the window would be
* spawned as a standalone one by the interface.
*****************************************************************************/
static int X11CreateWindowVOUT( vout_thread_t *p_vout )
{
XSetWindowAttributes xwindow_attributes; /* window attributes */
XGCValues xgcvalues; /* graphic context configuration */
XEvent xevent; /* first events */
boolean_t b_expose; /* 'expose' event received */
boolean_t b_map_notify; /* 'map_notify' event received */
/* Prepare window attributes */
xwindow_attributes.backing_store = Always; /* save the hidden part */
/* Create the window and set hints */
p_vout->p_sys->window = XCreateSimpleWindow( p_vout->p_sys->p_display,
p_vout->p_sys->window,
0, 0,
p_vout->i_width, p_vout->i_height,
0, 0, 0);
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window,
ExposureMask | StructureNotifyMask );
XChangeWindowAttributes( p_vout->p_sys->p_display, p_vout->p_sys->window,
CWBackingStore, &xwindow_attributes);
/* Creation of a graphic context that doesn't generate a GraphicsExpose event
when using functions like XCopyArea */
xgcvalues.graphics_exposures = False;
p_vout->p_sys->gc = XCreateGC( p_vout->p_sys->p_display, p_vout->p_sys->window,
GCGraphicsExposures, &xgcvalues);
/* Send orders to server, and wait until window is displayed - two events
* must be received: a MapNotify event, an Expose event allowing drawing in the
* window */
b_expose = 0;
b_map_notify = 0;
XMapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window);
do
{
XNextEvent( p_vout->p_sys->p_display, &xevent);
if( (xevent.type == Expose)
&& (xevent.xexpose.window == p_vout->p_sys->window) )
{
b_expose = 1;
}
else if( (xevent.type == MapNotify)
&& (xevent.xmap.window == p_vout->p_sys->window) )
{
b_map_notify = 1;
}
}
while( !( b_expose && b_map_notify ) );
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window, 0 );
/* At this stage, the window is open, displayed, and ready to receive
* data */
return( 0 ); return( 0 );
} }
...@@ -684,7 +724,8 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage, ...@@ -684,7 +724,8 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
XShmSegmentInfo *p_shm_info) XShmSegmentInfo *p_shm_info)
{ {
/* Create XImage */ /* Create XImage */
*pp_ximage = XShmCreateImage( p_vout->p_sys->p_display, p_vout->p_sys->p_visual, *pp_ximage =
XShmCreateImage( p_vout->p_sys->p_display, p_vout->p_sys->p_visual,
p_vout->i_screen_depth, ZPixmap, 0, p_vout->i_screen_depth, ZPixmap, 0,
p_shm_info, p_vout->i_width, p_vout->i_height ); p_shm_info, p_vout->i_width, p_vout->i_height );
if(! *pp_ximage ) /* error */ if(! *pp_ximage ) /* error */
...@@ -695,9 +736,9 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage, ...@@ -695,9 +736,9 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
/* Allocate shared memory segment - 0777 set the access permission /* Allocate shared memory segment - 0777 set the access permission
* rights (like umask), they are not yet supported by X servers */ * rights (like umask), they are not yet supported by X servers */
p_shm_info->shmid = shmget( IPC_PRIVATE, p_shm_info->shmid =
(*pp_ximage)->bytes_per_line * (*pp_ximage)->height, shmget( IPC_PRIVATE, (*pp_ximage)->bytes_per_line
IPC_CREAT | 0777); * (*pp_ximage)->height, IPC_CREAT | 0777);
if( p_shm_info->shmid < 0) /* error */ if( p_shm_info->shmid < 0) /* error */
{ {
intf_ErrMsg("error: can't allocate shared image data (%s)", intf_ErrMsg("error: can't allocate shared image data (%s)",
...@@ -723,7 +764,8 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage, ...@@ -723,7 +764,8 @@ static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
/* Attach shared memory segment to X server (read only) */ /* Attach shared memory segment to X server (read only) */
p_shm_info->readOnly = True; p_shm_info->readOnly = True;
if( XShmAttach( p_vout->p_sys->p_display, p_shm_info ) == False ) /* error */ if( XShmAttach( p_vout->p_sys->p_display, p_shm_info )
== False ) /* error */
{ {
intf_ErrMsg("error: can't attach shared memory to X11 server"); intf_ErrMsg("error: can't attach shared memory to X11 server");
shmdt( p_shm_info->shmaddr ); /* detach shared memory from process shmdt( p_shm_info->shmaddr ); /* detach shared memory from process
...@@ -768,8 +810,9 @@ static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage, ...@@ -768,8 +810,9 @@ static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
return; return;
} }
XShmDetach( p_vout->p_sys->p_display, p_shm_info ); /* detach from server */ XShmDetach( p_vout->p_sys->p_display, p_shm_info );/* detach from server */
XDestroyImage( p_ximage ); XDestroyImage( p_ximage );
if( shmdt( p_shm_info->shmaddr ) ) /* detach shared memory from process */ if( shmdt( p_shm_info->shmaddr ) ) /* detach shared memory from process */
{ /* also automatic freeing... */ { /* also automatic freeing... */
intf_ErrMsg( "error: can't detach shared memory (%s)", intf_ErrMsg( "error: can't detach shared memory (%s)",
...@@ -898,144 +941,11 @@ static int X11CreateWindow( vout_thread_t *p_vout ) ...@@ -898,144 +941,11 @@ static int X11CreateWindow( vout_thread_t *p_vout )
CWColormap, &xwindow_attributes ); CWColormap, &xwindow_attributes );
} }
/* At this stage, the window is open, displayed, and ready to receive data */ /* At this stage, the window is open, displayed, and ready to
* receive data */
return( 0 ); return( 0 );
} }
/*****************************************************************************
* X11ManageWindow: manage X11 main window
*****************************************************************************/
static void X11ManageWindow( vout_thread_t *p_vout )
{
XEvent xevent; /* X11 event */
boolean_t b_resized; /* window has been resized */
char i_key; /* ISO Latin-1 key */
/* Handle X11 events: ConfigureNotify events are parsed to know if the
* output window's size changed, MapNotify and UnmapNotify to know if the
* window is mapped (and if the display is useful), and ClientMessages
* to intercept window destruction requests */
b_resized = 0;
while( XCheckWindowEvent( p_vout->p_sys->p_display, p_vout->p_sys->window,
StructureNotifyMask | KeyPressMask |
ButtonPressMask, &xevent ) == True )
{
/* ConfigureNotify event: prepare */
if( (xevent.type == ConfigureNotify)
&& ((xevent.xconfigure.width != p_vout->p_sys->i_width)
|| (xevent.xconfigure.height != p_vout->p_sys->i_height)) )
{
/* Update dimensions */
b_resized = 1;
p_vout->p_sys->i_width = xevent.xconfigure.width;
p_vout->p_sys->i_height = xevent.xconfigure.height;
}
/* MapNotify event: change window status and disable screen saver */
else if( xevent.type == MapNotify)
{
if( (p_vout != NULL) && !p_vout->b_active )
{
X11DisableScreenSaver( p_vout );
p_vout->b_active = 1;
}
}
/* UnmapNotify event: change window status and enable screen saver */
else if( xevent.type == UnmapNotify )
{
if( (p_vout != NULL) && p_vout->b_active )
{
X11EnableScreenSaver( p_vout );
p_vout->b_active = 0;
}
}
/* Keyboard event */
else if( xevent.type == KeyPress )
{
if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
{
/* if( intf_ProcessKey( p_vout, i_key ) )
{
intf_DbgMsg("unhandled key '%c' (%i)", (char) i_key, i_key );
}*/
}
}
/* Mouse click */
else if( xevent.type == ButtonPress )
{
switch( ((XButtonEvent *)&xevent)->button )
{
case Button1:
/* in this part we will eventually manage
* clicks for DVD navigation for instance */
break;
case Button2:
X11TogglePointer( p_vout );
break;
case Button3:
vlc_mutex_lock( &p_vout->change_lock );
p_vout->b_interface = !p_vout->b_interface;
p_vout->i_changes |= VOUT_INTF_CHANGE;
vlc_mutex_unlock( &p_vout->change_lock );
break;
}
}
#ifdef DEBUG
/* Other event */
else
{
intf_DbgMsg( "%p -> unhandled event type %d received",
p_vout, xevent.type );
}
#endif
}
/* ClientMessage event - only WM_PROTOCOLS with WM_DELETE_WINDOW data
* are handled - according to the man pages, the format is always 32
* in this case */
while( XCheckTypedEvent( p_vout->p_sys->p_display,
ClientMessage, &xevent ) )
{
if( (xevent.xclient.message_type == p_vout->p_sys->wm_protocols)
&& (xevent.xclient.data.l[0] == p_vout->p_sys->wm_delete_window ) )
{
p_vout->b_die = 1;
}
else
{
intf_DbgMsg( "%p -> unhandled ClientMessage received", p_vout );
}
}
/*
* Handle vout or interface windows resizing
*/
if( p_vout != NULL )
{
if( b_resized )
{
/* If interface window has been resized, change vout size */
intf_DbgMsg( "resizing output window" );
vlc_mutex_lock( &p_vout->change_lock );
p_vout->i_width = p_vout->p_sys->i_width;
p_vout->i_height = p_vout->p_sys->i_height;
p_vout->i_changes |= VOUT_SIZE_CHANGE;
vlc_mutex_unlock( &p_vout->change_lock );
}
else if( (p_vout->i_width != p_vout->p_sys->i_width) ||
(p_vout->i_height != p_vout->p_sys->i_height) )
{
/* If video output size has changed, change interface window size */
intf_DbgMsg( "resizing output window" );
p_vout->p_sys->i_width = p_vout->i_width;
p_vout->p_sys->i_height = p_vout->i_height;
XResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->window,
p_vout->p_sys->i_width, p_vout->p_sys->i_height );
}
}
}
/***************************************************************************** /*****************************************************************************
* X11EnableScreenSaver: enable screen saver * X11EnableScreenSaver: enable screen saver
***************************************************************************** *****************************************************************************
...@@ -1047,13 +957,11 @@ static void X11ManageWindow( vout_thread_t *p_vout ) ...@@ -1047,13 +957,11 @@ static void X11ManageWindow( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
void X11EnableScreenSaver( vout_thread_t *p_vout ) void X11EnableScreenSaver( vout_thread_t *p_vout )
{ {
if( p_vout->p_sys->i_ss_count++ == 0 )
{
intf_DbgMsg( "intf: enabling screen saver" ); intf_DbgMsg( "intf: enabling screen saver" );
XSetScreenSaver( p_vout->p_sys->p_display, p_vout->p_sys->i_ss_timeout, XSetScreenSaver( p_vout->p_sys->p_display, p_vout->p_sys->i_ss_timeout,
p_vout->p_sys->i_ss_interval, p_vout->p_sys->i_ss_blanking, p_vout->p_sys->i_ss_interval,
p_vout->p_sys->i_ss_blanking,
p_vout->p_sys->i_ss_exposure ); p_vout->p_sys->i_ss_exposure );
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -1063,11 +971,10 @@ void X11EnableScreenSaver( vout_thread_t *p_vout ) ...@@ -1063,11 +971,10 @@ void X11EnableScreenSaver( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
void X11DisableScreenSaver( vout_thread_t *p_vout ) void X11DisableScreenSaver( vout_thread_t *p_vout )
{ {
if( --p_vout->p_sys->i_ss_count == 0 )
{
/* Save screen saver informations */ /* Save screen saver informations */
XGetScreenSaver( p_vout->p_sys->p_display, &p_vout->p_sys->i_ss_timeout, XGetScreenSaver( p_vout->p_sys->p_display, &p_vout->p_sys->i_ss_timeout,
&p_vout->p_sys->i_ss_interval, &p_vout->p_sys->i_ss_blanking, &p_vout->p_sys->i_ss_interval,
&p_vout->p_sys->i_ss_blanking,
&p_vout->p_sys->i_ss_exposure ); &p_vout->p_sys->i_ss_exposure );
/* Disable screen saver */ /* Disable screen saver */
...@@ -1075,7 +982,6 @@ void X11DisableScreenSaver( vout_thread_t *p_vout ) ...@@ -1075,7 +982,6 @@ void X11DisableScreenSaver( vout_thread_t *p_vout )
XSetScreenSaver( p_vout->p_sys->p_display, 0, XSetScreenSaver( p_vout->p_sys->p_display, 0,
p_vout->p_sys->i_ss_interval, p_vout->p_sys->i_ss_blanking, p_vout->p_sys->i_ss_interval, p_vout->p_sys->i_ss_blanking,
p_vout->p_sys->i_ss_exposure ); p_vout->p_sys->i_ss_exposure );
}
} }
/***************************************************************************** /*****************************************************************************
......
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