📄 xopendis.c
字号:
OutOfMemory(dpy, setup); UnlockMutex(&lock); return (NULL); } vendorlen = u.setup->nbytesVendor; u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup); (void) strncpy(dpy->vendor, u.vendor, vendorlen); dpy->vendor[vendorlen] = '\0'; vendorlen = (vendorlen + 3) & ~3; /* round up */ bcopy (u.vendor + vendorlen, setup, (int) setuplength - sz_xConnSetup - vendorlen); u.vendor = setup;/* * Now iterate down setup information..... */ dpy->pixmap_format = (ScreenFormat *)Xmalloc( (unsigned) (dpy->nformats *sizeof(ScreenFormat))); if (dpy->pixmap_format == NULL) { OutOfMemory (dpy, setup); UnlockMutex(&lock); return(NULL); }/* * First decode the Z axis Screen format information. */ for (i = 0; i < dpy->nformats; i++) { register ScreenFormat *fmt = &dpy->pixmap_format[i]; fmt->depth = u.sf->depth; fmt->bits_per_pixel = u.sf->bitsPerPixel; fmt->scanline_pad = u.sf->scanLinePad; fmt->ext_data = NULL; u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat); }/* * next the Screen structures. */ dpy->screens = (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen)); if (dpy->screens == NULL) { OutOfMemory (dpy, setup); UnlockMutex(&lock); return(NULL); }/* * Now go deal with each screen structure. */ for (i = 0; i < dpy->nscreens; i++) { register Screen *sp = &dpy->screens[i]; VisualID root_visualID = u.rp->rootVisualID; sp->display = dpy; sp->root = u.rp->windowId; sp->cmap = u.rp->defaultColormap; sp->white_pixel = u.rp->whitePixel; sp->black_pixel = u.rp->blackPixel; sp->root_input_mask = u.rp->currentInputMask; sp->width = u.rp->pixWidth; sp->height = u.rp->pixHeight; sp->mwidth = u.rp->mmWidth; sp->mheight = u.rp->mmHeight; sp->min_maps = u.rp->minInstalledMaps; sp->max_maps = u.rp->maxInstalledMaps; sp->root_visual = NULL; /* filled in later, when we alloc Visuals */ sp->backing_store= u.rp->backingStore; sp->save_unders = u.rp->saveUnders; sp->root_depth = u.rp->rootDepth; sp->ndepths = u.rp->nDepths; sp->ext_data = NULL; u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);/* * lets set up the depth structures. */ sp->depths = (Depth *)Xmalloc( (unsigned)sp->ndepths*sizeof(Depth)); if (sp->depths == NULL) { OutOfMemory (dpy, setup); UnlockMutex(&lock); return(NULL); } /* * for all depths on this screen. */ for (j = 0; j < sp->ndepths; j++) { Depth *dp = &sp->depths[j]; dp->depth = u.dp->depth; dp->nvisuals = u.dp->nVisuals; u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); if (dp->nvisuals > 0) { dp->visuals = (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual)); if (dp->visuals == NULL) { OutOfMemory (dpy, setup); UnlockMutex(&lock); return(NULL); } for (k = 0; k < dp->nvisuals; k++) { register Visual *vp = &dp->visuals[k]; if ((vp->visualid = u.vp->visualID) == root_visualID) sp->root_visual = vp; vp->class = u.vp->class; vp->bits_per_rgb= u.vp->bitsPerRGB; vp->map_entries = u.vp->colormapEntries; vp->red_mask = u.vp->redMask; vp->green_mask = u.vp->greenMask; vp->blue_mask = u.vp->blueMask; vp->ext_data = NULL; u.vp = (xVisualType *) (((char *) u.vp) + sz_xVisualType); } } else { dp->visuals = (Visual *) NULL; } } } /* * Now start talking to the server to setup all other information... */ Xfree (setup); /* all finished with setup information *//* * Make sure default screen is legal. */ if (iscreen >= dpy->nscreens) { OutOfMemory(dpy, (char *) NULL); UnlockMutex(&lock); return(NULL); }/* * Set up other stuff clients are always going to use. */ for (i = 0; i < dpy->nscreens; i++) { register Screen *sp = &dpy->screens[i]; XGCValues values; values.foreground = sp->black_pixel; values.background = sp->white_pixel; if ((sp->default_gc = XCreateGC (dpy, sp->root, GCForeground|GCBackground, &values)) == NULL) { OutOfMemory(dpy, (char *) NULL); UnlockMutex (&lock); return (NULL); } }/* * call into synchronization routine so that all programs can be * forced synchronize */ (void) XSynchronize(dpy, _Xdebug);/* * and done mucking with the display */ UnlockDisplay(dpy); /* didn't exist, so didn't lock */ UnlockMutex(&lock);/* * get the resource manager database off the root window. */ { Atom actual_type; int actual_format; unsigned long nitems; unsigned long leftover; char *xdef = NULL; if (XGetWindowProperty (dpy, RootWindow(dpy, 0), XA_RESOURCE_MANAGER, 0L, 100000000L, False, XA_STRING, &actual_type, &actual_format, &nitems, &leftover, (unsigned char **) &xdef) == Success) { if ((actual_type == XA_STRING) && (actual_format == 8)) { LockDisplay (dpy); dpy->xdefaults = xdef; UnlockDisplay (dpy); } else if (xdef) { Xfree (xdef); } } }#ifdef MOTIFBC { extern Display *_XHeadOfDisplayList; _XHeadOfDisplayList = dpy; }#endif/* * and return successfully */ return(dpy);}/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL after this returns. */static OutOfMemory (dpy, setup) Display *dpy; char *setup; { _XDisconnectDisplay (dpy->fd); _XFreeDisplayStructure (dpy); if (setup) Xfree (setup); }/* XFreeDisplayStructure frees all the storage associated with a * Display. It is used by XOpenDisplay if it runs out of memory, * and also by XCloseDisplay. It needs to check whether all pointers * are non-NULL before dereferencing them, since it may be called * by XOpenDisplay before the Display structure is fully formed. * XOpenDisplay must be sure to initialize all the pointers to NULL * before the first possible call on this. */_XFreeDisplayStructure(dpy) register Display *dpy;{ while (dpy->ext_procs) { _XExtension *ext = dpy->ext_procs; dpy->ext_procs = ext->next; if (ext->name) Xfree (ext->name); Xfree ((char *)ext); } if (dpy->im_filters) (*dpy->free_funcs->im_filters)(dpy); if (dpy->cms.clientCmaps) (*dpy->free_funcs->clientCmaps)(dpy); if (dpy->cms.defaultCCCs) (*dpy->free_funcs->defaultCCCs)(dpy); if (dpy->cms.perVisualIntensityMaps) (*dpy->free_funcs->intensityMaps)(dpy); if (dpy->atoms) (*dpy->free_funcs->atoms)(dpy); if (dpy->modifiermap) (*dpy->free_funcs->modifiermap)(dpy->modifiermap); if (dpy->key_bindings) (*dpy->free_funcs->key_bindings)(dpy); if (dpy->context_db) (*dpy->free_funcs->context_db)(dpy); if (dpy->screens) { register int i; for (i = 0; i < dpy->nscreens; i++) { Screen *sp = &dpy->screens[i]; if (sp->depths) { register int j; for (j = 0; j < sp->ndepths; j++) { Depth *dp = &sp->depths[j]; if (dp->visuals) { register int k; for (k = 0; k < dp->nvisuals; k++) _XFreeExtData (dp->visuals[k].ext_data); Xfree ((char *) dp->visuals); } } Xfree ((char *) sp->depths); } _XFreeExtData (sp->ext_data); } Xfree ((char *)dpy->screens); } if (dpy->pixmap_format) { register int i; for (i = 0; i < dpy->nformats; i++) _XFreeExtData (dpy->pixmap_format[i].ext_data); Xfree ((char *)dpy->pixmap_format); } if (dpy->display_name) Xfree (dpy->display_name); if (dpy->vendor) Xfree (dpy->vendor); if (dpy->buffer) Xfree (dpy->buffer); if (dpy->keysyms) Xfree ((char *) dpy->keysyms); if (dpy->xdefaults) Xfree (dpy->xdefaults); if (dpy->error_vec) Xfree ((char *)dpy->error_vec); _XFreeExtData (dpy->ext_data); Xfree ((char *)dpy->free_funcs); Xfree ((char *)dpy);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -