Mercurial > mplayer.hg
changeset 34465:3c1a1038bfc7
Properly handle the lack of XShm.
The GUI compiles and runs fine without HAVE_SHM now.
author | ib |
---|---|
date | Thu, 12 Jan 2012 18:21:56 +0000 |
parents | 251018f5254b |
children | a650895d50a5 |
files | gui/wm/ws.c gui/wm/ws.h |
diffstat | 2 files changed, 21 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sys/ipc.h> +#ifdef HAVE_SHM #include <sys/shm.h> +#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,
--- 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 <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 @@ Atom AtomWMSizeHint; Atom AtomWMNormalHint; +#ifdef HAVE_SHM XShmSegmentInfo Shminfo; +#endif unsigned char *ImageData; unsigned short int *ImageDataw; unsigned int *ImageDatadw;