# HG changeset patch # User ib # Date 1326392516 0 # Node ID 3c1a1038bfc7f89ded5f2b893c0c82100ce4d079 # Parent 251018f5254b4912c022624a393b92cce04a911c Properly handle the lack of XShm. The GUI compiles and runs fine without HAVE_SHM now. diff -r 251018f5254b -r 3c1a1038bfc7 gui/wm/ws.c --- a/gui/wm/ws.c Thu Jan 12 16:14:20 2012 +0000 +++ b/gui/wm/ws.c Thu Jan 12 18:21:56 2012 +0000 @@ -59,7 +59,9 @@ #endif #include +#ifdef HAVE_SHM #include +#endif #define MOUSEHIDE_DELAY 1000 // in milliseconds @@ -266,8 +268,10 @@ 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 @@ 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 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 @@ 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 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 @@ 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, diff -r 251018f5254b -r 3c1a1038bfc7 gui/wm/ws.h --- a/gui/wm/ws.h Thu Jan 12 16:14:20 2012 +0000 +++ b/gui/wm/ws.h Thu Jan 12 18:21:56 2012 +0000 @@ -28,7 +28,9 @@ #include #include #include +#ifdef HAVE_SHM #include +#endif #define wsKeyReleased 0 #define wsKeyPressed 1 @@ -158,7 +160,9 @@ Atom AtomWMSizeHint; Atom AtomWMNormalHint; +#ifdef HAVE_SHM XShmSegmentInfo Shminfo; +#endif unsigned char *ImageData; unsigned short int *ImageDataw; unsigned int *ImageDatadw;