Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!EXPO.LCS.MIT.EDU!keith From: keith@EXPO.LCS.MIT.EDU (Keith Packard) Newsgroups: comp.windows.x Subject: Re: Extension using AllocateGCPrivate Message-ID: <9002061809.AA17701@xenon.lcs.mit.edu> Date: 6 Feb 90 18:09:37 GMT References: <1250001@hpfcdan.HP.COM> Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 42 > I'm trying to write a complex extension and have run into problems using > AllocateGCPrivate. The problem is that the extension initialization > routines are called after InitOutput and InitOutput creates GCs. Too true. The GCs are allocated by AddScreen which calls CreateGCPerDepth on the new screen. This and the default stipple creation should be delayed until after the extensions are initialized. We solved the problem for window allocation by moving the root window creation from AddScreen to main; to solve the GC and stipple problem I'd suggest moving them as well. AddScreen would then look more like: ... screenInfo.numScreens++; if (!(*pfnInit)(i, pScreen, argc, argv)) { FreeScreen (pScreen); screenInfo.numScreens--; return -1; } return i; } while main would look more like: InitOutput(&screenInfo, argc, argv); if (screenInfo.numScreens < 1) FatalError("no screens found"); InitExtensions(argc, argv); for (i = 0; i < screenInfo.numScreens; i++) { if (!CreateGCPerDepth(i)) FatalError("failed to create scratch GCs"); if (!CreateDefaultStipple(i)) FatalError("failed to create default stipple"); if (!CreateRootWindow(screenInfo.screens[i])) FatalError("failed to create root window"); } Caveat: I have not tested this code (nor even compiled it). Keith Packard MIT X Consortium