static int glw_x11_init(glw_x11_t *gx11) { int attribs[10]; int na = 0; XInitThreads(); int use_locales = XSupportsLocale() && XSetLocaleModifiers("") != NULL; if((gx11->display = XOpenDisplay(gx11->displayname_real)) == NULL) { TRACE(TRACE_ERROR, "GLW", "Unable to open X display \"%s\"\n", gx11->displayname_real); return 1; } if(!glXQueryExtension(gx11->display, NULL, NULL)) { TRACE(TRACE_ERROR, "GLW", "OpenGL GLX extension not supported by display \"%s\"\n", gx11->displayname_real); return 1; } gx11->screen = DefaultScreen(gx11->display); gx11->screen_width = DisplayWidth(gx11->display, gx11->screen); gx11->screen_height = DisplayHeight(gx11->display, gx11->screen); gx11->root = RootWindow(gx11->display, gx11->screen); attribs[na++] = GLX_RGBA; attribs[na++] = GLX_RED_SIZE; attribs[na++] = 1; attribs[na++] = GLX_GREEN_SIZE; attribs[na++] = 1; attribs[na++] = GLX_BLUE_SIZE; attribs[na++] = 1; attribs[na++] = GLX_DOUBLEBUFFER; attribs[na++] = None; gx11->xvi = glXChooseVisual(gx11->display, gx11->screen, attribs); if(gx11->xvi == NULL) { TRACE(TRACE_ERROR, "GLW", "Unable to find an adequate Visual on \"%s\"\n", gx11->displayname_real); return 1; } if(GLXExtensionSupported(gx11->display, "GLX_SGI_swap_control")) { TRACE(TRACE_DEBUG, "GLW", "GLX_SGI_swap_control extension is present"); gx11->glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); } build_blank_cursor(gx11); if(use_locales) gx11->im = XOpenIM(gx11->display, NULL, NULL, NULL); gx11->atom_deletewindow = XInternAtom(gx11->display, "WM_DELETE_WINDOW", 0); #if ENABLE_VDPAU if(GLXExtensionSupported(gx11->display, "GLX_EXT_texture_from_pixmap")) { gx11->gr.gr_be.gbr_bind_tex_image = (PFNGLXBINDTEXIMAGEEXTPROC) glXGetProcAddress((const GLubyte*)"glXBindTexImageEXT"); gx11->gr.gr_be.gbr_release_tex_image = (PFNGLXRELEASETEXIMAGEEXTPROC) glXGetProcAddress((const GLubyte*)"glXReleaseTexImageEXT"); gx11->gr.gr_be.gbr_vdpau_dev = vdpau_init_x11(gx11->display, gx11->screen, vdpau_preempted, gx11); } else { TRACE(TRACE_DEBUG, "VDPAU", "GLX_EXT_texture_from_pixmap extension not present, disabling VDPAU"); } #endif probe_wm(gx11); gx11->is_fullscreen = gx11->want_fullscreen; int fs = 0; if(gx11->wm_flags == 0) { fs = 1; // No window manager, open in fullscreen mode } else { /* If window manager cannot do fullscreen, ask window to open in fullscreen mode */ fs = gx11->want_fullscreen && !(gx11->wm_flags & GX11_WM_CAN_FULLSCREEN); } if(window_open(gx11, fs)) return -1; // Fullscreen via window manager if(gx11->want_fullscreen && !fs) wm_set_fullscreen(gx11, 1); return 0; }
static int glw_x11_init(glw_x11_t *gx11) { int attribs[10]; int na = 0; int use_locales = XSupportsLocale() && XSetLocaleModifiers("@im=none") != NULL; if((gx11->display = XOpenDisplay(gx11->displayname_real)) == NULL) { TRACE(TRACE_ERROR, "GLW", "Unable to open X display \"%s\"\n", gx11->displayname_real); return 1; } if(!glXQueryExtension(gx11->display, NULL, NULL)) { TRACE(TRACE_ERROR, "GLW", "OpenGL GLX extension not supported by display \"%s\"\n", gx11->displayname_real); return 1; } gx11->screen = DefaultScreen(gx11->display); gx11->screen_width = DisplayWidth(gx11->display, gx11->screen); gx11->screen_height = DisplayHeight(gx11->display, gx11->screen); gx11->root = RootWindow(gx11->display, gx11->screen); attribs[na++] = GLX_RGBA; attribs[na++] = GLX_RED_SIZE; attribs[na++] = 1; attribs[na++] = GLX_GREEN_SIZE; attribs[na++] = 1; attribs[na++] = GLX_BLUE_SIZE; attribs[na++] = 1; attribs[na++] = GLX_DOUBLEBUFFER; attribs[na++] = None; gx11->xvi = glXChooseVisual(gx11->display, gx11->screen, attribs); if(gx11->xvi == NULL) { TRACE(TRACE_ERROR, "GLW", "Unable to find an adequate Visual on \"%s\"\n", gx11->displayname_real); return 1; } if(GLXExtensionSupported(gx11->display, "GLX_SGI_swap_control")) { TRACE(TRACE_DEBUG, "GLW", "GLX_SGI_swap_control extension is present"); gx11->glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); } build_blank_cursor(gx11); if(use_locales) gx11->im = XOpenIM(gx11->display, NULL, NULL, NULL); gx11->atom_deletewindow = XInternAtom(gx11->display, "WM_DELETE_WINDOW", 0); #if ENABLE_VDPAU gx11->gr.gr_be.gbr_glVDPAUInitNV = (PFNGLVDPAUINITNVPROC) glXGetProcAddress((const GLubyte*)"glVDPAUInitNV"); if(gx11->gr.gr_be.gbr_glVDPAUInitNV != NULL) { vdpau_dev_t *vd; vd = vdpau_init_x11(gx11->display, gx11->screen, vdpau_preempted, gx11); gx11->gr.gr_be.gbr_vdpau_dev = vd; gx11->gr.gr_be.gbr_glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC) glXGetProcAddress((const GLubyte*)"glVDPAUUnregisterSurfaceNV"); gx11->gr.gr_be.gbr_glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC) glXGetProcAddress((const GLubyte*)"glVDPAUUnmapSurfacesNV"); gx11->gr.gr_be.gbr_glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) glXGetProcAddress((const GLubyte*)"glVDPAURegisterOutputSurfaceNV"); gx11->gr.gr_be.gbr_glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC) glXGetProcAddress((const GLubyte*)"glVDPAUMapSurfacesNV"); } #endif probe_wm(gx11); gx11->is_fullscreen = gx11->want_fullscreen; int fs = 0; if(gx11->wm_flags == 0) { fs = 1; // No window manager, open in fullscreen mode } else { /* If window manager cannot do fullscreen, ask window to open in fullscreen mode */ fs = gx11->want_fullscreen && !(gx11->wm_flags & GX11_WM_CAN_FULLSCREEN); } if(window_open(gx11, fs)) return -1; // Fullscreen via window manager if(gx11->want_fullscreen && !fs) wm_set_fullscreen(gx11, 1); return 0; }