summaryrefslogtreecommitdiffstats
path: root/Gui
diff options
context:
space:
mode:
authorjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-19 19:54:59 +0000
committerjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-19 19:54:59 +0000
commitb885bda73aa4bb0e988975558dd32c0028640c43 (patch)
tree91b76429e20807144eb805046748ac956a8333e7 /Gui
parentf636151e5f0e92e106cc026d01974511e6eb05a3 (diff)
downloadmpv-b885bda73aa4bb0e988975558dd32c0028640c43.tar.bz2
mpv-b885bda73aa4bb0e988975558dd32c0028640c43.tar.xz
Choose a good visual from the list of supported visuals on the X11 server,
instead of using the attributes from the root window. A framebuffer in a Sun often runs using a default visual of 8-bit pseudocolor, yet a better 24 or 32 bit truecolor visual is available. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7803 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui')
-rw-r--r--Gui/wm/ws.c65
-rw-r--r--Gui/wm/ws.h1
2 files changed, 41 insertions, 25 deletions
diff --git a/Gui/wm/ws.c b/Gui/wm/ws.c
index a9a1e44d8d..ed6512ae16 100644
--- a/Gui/wm/ws.c
+++ b/Gui/wm/ws.c
@@ -262,7 +262,6 @@ wsXDNDInitialize();
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Display name: %s => %s display.\n",dispname,localdisp?"local":"REMOTE");
if (!localdisp) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Remote display, disabling XMITSHM\n");
}
-
if ( !XShmQueryExtension( wsDisplay ) )
{
mp_msg( MSGT_GPLAYER,MSGL_ERR,"[ws] sorry, your system is not supported X shared memory extension.\n" );
@@ -367,6 +366,8 @@ Window LeaderWindow;
void wsCreateWindow( wsTWindow * win,int X,int Y,int wX,int hY,int bW,int cV,unsigned char D,char * label )
{
+ int depth;
+
win->Property=D;
if ( D & wsShowFrame ) win->Decorations=1;
wsHGC=DefaultGC( wsDisplay,wsScreen );
@@ -399,13 +400,13 @@ void wsCreateWindow( wsTWindow * win,int X,int Y,int wX,int hY,int bW,int cV,uns
win->wsCursorPixmap=XCreateBitmapFromData( wsDisplay,wsRootWin,win->wsCursorData,1,1 );
if ( !(cV & wsShowMouseCursor) ) win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 );
- XGetWindowAttributes( wsDisplay,wsRootWin,&win->Attribs );
- if ( win->Attribs.depth < 15 )
+ depth = vo_find_depth_from_visuals( wsDisplay,wsScreen,NULL );
+ if ( depth < 15 )
{
mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, this color depth is not enough.\n" );
exit( 0 );
}
- XMatchVisualInfo( wsDisplay,wsScreen,win->Attribs.depth,TrueColor,&win->VisualInfo );
+ XMatchVisualInfo( wsDisplay,wsScreen,depth,TrueColor,&win->VisualInfo );
// ---
win->AtomLeaderClient=XInternAtom( wsDisplay,"WM_CLIENT_LEADER",False );
@@ -1139,24 +1140,40 @@ void wsVisibleMouse( wsTWindow * win,int m )
int wsGetDepthOnScreen( void )
{
- int bpp,ibpp;
- XImage * mXImage;
- XWindowAttributes attribs;
-
- mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
- bpp=mXImage->bits_per_pixel;
-
- XGetWindowAttributes( wsDisplay,wsRootWin,&attribs );
- ibpp=attribs.depth;
- mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
- bpp=mXImage->bits_per_pixel;
- if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp;
- wsDepthOnScreen=ibpp;
- wsRedMask=mXImage->red_mask;
- wsGreenMask=mXImage->green_mask;
- wsBlueMask=mXImage->blue_mask;
- XDestroyImage( mXImage );
- return ibpp;
+ int depth;
+ XImage * mXImage;
+ Visual * visual;
+
+ if( (depth = vo_find_depth_from_visuals( wsDisplay,wsScreen,&visual )) > 0 )
+ {
+ mXImage = XCreateImage( wsDisplay,visual,depth,ZPixmap,0,NULL,
+ 1,1,32,0 );
+ wsDepthOnScreen = mXImage->bits_per_pixel;
+ wsRedMask=mXImage->red_mask;
+ wsGreenMask=mXImage->green_mask;
+ wsBlueMask=mXImage->blue_mask;
+ XDestroyImage( mXImage );
+ }
+ else
+ {
+ int bpp,ibpp;
+ XWindowAttributes attribs;
+
+ mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
+ bpp=mXImage->bits_per_pixel;
+
+ XGetWindowAttributes( wsDisplay,wsRootWin,&attribs );
+ ibpp=attribs.depth;
+ mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap );
+ bpp=mXImage->bits_per_pixel;
+ if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp;
+ wsDepthOnScreen=ibpp;
+ wsRedMask=mXImage->red_mask;
+ wsGreenMask=mXImage->green_mask;
+ wsBlueMask=mXImage->blue_mask;
+ XDestroyImage( mXImage );
+ }
+ return wsDepthOnScreen;
}
void wsXDone( void )
@@ -1195,7 +1212,7 @@ void wsCreateImage( wsTWindow * win,int Width,int Height )
{
CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion;
win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual,
- win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height );
+ win->VisualInfo.depth,ZPixmap,NULL,&win->Shminfo,Width,Height );
if ( win->xImage == NULL )
{
mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" );
@@ -1224,7 +1241,7 @@ void wsCreateImage( wsTWindow * win,int Width,int Height )
}
else
{
- win->xImage=XCreateImage( wsDisplay,win->VisualInfo.visual,win->Attribs.depth,
+ win->xImage=XCreateImage( wsDisplay,win->VisualInfo.visual,win->VisualInfo.depth,
ZPixmap,0,0,Width,Height,
(wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen,
0 );
diff --git a/Gui/wm/ws.h b/Gui/wm/ws.h
index 332abdcbf1..1b6cbe9dea 100644
--- a/Gui/wm/ws.h
+++ b/Gui/wm/ws.h
@@ -155,7 +155,6 @@ typedef struct
XGCValues wGCV;
unsigned long WindowMask;
XVisualInfo VisualInfo;
- XWindowAttributes Attribs;
XSetWindowAttributes WindowAttrib;
XSizeHints SizeHint;
XWMHints WMHints;