Commit 3668622d authored by Sam Hocevar's avatar Sam Hocevar

* ./plugins/x11/*: added the --x11-drawable and --xvideo-drawable options to

    tell vlc to draw in an existing drawable instead of creating a new window.
parent 31f47190
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* x11.c : X11 plugin for vlc * x11.c : X11 plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: x11.c,v 1.18 2002/06/01 12:32:00 sam Exp $ * $Id: x11.c,v 1.19 2002/06/27 19:01:28 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>
...@@ -51,10 +51,16 @@ ...@@ -51,10 +51,16 @@
"Specify the X11 hardware display you want to use. By default vlc will " \ "Specify the X11 hardware display you want to use. By default vlc will " \
"use the value of the DISPLAY environment variable.") "use the value of the DISPLAY environment variable.")
#define DRAWABLE_TEXT N_("X11 drawable")
#define DRAWABLE_LONGTEXT N_( \
"Specify a X11 drawable to use instead of opening a new window. This " \
"option is DANGEROUS, use with care.")
MODULE_CONFIG_START MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL ) ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_STRING ( "x11-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT ) ADD_STRING ( "x11-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_BOOL ( "x11-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT ) ADD_BOOL ( "x11-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_INTEGER ( "x11-drawable", -1, NULL, DRAWABLE_TEXT, DRAWABLE_LONGTEXT )
MODULE_CONFIG_STOP MODULE_CONFIG_STOP
MODULE_INIT_START MODULE_INIT_START
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins * xcommon.c: Functions common to the X11 and XVideo plugins
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.40 2002/06/05 18:07:03 stef Exp $ * $Id: xcommon.c,v 1.41 2002/06/27 19:01:28 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>
...@@ -142,6 +142,7 @@ struct vout_sys_s ...@@ -142,6 +142,7 @@ struct vout_sys_s
int i_screen; /* screen number */ int i_screen; /* screen number */
GC gc; /* graphic context instance handler */ GC gc; /* graphic context instance handler */
Window window; /* root window */ Window window; /* root window */
vlc_bool_t b_createwindow; /* are we the window's owner ? */
Window video_window; /* sub-window for displaying video */ Window video_window; /* sub-window for displaying video */
#ifdef HAVE_SYS_SHM_H #ifdef HAVE_SYS_SHM_H
...@@ -925,6 +926,8 @@ static int CreateWindow( vout_thread_t *p_vout ) ...@@ -925,6 +926,8 @@ static int CreateWindow( vout_thread_t *p_vout )
vlc_bool_t b_configure_notify; vlc_bool_t b_configure_notify;
vlc_bool_t b_map_notify; vlc_bool_t b_map_notify;
long long int i_drawable;
/* Set main window's size */ /* Set main window's size */
p_vout->p_sys->i_width = p_vout->i_window_width; p_vout->p_sys->i_width = p_vout->i_window_width;
p_vout->p_sys->i_height = p_vout->i_window_height; p_vout->p_sys->i_height = p_vout->i_window_height;
...@@ -943,39 +946,54 @@ static int CreateWindow( vout_thread_t *p_vout ) ...@@ -943,39 +946,54 @@ static int CreateWindow( vout_thread_t *p_vout )
xwindow_attributes.background_pixel = BlackPixel(p_vout->p_sys->p_display, xwindow_attributes.background_pixel = BlackPixel(p_vout->p_sys->p_display,
p_vout->p_sys->i_screen); p_vout->p_sys->i_screen);
xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask; xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;
/* Create the window and set hints - the window must receive /* Check whether someone provided us with a window */
* ConfigureNotify events, and until it is displayed, Expose and i_drawable = config_GetInt( p_vout, MODULE_STRING "-drawable");
* MapNotify events. */
p_vout->p_sys->window = if( i_drawable == -1 )
XCreateWindow( p_vout->p_sys->p_display, {
DefaultRootWindow( p_vout->p_sys->p_display ), p_vout->p_sys->b_createwindow = 1;
0, 0,
p_vout->p_sys->i_width, /* Create the window and set hints - the window must receive
p_vout->p_sys->i_height, * ConfigureNotify events, and until it is displayed, Expose and
0, * MapNotify events. */
0, InputOutput, 0,
CWBackingStore | CWBackPixel | CWEventMask, p_vout->p_sys->window =
&xwindow_attributes ); XCreateWindow( p_vout->p_sys->p_display,
DefaultRootWindow( p_vout->p_sys->p_display ),
/* Set window manager hints and properties: size hints, command, 0, 0,
* window's name, and accepted protocols */ p_vout->p_sys->i_width,
XSetWMNormalHints( p_vout->p_sys->p_display, p_vout->p_sys->window, p_vout->p_sys->i_height,
&xsize_hints ); 0,
/* XXX: DISABLED! makes browsers crash */ 0, InputOutput, 0,
#if 0 CWBackingStore | CWBackPixel | CWEventMask,
XSetCommand( p_vout->p_sys->p_display, p_vout->p_sys->window, &xwindow_attributes );
p_vout->p_vlc->ppsz_argv, p_vout->p_vlc->i_argc );
#endif /* Set window manager hints and properties: size hints, command,
XStoreName( p_vout->p_sys->p_display, p_vout->p_sys->window, * window's name, and accepted protocols */
XSetWMNormalHints( p_vout->p_sys->p_display, p_vout->p_sys->window,
&xsize_hints );
XSetCommand( p_vout->p_sys->p_display, p_vout->p_sys->window,
p_vout->p_vlc->ppsz_argv, p_vout->p_vlc->i_argc );
XStoreName( p_vout->p_sys->p_display, p_vout->p_sys->window,
#ifdef MODULE_NAME_IS_x11 #ifdef MODULE_NAME_IS_x11
VOUT_TITLE " (X11 output)" VOUT_TITLE " (X11 output)"
#else #else
VOUT_TITLE " (XVideo output)" VOUT_TITLE " (XVideo output)"
#endif #endif
); );
}
else
{
p_vout->p_sys->b_createwindow = 0;
p_vout->p_sys->window = i_drawable;
XChangeWindowAttributes( p_vout->p_sys->p_display,
p_vout->p_sys->window,
CWBackingStore | CWBackPixel | CWEventMask,
&xwindow_attributes );
}
if( (p_vout->p_sys->wm_protocols == None) /* use WM_DELETE_WINDOW */ if( (p_vout->p_sys->wm_protocols == None) /* use WM_DELETE_WINDOW */
|| (p_vout->p_sys->wm_delete_window == None) || (p_vout->p_sys->wm_delete_window == None)
...@@ -993,36 +1011,49 @@ static int CreateWindow( vout_thread_t *p_vout ) ...@@ -993,36 +1011,49 @@ static int CreateWindow( vout_thread_t *p_vout )
p_vout->p_sys->window, p_vout->p_sys->window,
GCGraphicsExposures, &xgcvalues); GCGraphicsExposures, &xgcvalues);
/* Send orders to server, and wait until window is displayed - three if( p_vout->p_sys->b_createwindow )
* events must be received: a MapNotify event, an Expose event allowing
* drawing in the window, and a ConfigureNotify to get the window
* dimensions. Once those events have been received, only ConfigureNotify
* events need to be received. */
b_expose = 0;
b_configure_notify = 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); /* Send orders to server, and wait until window is displayed - three
if( (xevent.type == Expose) * events must be received: a MapNotify event, an Expose event allowing
&& (xevent.xexpose.window == p_vout->p_sys->window) ) * drawing in the window, and a ConfigureNotify to get the window
{ * dimensions. Once those events have been received, only
b_expose = 1; * ConfigureNotify events need to be received. */
} b_expose = 0;
else if( (xevent.type == MapNotify) b_configure_notify = 0;
&& (xevent.xmap.window == p_vout->p_sys->window) ) b_map_notify = 0;
{ XMapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
b_map_notify = 1; do
}
else if( (xevent.type == ConfigureNotify)
&& (xevent.xconfigure.window == p_vout->p_sys->window) )
{ {
b_configure_notify = 1; XNextEvent( p_vout->p_sys->p_display, &xevent);
p_vout->p_sys->i_width = xevent.xconfigure.width; if( (xevent.type == Expose)
p_vout->p_sys->i_height = xevent.xconfigure.height; && (xevent.xexpose.window == p_vout->p_sys->window) )
} {
} while( !( b_expose && b_configure_notify && b_map_notify ) ); b_expose = 1;
}
else if( (xevent.type == MapNotify)
&& (xevent.xmap.window == p_vout->p_sys->window) )
{
b_map_notify = 1;
}
else if( (xevent.type == ConfigureNotify)
&& (xevent.xconfigure.window == p_vout->p_sys->window) )
{
b_configure_notify = 1;
p_vout->p_sys->i_width = xevent.xconfigure.width;
p_vout->p_sys->i_height = xevent.xconfigure.height;
}
} while( !( b_expose && b_configure_notify && b_map_notify ) );
}
else
{
/* Get the window's geometry information */
Window dummy1;
unsigned int dummy2, dummy3;
XGetGeometry( p_vout->p_sys->p_display, p_vout->p_sys->window,
&dummy1, &dummy2, &dummy3,
&p_vout->p_sys->i_width, &p_vout->p_sys->i_height,
&dummy2, &dummy3 );
}
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window, XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window,
StructureNotifyMask | KeyPressMask | StructureNotifyMask | KeyPressMask |
...@@ -1030,7 +1061,8 @@ static int CreateWindow( vout_thread_t *p_vout ) ...@@ -1030,7 +1061,8 @@ static int CreateWindow( vout_thread_t *p_vout )
PointerMotionMask ); PointerMotionMask );
#ifdef MODULE_NAME_IS_x11 #ifdef MODULE_NAME_IS_x11
if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 ) if( p_vout->p_sys->b_createwindow &&
XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 )
{ {
/* Allocate a new palette */ /* Allocate a new palette */
p_vout->p_sys->colormap = p_vout->p_sys->colormap =
...@@ -1045,8 +1077,8 @@ static int CreateWindow( vout_thread_t *p_vout ) ...@@ -1045,8 +1077,8 @@ static int CreateWindow( vout_thread_t *p_vout )
p_vout->p_sys->window, p_vout->p_sys->window,
CWColormap, &xwindow_attributes ); CWColormap, &xwindow_attributes );
} }
#endif #endif
/* Create video output sub-window. */ /* Create video output sub-window. */
p_vout->p_sys->video_window = XCreateSimpleWindow( p_vout->p_sys->video_window = XCreateSimpleWindow(
p_vout->p_sys->p_display, p_vout->p_sys->p_display,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xvideo.c : Xvideo plugin for vlc * xvideo.c : Xvideo plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: xvideo.c,v 1.14 2002/06/01 12:32:01 sam Exp $ * $Id: xvideo.c,v 1.15 2002/06/27 19:01:28 sam Exp $
* *
* Authors: Shane Harper <shanegh@optusnet.com.au> * Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -61,12 +61,18 @@ ...@@ -61,12 +61,18 @@
"Force the XVideo renderer to use a specific chroma format instead of " \ "Force the XVideo renderer to use a specific chroma format instead of " \
"trying to improve performances by using the most efficient one.") "trying to improve performances by using the most efficient one.")
#define DRAWABLE_TEXT N_("X11 drawable")
#define DRAWABLE_LONGTEXT N_( \
"Specify a X11 drawable to use instead of opening a new window. This " \
"option is DANGEROUS, use with care.")
MODULE_CONFIG_START MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL ) ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_STRING ( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT ) ADD_STRING ( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_INTEGER ( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT ) ADD_INTEGER ( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT )
ADD_BOOL ( "xvideo-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT ) ADD_BOOL ( "xvideo-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_STRING ( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT ) ADD_STRING ( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT )
ADD_INTEGER ( "xvideo-drawable", -1, NULL, DRAWABLE_TEXT, DRAWABLE_LONGTEXT )
MODULE_CONFIG_STOP MODULE_CONFIG_STOP
MODULE_INIT_START MODULE_INIT_START
......
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