[Mplayer-cvslog] CVS: main/Gui/wm ws.c,1.56,1.57 ws.h,1.20,1.21

Jürgen Keil jkeil at mplayerhq.hu
Sat Oct 19 21:55:02 CEST 2002


Update of /cvsroot/mplayer/main/Gui/wm
In directory mail:/var/tmp.root/cvs-serv22700

Modified Files:
	ws.c ws.h 
Log Message:
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.


Index: ws.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/ws.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- ws.c	19 Oct 2002 19:47:16 -0000	1.56
+++ ws.c	19 Oct 2002 19:54:59 -0000	1.57
@@ -262,7 +262,6 @@
  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 @@
 
 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 @@
  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 @@
 
 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 @@
   {
    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 @@
   }
   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 );

Index: ws.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/ws.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ws.h	11 Aug 2002 13:12:38 -0000	1.20
+++ ws.h	19 Oct 2002 19:54:59 -0000	1.21
@@ -155,7 +155,6 @@
  XGCValues            wGCV;
  unsigned long        WindowMask;
  XVisualInfo          VisualInfo;
- XWindowAttributes    Attribs;
  XSetWindowAttributes WindowAttrib;
  XSizeHints           SizeHint;
  XWMHints             WMHints;




More information about the MPlayer-cvslog mailing list