diff options
author | wm4 <wm4@nowhere> | 2017-04-21 07:30:03 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-04-21 07:30:03 +0200 |
commit | 927afa311d4a89b022305508acbf4e7325fe3928 (patch) | |
tree | 4c6aafa3fb81e67fffdfd991f9cf96693e6f3fda | |
parent | 4d1eab6e552681ef961ce48af74f6795e7077fc6 (diff) |
build: make various x11 protocol extension libs mandatory
Reduces the ifdeffery, which is good and will avoid silent breakages, or
weird behavior if a lib is omitted.
Also reorder the x11_common.c include statements.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | video/out/vo_x11.c | 14 | ||||
-rw-r--r-- | video/out/vo_xv.c | 14 | ||||
-rw-r--r-- | video/out/x11_common.c | 68 | ||||
-rw-r--r-- | wscript | 26 |
5 files changed, 38 insertions, 87 deletions
@@ -89,7 +89,8 @@ to the *prefix* after it is compiled. Essential dependencies (incomplete list): - gcc or clang -- X development headers (xlib, X extensions, libvdpau, libGL, libXv, ...) +- X development headers (xlib, xrandr, xext, xscrnsaver, xinerama, libvdpau, + libGL, libXv, ...) - Audio output development headers (libasound/ALSA, pulseaudio) - FFmpeg libraries (libavutil libavcodec libavformat libswscale libavfilter and either libswresample or libavresample) diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 34a307bfbb..dd2d942c9a 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -37,7 +37,7 @@ #include "x11_common.h" -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM #include <sys/ipc.h> #include <sys/shm.h> #include <X11/extensions/XShm.h> @@ -79,7 +79,7 @@ struct priv { int current_buf; bool reset_view; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM int Shmem_Flag; XShmSegmentInfo Shminfo[2]; int Shm_Warned_Slow; @@ -91,7 +91,7 @@ static bool resize(struct vo *vo); static bool getMyXImage(struct priv *p, int foo) { struct vo *vo = p->vo; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM if (vo->x11->display_is_local && XShmQueryExtension(vo->x11->display)) { p->Shmem_Flag = 1; vo->x11->ShmCompletionEvent = XShmGetEventBase(vo->x11->display) @@ -147,7 +147,7 @@ shmemerror: } p->myximage[foo]->data = calloc(1, p->myximage[foo]->bytes_per_line * p->image_height + 32); -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM } #endif return true; @@ -155,7 +155,7 @@ shmemerror: static void freeMyXImage(struct priv *p, int foo) { -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM struct vo *vo = p->vo; if (p->Shmem_Flag) { XShmDetach(vo->x11->display, &p->Shminfo[foo]); @@ -284,7 +284,7 @@ static void Display_Image(struct priv *p, XImage *myximage) p->reset_view = false; } -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM if (p->Shmem_Flag) { XShmPutImage(vo->x11->display, vo->x11->window, p->gc, x_image, 0, 0, p->dst.x0, p->dst.y0, p->dst_w, p->dst_h, @@ -312,7 +312,7 @@ static struct mp_image get_x_buffer(struct priv *p, int buf_index) static void wait_for_completion(struct vo *vo, int max_outstanding) { -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM struct priv *ctx = vo->priv; struct vo_x11_state *x11 = vo->x11; if (ctx->Shmem_Flag) { diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index cbc64433ee..a866266f89 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -30,7 +30,7 @@ #include "config.h" -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> @@ -93,7 +93,7 @@ struct xvctx { GC f_gc; // used to paint background GC vo_gc; // used to paint video int Shmem_Flag; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM XShmSegmentInfo Shminfo[MAX_BUFFERS]; int Shm_Warned_Slow; #endif @@ -537,7 +537,7 @@ static bool allocate_xvimage(struct vo *vo, int foo) int aligned_w = FFALIGN(ctx->image_width, 32); // round up the height to next chroma boundary too int aligned_h = FFALIGN(ctx->image_height, 2); -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM if (x11->display_is_local && XShmQueryExtension(x11->display)) { ctx->Shmem_Flag = 1; x11->ShmCompletionEvent = XShmGetEventBase(x11->display) @@ -599,7 +599,7 @@ static bool allocate_xvimage(struct vo *vo, int foo) static void deallocate_xvimage(struct vo *vo, int foo) { struct xvctx *ctx = vo->priv; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM if (ctx->Shmem_Flag) { XShmDetach(vo->x11->display, &ctx->Shminfo[foo]); shmdt(ctx->Shminfo[foo].shmaddr); @@ -612,7 +612,7 @@ static void deallocate_xvimage(struct vo *vo, int foo) XFree(ctx->xvimage[foo]); ctx->xvimage[foo] = NULL; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM ctx->Shminfo[foo] = (XShmSegmentInfo){0}; #endif @@ -628,7 +628,7 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi) struct mp_rect *dst = &ctx->dst_rect; int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; int sw = src->x1 - src->x0, sh = src->y1 - src->y0; -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM if (ctx->Shmem_Flag) { XvShmPutImage(x11->display, ctx->xv_port, x11->window, ctx->vo_gc, xvi, src->x0, src->y0, sw, sh, @@ -672,7 +672,7 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index) static void wait_for_completion(struct vo *vo, int max_outstanding) { -#if HAVE_SHM && HAVE_XEXT +#if HAVE_SHM struct xvctx *ctx = vo->priv; struct vo_x11_state *x11 = vo->x11; if (ctx->Shmem_Flag) { diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 6f3cc41637..26f861be06 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -22,6 +22,23 @@ #include <limits.h> #include <unistd.h> #include <poll.h> +#include <string.h> +#include <assert.h> + +#include <X11/Xmd.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xatom.h> +#include <X11/keysym.h> +#include <X11/XKBlib.h> +#include <X11/XF86keysym.h> + +#include <X11/extensions/scrnsaver.h> +#include <X11/extensions/dpms.h> +#include <X11/extensions/Xinerama.h> +#include <X11/extensions/Xrandr.h> + +#include <zlib.h> #include "config.h" #include "misc/bstr.h" @@ -34,10 +51,6 @@ #include "x11_common.h" #include "mpv_talloc.h" -#include <string.h> -#include <unistd.h> -#include <assert.h> - #include "vo.h" #include "win_state.h" #include "osdep/io.h" @@ -47,34 +60,6 @@ // Specifically for mp_cancel #include "stream/stream.h" -#include <X11/Xmd.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xatom.h> -#include <X11/keysym.h> -#include <X11/XKBlib.h> -#include <X11/XF86keysym.h> - -#if HAVE_XSS -#include <X11/extensions/scrnsaver.h> -#endif - -#if HAVE_XEXT -#include <X11/extensions/dpms.h> -#endif - -#if HAVE_XINERAMA -#include <X11/extensions/Xinerama.h> -#endif - -#if HAVE_XRANDR -#include <X11/extensions/Xrandr.h> -#endif - -#if HAVE_ZLIB -#include <zlib.h> -#endif - #include "input/input.h" #include "input/keycodes.h" @@ -369,7 +354,6 @@ static int vo_wm_detect(struct vo *vo) static void xrandr_read(struct vo_x11_state *x11) { -#if HAVE_XRANDR for(int i = 0; i < x11->num_displays; i++) talloc_free(x11->displays[i].name); @@ -434,7 +418,6 @@ static void xrandr_read(struct vo_x11_state *x11) } XRRFreeScreenResources(r); -#endif } static void vo_x11_update_screeninfo(struct vo *vo) @@ -443,7 +426,6 @@ static void vo_x11_update_screeninfo(struct vo *vo) struct vo_x11_state *x11 = vo->x11; bool all_screens = opts->fullscreen && opts->fsscreen_id == -2; x11->screenrc = (struct mp_rect){.x1 = x11->ws_width, .y1 = x11->ws_height}; -#if HAVE_XINERAMA if (opts->screen_id >= -1 && XineramaIsActive(x11->display) && !all_screens) { int screen = opts->fullscreen ? opts->fsscreen_id : opts->screen_id; @@ -476,7 +458,6 @@ static void vo_x11_update_screeninfo(struct vo *vo) XFree(screens); } -#endif } // Get the monitors for the 4 edges of the rectangle spanning all screens. @@ -484,7 +465,6 @@ static void vo_x11_get_bounding_monitors(struct vo_x11_state *x11, long b[4]) { //top bottom left right b[0] = b[1] = b[2] = b[3] = 0; -#if HAVE_XINERAMA int num_screens = 0; XineramaScreenInfo *screens = XineramaQueryScreens(x11->display, &num_screens); if (!screens) @@ -501,7 +481,6 @@ static void vo_x11_get_bounding_monitors(struct vo_x11_state *x11, long b[4]) b[3] = n; } XFree(screens); -#endif } static void *screensaver_thread(void *arg) @@ -1337,7 +1316,6 @@ static void vo_x11_xembed_send_message(struct vo_x11_state *x11, long m[4]) XSendEvent(x11->display, x11->parent, False, NoEventMask, &ev); } -#if HAVE_ZLIB static bstr decompress_gz(bstr in) { bstr res = {0}; @@ -1380,12 +1358,6 @@ static bstr decompress_gz(bstr in) error: return res; } -#else -static bstr decompress_gz(bstr in) -{ - return (bstr){0}; -} -#endif #define MAX_ICONS 10 @@ -1978,9 +1950,6 @@ static void xscreensaver_heartbeat(struct vo_x11_state *x11) static int xss_suspend(Display *mDisplay, Bool suspend) { -#if !HAVE_XSS - return 0; -#else int event, error, major, minor; if (XScreenSaverQueryExtension(mDisplay, &event, &error) != True || XScreenSaverQueryVersion(mDisplay, &major, &minor) != True) @@ -1989,7 +1958,6 @@ static int xss_suspend(Display *mDisplay, Bool suspend) return 0; XScreenSaverSuspend(mDisplay, suspend); return 1; -#endif } static void set_screensaver(struct vo_x11_state *x11, bool enabled) @@ -2001,7 +1969,6 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled) x11->screensaver_enabled = enabled; if (xss_suspend(mDisplay, !enabled)) return; -#if HAVE_XEXT int nothing; if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) { BOOL onoff = 0; @@ -2022,7 +1989,6 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled) MP_WARN(x11, "DPMS state could not be set.\n"); } } -#endif } static void vo_x11_selectinput_witherr(struct vo *vo, @@ -579,33 +579,17 @@ video_output_features = [ } , { 'name': '--x11', 'desc': 'X11', - 'func': check_pkg_config('x11'), - } , { - 'name': '--xss', - 'desc': 'Xss screensaver extensions', - 'deps': [ 'x11' ], - 'func': check_pkg_config('xscrnsaver'), - } , { - 'name': '--xext', - 'desc': 'X extensions', - 'deps': [ 'x11' ], - 'func': check_pkg_config('xext'), + 'func': check_pkg_config('x11', '>= 1.0.0', + 'xscrnsaver', '>= 1.0.0', + 'xext', '>= 1.0.0', + 'xinerama', '>= 1.0.0', + 'xrandr', '>= 1.2.0'), } , { 'name': '--xv', 'desc': 'Xv video output', 'deps': [ 'x11' ], 'func': check_pkg_config('xv'), } , { - 'name': '--xinerama', - 'desc': 'Xinerama', - 'deps': [ 'x11' ], - 'func': check_pkg_config('xinerama'), - }, { - 'name': '--xrandr', - 'desc': 'Xrandr', - 'deps': [ 'x11' ], - 'func': check_pkg_config('xrandr', '>= 1.2.0'), - } , { 'name': '--gl-cocoa', 'desc': 'OpenGL Cocoa Backend', 'deps': [ 'cocoa' ], |