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

📄 sdl_x11modes.c

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 C
📖 第 1 页 / 共 3 页
字号:
            SDL_modelist[i]->x = 0;            SDL_modelist[i]->y = 0;            SDL_modelist[i]->w = modelist[j].width;            SDL_modelist[i]->h = modelist[j].height;                    }        SDL_modelist[i] = NULL; /* terminator */        use_xme = xme_major * 100 + xme_minor;        saved_res = modelist[ractive]; /* save the current resolution */    }    if ( modelist ) {        XFree(modelist);    }#endif /* SDL_VIDEO_DRIVER_X11_XME */    {	/* It's interesting to note that if we allow 32 bit depths,	   we get a visual with an alpha mask on composite servers.        static int depth_list[] = { 32, 24, 16, 15, 8 };	*/        static int depth_list[] = { 24, 16, 15, 8 };        int j, np;        int use_directcolor = 1;        XPixmapFormatValues *pf;        /* Search for the visuals in deepest-first order, so that the first           will be the richest one */        if ( SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {                use_directcolor = 0;        }        this->hidden->nvisuals = 0;        if ( ! add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID")) ) {                for ( i=0; i<SDL_arraysize(depth_list); ++i ) {                        if ( depth_list[i] > 8 ) {                                if ( use_directcolor ) {                                        add_visual(this, depth_list[i], DirectColor);                                }                                add_visual(this, depth_list[i], TrueColor);                        } else {                                add_visual(this, depth_list[i], PseudoColor);                                add_visual(this, depth_list[i], StaticColor);                        }                }        }        if ( this->hidden->nvisuals == 0 ) {            SDL_SetError("Found no sufficiently capable X11 visuals");            return -1;        }                    /* look up the pixel quantum for each depth */        pf = XListPixmapFormats(SDL_Display, &np);        for(i = 0; i < this->hidden->nvisuals; i++) {            int d = this->hidden->visuals[i].depth;            for(j = 0; j < np; j++)                if(pf[j].depth == d)                    break;            this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;        }        XFree(pf);    }    if ( SDL_modelist == NULL ) {        SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *));        if ( !SDL_modelist ) {            SDL_OutOfMemory();            return -1;        }        n = 0;        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;        }        SDL_modelist[n] = NULL;    }#ifdef X11MODES_DEBUG    if ( use_xinerama ) {        printf("Xinerama is enabled\n");    }    if ( use_xrandr ) {        printf("XRandR is enabled\n");    }    if ( use_vidmode ) {        printf("VidMode is enabled\n");    }    if ( use_xme ) {        printf("Xi Graphics XME fullscreen is enabled\n");    }    if ( SDL_modelist ) {        printf("X11 video mode list:\n");        for ( i=0; SDL_modelist[i]; ++i ) {            printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h);        }    }#endif /* X11MODES_DEBUG */    return 0;}int X11_SupportedVisual(_THIS, SDL_PixelFormat *format){    int i;    for(i = 0; i < this->hidden->nvisuals; i++)        if(this->hidden->visuals[i].bpp == format->BitsPerPixel)            return 1;    return 0;}SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags){    if ( X11_SupportedVisual(this, format) ) {        if ( flags & SDL_FULLSCREEN ) {            return(SDL_modelist);        } else {            return((SDL_Rect **)-1);        }    } else {        return((SDL_Rect **)0);    }}void X11_FreeVideoModes(_THIS){    int i;    if ( SDL_modelist ) {        for ( i=0; SDL_modelist[i]; ++i ) {            SDL_free(SDL_modelist[i]);        }        SDL_free(SDL_modelist);        SDL_modelist = NULL;    }#if SDL_VIDEO_DRIVER_X11_XRANDR    /* Free the Xrandr screen configuration */    if ( screen_config ) {        XRRFreeScreenConfigInfo(screen_config);        screen_config = NULL;    }#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */}int X11_ResizeFullScreen(_THIS){    int x = 0, y = 0;    int real_w, real_h;    int screen_w;    int screen_h;    screen_w = DisplayWidth(SDL_Display, SDL_Screen);    screen_h = DisplayHeight(SDL_Display, SDL_Screen);#if SDL_VIDEO_DRIVER_X11_XINERAMA    if ( use_xinerama &&         window_w <= xinerama_info.width &&         window_h <= xinerama_info.height ) {        x = xinerama_info.x_org;        y = xinerama_info.y_org;    }#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */    if ( currently_fullscreen ) {        /* Switch resolution and cover it with the FSwindow */        move_cursor_to(this, x, y);        set_best_resolution(this, window_w, window_h);        move_cursor_to(this, x, y);        get_real_resolution(this, &real_w, &real_h);        if ( window_w > real_w ) {            real_w = MAX(real_w, screen_w);        }        if ( window_h > real_h ) {            real_h = MAX(real_h, screen_h);        }        XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);        move_cursor_to(this, real_w/2, real_h/2);        /* Center and reparent the drawing window */        x = (real_w - window_w)/2;        y = (real_h - window_h)/2;        XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);        /* FIXME: move the mouse to the old relative location */        XSync(SDL_Display, True);   /* Flush spurious mode change events */    }    return(1);}void X11_QueueEnterFullScreen(_THIS){    switch_waiting = 0x01 | SDL_FULLSCREEN;    switch_time = SDL_GetTicks() + 1500;#if 0 /* This causes a BadMatch error if the window is iconified (not needed) */    XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);#endif}int X11_EnterFullScreen(_THIS){    int okay;#if 0    Window tmpwin, *windows;    int i, nwindows;#endif    int x = 0, y = 0;    int real_w, real_h;    int screen_w;    int screen_h;    okay = 1;    if ( currently_fullscreen ) {        return(okay);    }    /* Ungrab the input so that we can move the mouse around */    X11_GrabInputNoLock(this, SDL_GRAB_OFF);#if SDL_VIDEO_DRIVER_X11_XINERAMA    if ( use_xinerama &&         window_w <= xinerama_info.width &&         window_h <= xinerama_info.height ) {        x = xinerama_info.x_org;        y = xinerama_info.y_org;    }#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */    /* Map the fullscreen window to blank the screen */    screen_w = DisplayWidth(SDL_Display, SDL_Screen);    screen_h = DisplayHeight(SDL_Display, SDL_Screen);    get_real_resolution(this, &real_w, &real_h);    if ( window_w > real_w ) {        real_w = MAX(real_w, screen_w);    }    if ( window_h > real_h ) {        real_h = MAX(real_h, screen_h);    }    XMoveResizeWindow(SDL_Display, FSwindow,                      x, y, real_w, real_h);    XMapRaised(SDL_Display, FSwindow);    X11_WaitMapped(this, FSwindow);#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */    /* Make sure we got to the top of the window stack */    if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,                            &windows, &nwindows) && windows ) {        /* If not, try to put us there - if fail... oh well */        if ( windows[nwindows-1] != FSwindow ) {            tmpwin = windows[nwindows-1];            for ( i=0; i<nwindows; ++i ) {                if ( windows[i] == FSwindow ) {                    SDL_memcpy(&windows[i], &windows[i+1],                           (nwindows-i-1)*sizeof(windows[i]));                    break;                }            }            windows[nwindows-1] = FSwindow;            XRestackWindows(SDL_Display, windows, nwindows);            XSync(SDL_Display, False);        }        XFree(windows);    }#else    XRaiseWindow(SDL_Display, FSwindow);#endif#if SDL_VIDEO_DRIVER_X11_VIDMODE    /* Save the current video mode */    if ( use_vidmode ) {        SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, True);    }#endif    currently_fullscreen = 1;    /* Set the new resolution */    okay = X11_ResizeFullScreen(this);    if ( ! okay ) {        X11_LeaveFullScreen(this);    }    /* Set the colormap */    if ( SDL_XColorMap ) {        XInstallColormap(SDL_Display, SDL_XColorMap);    }    if ( okay ) {        X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);    }    /* We may need to refresh the screen at this point (no backing store)       We also don't get an event, which is why we explicitly refresh. */    if ( this->screen ) {        if ( this->screen->flags & SDL_OPENGL ) {            SDL_PrivateExpose();        } else {            X11_RefreshDisplay(this);        }    }    return(okay);}int X11_LeaveFullScreen(_THIS){    if ( currently_fullscreen ) {        XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);#if SDL_VIDEO_DRIVER_X11_VIDMODE        if ( use_vidmode ) {            restore_mode(this);            SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False);        }#endif#if SDL_VIDEO_DRIVER_X11_XME        if ( use_xme ) {            int rw, rh;                                /* check current mode so we can avoid uneccessary mode changes */            get_real_resolution(this, &rw, &rh);            if (rw != saved_res.width || rh != saved_res.height) {                XiGMiscChangeResolution(SDL_Display,                                         SDL_Screen,                                        0, /* view */                                        saved_res.width,                                         saved_res.height,                                        0);                XSync(SDL_Display, False);            }        }#endif#if SDL_VIDEO_DRIVER_X11_XRANDR        if ( use_xrandr ) {            XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root,                               saved_size_id, saved_rotation, CurrentTime);        }#endif        XUnmapWindow(SDL_Display, FSwindow);        X11_WaitUnmapped(this, FSwindow);        XSync(SDL_Display, True);   /* Flush spurious mode change events */        currently_fullscreen = 0;    }    /* If we get popped out of fullscreen mode for some reason, input_grab       will still have the SDL_GRAB_FULLSCREEN flag set, since this is only       temporary.  In this case, release the grab unless the input has been       explicitly grabbed.     */    X11_GrabInputNoLock(this, this->input_grab & ~SDL_GRAB_FULLSCREEN);    /* We may need to refresh the screen at this point (no backing store)       We also don't get an event, which is why we explicitly refresh. */    if ( this->screen ) {        if ( this->screen->flags & SDL_OPENGL ) {            SDL_PrivateExpose();        } else {            X11_RefreshDisplay(this);        }    }    return(0);}

⌨️ 快捷键说明

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