⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_x11modes.c

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* Query the extension version */    if ( !SDL_NAME(XineramaQueryExtension)(SDL_Display, major, minor) ||         !SDL_NAME(XineramaIsActive)(SDL_Display) ) {        return 0;    }    return 1;}#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */#if SDL_VIDEO_DRIVER_X11_XRANDRstatic int CheckXRandR(_THIS, int *major, int *minor){    const char *env;    /* Default the extension not available */    *major = *minor = 0;    /* Allow environment override */    env = getenv("SDL_VIDEO_X11_XRANDR");    if ( env && !SDL_atoi(env) ) {        return 0;    }    /* This defaults off now, due to KDE window maximize problems */    if ( !env ) {        return 0;    }    if ( !SDL_X11_HAVE_XRANDR ) {        return 0;    }    /* Query the extension version */    if ( !XRRQueryVersion(SDL_Display, major, minor) ) {        return 0;    }    return 1;}#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */#if SDL_VIDEO_DRIVER_X11_VIDMODEstatic int CheckVidMode(_THIS, int *major, int *minor){    const char *env;    /* Default the extension not available */    *major = *minor = 0;    /* Allow environment override */    env = getenv("SDL_VIDEO_X11_VIDMODE");    if ( env && !SDL_atoi(env) ) {        return 0;    }        /* Metro-X 4.3.0 and earlier has a broken implementation of       XF86VidModeGetAllModeLines() - it hangs the client.     */    if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) {        FILE *metro_fp;        metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");        if ( metro_fp != NULL ) {            int major, minor, patch, version;            major = 0; minor = 0; patch = 0;            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);            fclose(metro_fp);            version = major*100+minor*10+patch;            if ( version < 431 ) {                return 0;            }        }    }    /* Query the extension version */    vm_error = -1;    if ( !SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) ||         !SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, major, minor) ) {        return 0;    }    return 1;}#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */#if SDL_VIDEO_DRIVER_X11_XMEstatic int CheckXME(_THIS, int *major, int *minor){    const char *env;    /* Default the extension not available */    *major = *minor = 0;    /* Allow environment override */    env = getenv("SDL_VIDEO_X11_VIDMODE");    if ( env && !SDL_atoi(env) ) {        return 0;    }        /* Query the extension version */    if ( !XiGMiscQueryVersion(SDL_Display, major, minor) ) {        return 0;    }    return 1;}#endif /* SDL_VIDEO_DRIVER_X11_XME */int X11_GetVideoModes(_THIS){#if SDL_VIDEO_DRIVER_X11_XINERAMA    int xinerama_major, xinerama_minor;#endif#if SDL_VIDEO_DRIVER_X11_XRANDR    int xrandr_major, xrandr_minor;    int nsizes;    XRRScreenSize *sizes;#endif#if SDL_VIDEO_DRIVER_X11_VIDMODE    int vm_major, vm_minor;    int nmodes;    SDL_NAME(XF86VidModeModeInfo) **modes;#endif#if SDL_VIDEO_DRIVER_X11_XME    int xme_major, xme_minor;    int ractive, nummodes;    XiGMiscResolutionInfo *modelist;#endif    int i, n;    int screen_w;    int screen_h;    use_xinerama = 0;    use_xrandr = 0;    use_vidmode = 0;    use_xme = 0;    screen_w = DisplayWidth(SDL_Display, SDL_Screen);    screen_h = DisplayHeight(SDL_Display, SDL_Screen);#if SDL_VIDEO_DRIVER_X11_XINERAMA    /* Query Xinerama extention */    if ( CheckXinerama(this, &xinerama_major, &xinerama_minor) ) {        /* Find out which screen is the desired one */        int desired = 0;        int screens;        int w, h;        SDL_NAME(XineramaScreenInfo) *xinerama;        const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");        if ( variable ) {                desired = SDL_atoi(variable);        }#ifdef X11MODES_DEBUG        printf("X11 detected Xinerama:\n");#endif        xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens);        for ( i = 0; i < screens; i++ ) {#ifdef X11MODES_DEBUG            printf("xinerama %d: %dx%d+%d+%d\n",                xinerama[i].screen_number,                xinerama[i].width, xinerama[i].height,                xinerama[i].x_org, xinerama[i].y_org);#endif            if ( xinerama[i].screen_number == desired ) {                use_xinerama = 1;                xinerama_info = xinerama[i];            }        }        XFree(xinerama);        if ( use_xinerama ) {            SDL_modelist = (SDL_Rect **)SDL_malloc(3*sizeof(SDL_Rect *));            if ( !SDL_modelist ) {                SDL_OutOfMemory();                return -1;            }            /* Add the full xinerama mode */            n = 0;            w = xinerama_info.width;            h = xinerama_info.height;            if ( screen_w > w || screen_h > h) {                SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));                if ( SDL_modelist[n] ) {                    SDL_modelist[n]->x = 0;                    SDL_modelist[n]->y = 0;                    SDL_modelist[n]->w = screen_w;                    SDL_modelist[n]->h = screen_h;                    ++n;                }            }            /* Add the head xinerama mode */            SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));            if ( SDL_modelist[n] ) {                SDL_modelist[n]->x = 0;                SDL_modelist[n]->y = 0;                SDL_modelist[n]->w = w;                SDL_modelist[n]->h = h;                ++n;            }            SDL_modelist[n] = NULL;        }    }#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */#if SDL_VIDEO_DRIVER_X11_XRANDR    /* XRandR */    /* require at least XRandR v1.0 (arbitrary) */    if ( CheckXRandR(this, &xrandr_major, &xrandr_minor) && (xrandr_major >= 1) )    {#ifdef X11MODES_DEBUG        fprintf(stderr, "XRANDR: XRRQueryVersion: V%d.%d\n",                xrandr_major, xrandr_minor);#endif        /* save the screen configuration since we must reference it           each time we toggle modes.        */        screen_config = XRRGetScreenInfo(SDL_Display, SDL_Root);        /* retrieve the list of resolution */        sizes = XRRConfigSizes(screen_config, &nsizes);        if (nsizes > 0) {            if ( SDL_modelist ) {                for ( i = 0; SDL_modelist[i]; ++i ) {                    SDL_free(SDL_modelist[i]);                }                SDL_free(SDL_modelist);            }            SDL_modelist = (SDL_Rect **)malloc((nsizes+1)*sizeof(SDL_Rect *));            if ( !SDL_modelist ) {                SDL_OutOfMemory();                return -1;            }            for ( i=0; i < nsizes; i++ ) {                if ((SDL_modelist[i] =                     (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL)                    break;#ifdef X11MODES_DEBUG                fprintf(stderr, "XRANDR: mode = %4d, w = %4d, h = %4d\n",                        i, sizes[i].width, sizes[i].height);#endif                SDL_modelist[i]->x = 0;                SDL_modelist[i]->y = 0;                SDL_modelist[i]->w = sizes[i].width;                SDL_modelist[i]->h = sizes[i].height;            }            /* sort the mode list descending as SDL expects */            SDL_qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist);            SDL_modelist[i] = NULL; /* terminator */            use_xrandr = xrandr_major * 100 + xrandr_minor;            saved_size_id = XRRConfigCurrentConfiguration(screen_config, &saved_rotation);        }    }#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */#if SDL_VIDEO_DRIVER_X11_VIDMODE    /* XVidMode */    if ( !use_xrandr &&#if SDL_VIDEO_DRIVER_X11_XINERAMA         (!use_xinerama || xinerama_info.screen_number == 0) &&#endif         CheckVidMode(this, &vm_major, &vm_minor) &&         SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) )    {#ifdef X11MODES_DEBUG        printf("VidMode modes: (unsorted)\n");        for ( i = 0; i < nmodes; ++i ) {            printf("Mode %d: %d x %d @ %d\n", i,                    modes[i]->hdisplay, modes[i]->vdisplay,                    (modes[i]->htotal && modes[i]->vtotal) ? (1000 * modes[i]->dotclock / (modes[i]->htotal * modes[i]->vtotal)) : 0 );        }#endif        if ( SDL_modelist ) {            for ( i = 0; SDL_modelist[i]; ++i ) {                SDL_free(SDL_modelist[i]);            }            SDL_free(SDL_modelist);        }        SDL_modelist = (SDL_Rect **)SDL_malloc((nmodes+2)*sizeof(SDL_Rect *));        if ( !SDL_modelist ) {            SDL_OutOfMemory();            return -1;        }        SDL_qsort(modes, nmodes, sizeof *modes, cmpmodes);        n = 0;        for ( i=0; i<nmodes; ++i ) {            int w, h;            /* Eliminate duplicate modes with different refresh rates */            if ( i > 0 &&                 modes[i]->hdisplay == modes[i-1]->hdisplay &&                 modes[i]->vdisplay == modes[i-1]->vdisplay ) {                    continue;            }            /* Check to see if we should add the screen size (Xinerama) */            w = modes[i]->hdisplay;            h = modes[i]->vdisplay;            if ( (screen_w * screen_h) >= (w * h) ) {                if ( (screen_w != w) || (screen_h != h) ) {                    SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));                    if ( SDL_modelist[n] ) {                        SDL_modelist[n]->x = 0;                        SDL_modelist[n]->y = 0;                        SDL_modelist[n]->w = screen_w;                        SDL_modelist[n]->h = screen_h;                        ++n;                    }                }                screen_w = 0;                screen_h = 0;            }            /* Add the size from the video mode list */            SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));            if ( SDL_modelist[n] == NULL ) {                break;            }            SDL_modelist[n]->x = 0;            SDL_modelist[n]->y = 0;            SDL_modelist[n]->w = w;            SDL_modelist[n]->h = h;            ++n;        }        SDL_modelist[n] = NULL;        XFree(modes);        use_vidmode = vm_major * 100 + vm_minor;        save_mode(this);    }#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */#if SDL_VIDEO_DRIVER_X11_XME    /* XiG */    modelist = NULL;    /* first lets make sure we have the extension, and it's at least v2.0 */    if ( CheckXME(this, &xme_major, &xme_minor) && xme_major >= 2 &&         (nummodes = XiGMiscQueryResolutions(SDL_Display, SDL_Screen,                                             0, /* view */                                             &ractive, &modelist)) > 1 )    {                                /* then we actually have some */        int j;        /* We get the list already sorted in descending order.           We'll copy it in reverse order so SDL is happy */#ifdef X11MODES_DEBUG        fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",                nummodes, ractive);#endif        if ( SDL_modelist ) {            for ( i = 0; SDL_modelist[i]; ++i ) {                SDL_free(SDL_modelist[i]);            }            SDL_free(SDL_modelist);        }        SDL_modelist = (SDL_Rect **)SDL_malloc((nummodes+1)*sizeof(SDL_Rect *));        if ( !SDL_modelist ) {            SDL_OutOfMemory();            return -1;        }        for ( i=0, j=nummodes-1; j>=0; i++, j-- ) {            if ((SDL_modelist[i] =                  (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect))) == NULL)              break;#ifdef X11MODES_DEBUG            fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",                   i, modelist[i].width, modelist[i].height);#endif            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -