[MPlayer-cvslog] r34553 - in trunk/gui/wm: ws.c ws.h

ib subversion at mplayerhq.hu
Thu Jan 12 19:21:57 CET 2012


Author: ib
Date: Thu Jan 12 19:21:56 2012
New Revision: 34553

Log:
Properly handle the lack of XShm.

The GUI compiles and runs fine without HAVE_SHM now.

Modified:
   trunk/gui/wm/ws.c
   trunk/gui/wm/ws.h

Modified: trunk/gui/wm/ws.c
==============================================================================
--- trunk/gui/wm/ws.c	Thu Jan 12 17:14:20 2012	(r34552)
+++ trunk/gui/wm/ws.c	Thu Jan 12 19:21:56 2012	(r34553)
@@ -59,7 +59,9 @@
 #endif
 
 #include <sys/ipc.h>
+#ifdef HAVE_SHM
 #include <sys/shm.h>
+#endif
 
 #define MOUSEHIDE_DELAY 1000   // in milliseconds
 
@@ -266,8 +268,10 @@ void wsXInit(Display *mDisplay)
             mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_WS_RemoteDisplay);
     }
 
+#ifdef HAVE_SHM
     if (!XShmQueryExtension(wsDisplay))
-        wsUseXShm = 0;
+#endif
+    wsUseXShm = 0;
 
     if (!wsUseXShm)
         mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_WS_NoXshm);
@@ -319,12 +323,14 @@ void wsXInit(Display *mDisplay)
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws]  green mask: 0x%x\n", wsGreenMask);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws]  blue mask: 0x%x\n", wsBlueMask);
 
+#ifdef HAVE_SHM
     if (wsUseXShm) {
         int minor, major, shp;
 
         XShmQueryVersion(wsDisplay, &major, &minor, &shp);
         mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] XShm version is %d.%d\n", major, minor);
     }
+#endif
 
 #ifdef CONFIG_XSHAPE
     if (wsUseXShape) {
@@ -1071,12 +1077,15 @@ void wsConvert(wsTWindow *win, unsigned 
 
 void wsPutImage(wsTWindow *win)
 {
+#ifdef HAVE_SHM
     if (wsUseXShm) {
         XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                      0, 0,
                      (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
                      win->xImage->width, win->xImage->height, 0);
-    } else {
+    } else
+#endif
+    {
         XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                   0, 0,
                   (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
@@ -1400,10 +1409,12 @@ void wsDestroyImage(wsTWindow *win)
     if (win->xImage) {
         XDestroyImage(win->xImage);
 
+#ifdef HAVE_SHM
         if (wsUseXShm) {
             XShmDetach(wsDisplay, &win->Shminfo);
             shmdt(win->Shminfo.shmaddr);
         }
+#endif
     }
 
     win->xImage = NULL;
@@ -1411,6 +1422,7 @@ void wsDestroyImage(wsTWindow *win)
 
 void wsCreateImage(wsTWindow *win, int Width, int Height)
 {
+#ifdef HAVE_SHM
     if (wsUseXShm) {
         win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual,
                                       win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, Width, Height);
@@ -1445,7 +1457,9 @@ void wsCreateImage(wsTWindow *win, int W
         XShmAttach(wsDisplay, &win->Shminfo);
         XSync(wsDisplay, False);
         shmctl(win->Shminfo.shmid, IPC_RMID, 0);
-    } else {
+    } else
+#endif
+    {
         win->xImage = XCreateImage(wsDisplay, win->VisualInfo.visual, win->VisualInfo.depth,
                                    ZPixmap, 0, 0, Width, Height,
                                    (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen,

Modified: trunk/gui/wm/ws.h
==============================================================================
--- trunk/gui/wm/ws.h	Thu Jan 12 17:14:20 2012	(r34552)
+++ trunk/gui/wm/ws.h	Thu Jan 12 19:21:56 2012	(r34553)
@@ -28,7 +28,9 @@
 #include <X11/Xutil.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
+#ifdef HAVE_SHM
 #include <X11/extensions/XShm.h>
+#endif
 
 #define  wsKeyReleased   0
 #define  wsKeyPressed    1
@@ -158,7 +160,9 @@ typedef struct {
     Atom AtomWMSizeHint;
     Atom AtomWMNormalHint;
 
+#ifdef HAVE_SHM
     XShmSegmentInfo Shminfo;
+#endif
     unsigned char *ImageData;
     unsigned short int *ImageDataw;
     unsigned int *ImageDatadw;


More information about the MPlayer-cvslog mailing list