* xmga.c : X11 MGA plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: xmga.c,v 1.5 2002/02/19 00:50:19 sam Exp $
+ * $Id: xmga.c,v 1.11 2002/03/25 19:16:20 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
+ * Gildas Bazin <gbazin@netcourrier.com>
*
* 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
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
+
+#define ALT_FS_TEXT "Alternate fullscreen method"
+#define ALT_FS_LONGTEXT "There are two ways to make a fullscreen window, " \
+ "unfortunately each one has its drawbacks.\n" \
+ "1) Let the window manager handle your fullscreen " \
+ "window (default). But things like taskbars will " \
+ "likely show on top of the video\n" \
+ "2) Completly bypass the window manager, but then " \
+ "nothing will be able to show on top of the video"
+
+#define DISPLAY_TEXT "X11 display name"
+#define DISPLAY_LONGTEXT "Specify the X11 hardware display you want to use.\n"\
+ "By default vlc will use the value of the DISPLAY " \
+ "environment variable."
+
MODULE_CONFIG_START
+ADD_CATEGORY_HINT( "Miscellaneous", NULL )
+ADD_STRING ( "xmga_display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
+ADD_BOOL ( "xmga_altfullscreen", NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
MODULE_CONFIG_STOP
MODULE_INIT_START
int i_width; /* width of main window */
int i_height; /* height of main window */
+ boolean_t b_altfullscreen; /* which fullscreen method */
/* Backup of window position and size before fullscreen switch */
int i_width_backup;
return( 1 );
}
- /* Open display, unsing 'vlc_display' or DISPLAY environment variable */
- psz_display = XDisplayName( main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) );
+ /* Open display, unsing the "display" config variable or the DISPLAY
+ * environment variable */
+ psz_display = config_GetPszVariable( "xmga_display" );
p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( p_vout->p_sys->p_display == NULL ) /* error */
{
- intf_ErrMsg( "vout error: cannot open display %s", psz_display );
+ intf_ErrMsg( "vout error: cannot open display %s",
+ XDisplayName( psz_display ) );
free( p_vout->p_sys );
+ if( psz_display ) free( psz_display );
return( 1 );
}
+ if( psz_display ) free( psz_display );
+
p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display );
/* Create blank cursor (for mouse cursor autohiding) */
return( 1 );
}
- /* Disable screen saver and return */
+ /* Disable screen saver */
DisableXScreenSaver( p_vout );
+ /* Misc init */
+ p_vout->p_sys->b_altfullscreen = 0;
+
return( 0 );
}
switch( p_vout->p_sys->i_screen_depth )
{
case 8: /* FIXME: set the palette */
- p_vout->output.i_chroma = FOURCC_BI_RGB; break;
+ p_vout->output.i_chroma = FOURCC_RGB2; break;
case 15:
p_vout->output.i_chroma = FOURCC_RV15; break;
case 16:
p_vout->output.i_chroma = FOURCC_RV16; break;
case 24:
- p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; break;
+ p_vout->output.i_chroma = FOURCC_RV24; break;
case 32:
- p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; break;
+ p_vout->output.i_chroma = FOURCC_RV32; break;
default:
intf_ErrMsg( "vout error: unknown screen depth" );
return( 0 );
boolean_t b_map_notify;
/* Set main window's size */
- if( p_vout->render.i_height * p_vout->render.i_aspect
- >= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
- {
- p_vout->p_sys->i_width = p_vout->render.i_height
- * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
- p_vout->p_sys->i_height = p_vout->render.i_height;
- }
- else
- {
- p_vout->p_sys->i_width = p_vout->render.i_width;
- p_vout->p_sys->i_height = p_vout->render.i_width
- * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
- }
-
-#if 0
- if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
- {
- p_vout->p_sys->i_width <<= 1;
- p_vout->p_sys->i_height <<= 1;
- }
- else if( p_vout->p_sys->i_width <= 400
- && p_vout->p_sys->i_height <= 400 )
- {
- p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
- p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
- }
-#endif
+ p_vout->p_sys->i_width = p_vout->i_window_width;
+ p_vout->p_sys->i_height = p_vout->i_window_height;
/* Prepare window manager hints and properties */
xsize_hints.base_width = p_vout->p_sys->i_width;
mwmhints_t mwmhints;
int i_xpos, i_ypos, i_width, i_height;
XEvent xevent;
-#ifdef ALTERNATE_FULLSCREEN
XSetWindowAttributes attributes;
-#endif
p_vout->b_fullscreen = !p_vout->b_fullscreen;
intf_WarnMsg( 3, "vout: entering fullscreen mode" );
+ /* Only check the fullscreen method when we actually go fullscreen,
+ * because to go back to window mode we need to know in which
+ * fullscreen mode we where */
+ p_vout->p_sys->b_altfullscreen =
+ config_GetIntVariable( "xmga_altfullscreen" );
+
/* Save current window coordinates so they can be restored when
* we exit from fullscreen mode. This is the tricky part because
* this heavily depends on the behaviour of the window manager.
i_height = DisplayHeight( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
-#if 0
- /* Being a transient window allows us to really be fullscreen (display
- * over the taskbar for instance) but then we end-up with the same
- * result as with the brute force method */
- XSetTransientForHint( p_vout->p_sys->p_display,
- p_vout->p_sys->window, None );
-#endif
}
else
{
* The other way is to use the motif property "_MOTIF_WM_HINTS" which
* luckily seems to be supported by most window managers.
*/
-#ifndef ALTERNATE_FULLSCREEN
- mwmhints.flags = MWM_HINTS_DECORATIONS;
- mwmhints.decorations = !p_vout->b_fullscreen;
-
- prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",
- False );
- XChangeProperty( p_vout->p_sys->p_display, p_vout->p_sys->window,
- prop, prop, 32, PropModeReplace,
- (unsigned char *)&mwmhints,
- PROP_MWM_HINTS_ELEMENTS );
-
-#else
- /* brute force way to remove decorations */
- attributes.override_redirect = p_vout->b_fullscreen;
- XChangeWindowAttributes( p_vout->p_sys->p_display,
- p_vout->p_sys->window,
- CWOverrideRedirect,
- &attributes);
-#endif
+ if( !p_vout->p_sys->b_altfullscreen )
+ {
+ mwmhints.flags = MWM_HINTS_DECORATIONS;
+ mwmhints.decorations = !p_vout->b_fullscreen;
+
+ prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",
+ False );
+ XChangeProperty( p_vout->p_sys->p_display, p_vout->p_sys->window,
+ prop, prop, 32, PropModeReplace,
+ (unsigned char *)&mwmhints,
+ PROP_MWM_HINTS_ELEMENTS );
+ }
+ else
+ {
+ /* brute force way to remove decorations */
+ attributes.override_redirect = p_vout->b_fullscreen;
+ XChangeWindowAttributes( p_vout->p_sys->p_display,
+ p_vout->p_sys->window,
+ CWOverrideRedirect,
+ &attributes);
+ }
/* We need to unmap and remap the window if we want the window
* manager to take our changes into effect */
}
}
-#ifdef ALTERNATE_FULLSCREEN
- XSetInputFocus(p_vout->p_sys->p_display,
- p_vout->p_sys->window,
- RevertToParent,
- CurrentTime);
-#endif
+ if( p_vout->p_sys->b_altfullscreen )
+ XSetInputFocus(p_vout->p_sys->p_display,
+ p_vout->p_sys->window,
+ RevertToParent,
+ CurrentTime);
/* signal that the size needs to be updated */
p_vout->p_sys->i_width = i_width;