* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: xcommon.c,v 1.3 2002/08/19 08:19:31 gbazin Exp $
+ * $Id: xcommon.c,v 1.4 2002/09/10 12:15:07 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
- return( 1 );
+ return VLC_ENOMEM;
}
/* Open display, unsing the "display" config variable or the DISPLAY
XDisplayName( psz_display ) );
free( p_vout->p_sys );
if( psz_display ) free( psz_display );
- return( 1 );
+ return VLC_EGENERIC;
}
if( psz_display ) free( psz_display );
if( p_vout->p_sys->i_xvport < 0 )
{
/* If a specific chroma format was requested, then we don't try to
- * be cleverer than the user. He knows pretty well what he wants. */
+ * be cleverer than the user. He knew pretty well what he wanted. */
if( b_chroma )
{
XCloseDisplay( p_vout->p_sys->p_display );
free( p_vout->p_sys );
- return 1;
+ return VLC_EGENERIC;
}
/* It failed, but it's not completely lost ! We try to open an
{
XCloseDisplay( p_vout->p_sys->p_display );
free( p_vout->p_sys );
- return 1;
+ return VLC_EGENERIC;
}
}
}
DestroyCursor( p_vout );
XCloseDisplay( p_vout->p_sys->p_display );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
/* Open and initialize device. */
DestroyWindow( p_vout, &p_vout->p_sys->original_window );
XCloseDisplay( p_vout->p_sys->p_display );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
/* Disable screen saver */
p_vout->p_sys->b_altfullscreen = 0;
p_vout->p_sys->i_time_button_last_pressed = 0;
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
default:
msg_Err( p_vout, "unknown screen depth %i",
p_vout->p_sys->i_screen_depth );
- return( 0 );
+ return VLC_SUCCESS;
}
vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width,
I_OUTPUTPICTURES++;
}
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
if( i_drawable == -1 )
{
- p_vout->p_sys->b_createwindow = 1;
+ p_win->b_owned = VLC_TRUE;
/* Create the window and set hints - the window must receive
* ConfigureNotify events, and until it is displayed, Expose and
}
else
{
- p_vout->p_sys->b_createwindow = 0;
+ p_win->b_owned = VLC_FALSE;
p_win->base_window = i_drawable;
XChangeWindowAttributes( p_vout->p_sys->p_display,
p_win->base_window,
GCGraphicsExposures, &xgcvalues );
- if( p_vout->p_sys->b_createwindow )
+ if( p_win->b_owned )
{
/* Send orders to server, and wait until window is displayed - three
* events must be received: a MapNotify event, an Expose event allowing
PointerMotionMask );
#ifdef MODULE_NAME_IS_x11
- if( p_vout->p_sys->b_createwindow &&
+ if( p_win->b_owned &&
XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 )
{
/* Allocate a new palette */
* receive data */
p_vout->p_sys->p_win = p_win;
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
XSync( p_vout->p_sys->p_display, False );
XDestroyWindow( p_vout->p_sys->p_display, p_win->video_window );
- XUnmapWindow( p_vout->p_sys->p_display, p_win->base_window );
XFreeGC( p_vout->p_sys->p_display, p_win->gc );
- XDestroyWindow( p_vout->p_sys->p_display, p_win->base_window );
+
+ if( p_win->b_owned )
+ {
+ XUnmapWindow( p_vout->p_sys->p_display, p_win->base_window );
+ XDestroyWindow( p_vout->p_sys->p_display, p_win->base_window );
+ }
}
/*****************************************************************************
p_vout->p_sys->b_altfullscreen =
config_GetInt( p_vout, MODULE_STRING "-altfullscreen" );
- if( p_vout->p_sys->b_createwindow )
+ if( p_vout->p_sys->p_win->b_owned )
+ {
XUnmapWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->base_window);
+ }
p_vout->p_sys->p_win = &p_vout->p_sys->fullscreen_window;
DestroyWindow( p_vout, &p_vout->p_sys->fullscreen_window );
p_vout->p_sys->p_win = &p_vout->p_sys->original_window;
- if( p_vout->p_sys->b_createwindow )
+ if( p_vout->p_sys->p_win->b_owned )
{
XMapWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->base_window);
* window has already been mapped because the XMapWindow() request
* has not necessarily been sent directly to our window (remember,
* the call is first redirected to the window manager) */
- do
+ if( p_vout->p_sys->p_win->b_owned )
+ {
+ do
+ {
+ XWindowEvent( p_vout->p_sys->p_display,
+ p_vout->p_sys->p_win->base_window,
+ StructureNotifyMask, &xevent );
+ } while( xevent.type != MapNotify );
+ }
+ else
{
- XWindowEvent( p_vout->p_sys->p_display,
- p_vout->p_sys->p_win->base_window,
- StructureNotifyMask, &xevent );
- } while( xevent.type != MapNotify );
+ XSync( p_vout->p_sys->p_display, False );
+ }
/* Becareful, this can generate a BadMatch error if the window is not
* already mapped by the server (see above) */
case XvBadExtension:
msg_Warn( p_vout, "XvBadExtension" );
- return( -1 );
+ return -1;
case XvBadAlloc:
msg_Warn( p_vout, "XvBadAlloc" );
- return( -1 );
+ return -1;
default:
msg_Warn( p_vout, "XvQueryExtension failed" );
- return( -1 );
+ return -1;
}
switch( XvQueryAdaptors( p_vout->p_sys->p_display,
case XvBadExtension:
msg_Warn( p_vout, "XvBadExtension for XvQueryAdaptors" );
- return( -1 );
+ return -1;
case XvBadAlloc:
msg_Warn( p_vout, "XvBadAlloc for XvQueryAdaptors" );
- return( -1 );
+ return -1;
default:
msg_Warn( p_vout, "XvQueryAdaptors failed" );
- return( -1 );
+ return -1;
}
i_selected_port = -1;
}
}
- return( i_selected_port );
+ return i_selected_port;
}
/*****************************************************************************
if( p_xvisual == NULL )
{
msg_Err( p_vout, "no PseudoColor visual available" );
- return( 1 );
+ return VLC_EGENERIC;
}
p_vout->p_sys->i_bytes_per_pixel = 1;
p_vout->output.pf_setpalette = SetPalette;
if( p_xvisual == NULL )
{
msg_Err( p_vout, "no TrueColor visual available" );
- return( 1 );
+ return VLC_EGENERIC;
}
p_vout->output.i_rmask = p_xvisual->red_mask;
XFree( p_xvisual );
#endif
- return( 0 );
+ return VLC_SUCCESS;
}
#ifdef HAVE_SYS_SHM_H
if( p_image == NULL )
{
msg_Err( p_vout, "image creation failed" );
- return( NULL );
+ return NULL;
}
/* Allocate shared memory segment - 0776 set the access permission
msg_Err( p_vout, "cannot allocate shared image data (%s)",
strerror( errno ) );
IMAGE_FREE( p_image );
- return( NULL );
+ return NULL;
}
/* Attach shared memory segment to process (read/write) */
strerror(errno));
IMAGE_FREE( p_image );
shmctl( p_shm->shmid, IPC_RMID, 0 );
- return( NULL );
+ return NULL;
}
/* Read-only data. We won't be using XShmGetImage */
IMAGE_FREE( p_image );
shmctl( p_shm->shmid, IPC_RMID, 0 );
shmdt( p_shm->shmaddr );
- return( NULL );
+ return NULL;
}
/* Send image to X server. This instruction is required, since having
shmctl( p_shm->shmid, IPC_RMID, 0 );
#endif
- return( p_image );
+ return p_image;
}
#endif
if( !p_data )
{
msg_Err( p_vout, "out of memory" );
- return( NULL );
+ return NULL;
}
#ifdef MODULE_NAME_IS_x11
{
msg_Err( p_vout, "XCreateImage() failed" );
free( p_data );
- return( NULL );
+ return NULL;
}
return p_image;