/*********************************************************************** * Add window to the WM_COLORMAP_WINDOWS property on the Netscape * toplevel widget if necessary ***********************************************************************/ static void SetWMColormap(PluginInstance* This, Window win) { int i; Colormap top_cmap; Arg arg; /* get window's record */ for (i = 0; i < This->nclient_windows; i++) if ((This->client_windows[i].win = win)) break; if (i == This->nclient_windows) return; /* if window's colormap is different from toplevel's one set property */ XtSetArg(arg, XtNcolormap, &top_cmap); XtGetValues(This->toplevel_widget, &arg, 1); if (This->client_windows[i].colormap != top_cmap) { Window *cur_list; int cur_count = 0; /* if there is already a non empty list we need to update it */ if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), &cur_list, &cur_count) == True && cur_count != 0) { if (IsInWinList(cur_list, cur_count, win)) { /* window is already in the list just move it in first place */ SetFirstWinList(cur_list, cur_count, win); XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), cur_list, cur_count); } else { /* window is not in the list add it in first place */ Window *new_list; int new_count; PrependToWinList(&new_list, &new_count, cur_list, cur_count, win); XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), new_list, new_count); free(new_list); } } else { /* no list yet so lets make one */ Window list[2]; list[0] = win; list[1] = XtWindow(This->toplevel_widget); XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), list, 2); } if (cur_count != 0) XFree(cur_list); } }
static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes) { register GLwDrawingAreaWidget glw=(GLwDrawingAreaWidget)w; GLwDrawingAreaCallbackStruct cb; Widget parentShell; Status status; Window windows[2],*windowsReturn,*windowList; int countReturn,i; /* if we haven't requested that the background be both installed and * allocated, don't install it. */ if(!(glw->glwDrawingArea.installBackground && glw->glwDrawingArea.allocateBackground)) { *valueMask&=~CWBackPixel; } XtCreateWindow(w,(unsigned int)InputOutput,glw->glwDrawingArea.visualInfo->visual,*valueMask,attributes); /* if appropriate, call XSetWMColormapWindows to install the colormap */ if(glw->glwDrawingArea.installColormap) { /* Get parent shell */ for(parentShell=XtParent(w); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell)); if(parentShell && XtWindow(parentShell)) { /* check to see if there is already a property */ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn); /* if no property, just create one */ if(!status) { windows[0]=XtWindow(w); windows[1]=XtWindow(parentShell); XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windows,2); } /* there was a property, add myself to the beginning */ else { windowList=(Window *)XtMalloc((sizeof(Window))*(countReturn+1)); windowList[0]=XtWindow(w); for(i=0; i<countReturn; i++) windowList[i+1]=windowsReturn[i]; XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowList,countReturn+1); XtFree((char*)windowList); XtFree((char*)windowsReturn); } } else { warning(w,"Could not set colormap property on parent shell"); } } /* Invoke callbacks */ cb.reason=GLwCR_GINIT; cb.event=NULL; cb.width=glw->core.width; cb.height=glw->core.height; XtCallCallbackList((Widget)glw,glw->glwDrawingArea.ginitCallback,&cb); }
/*********************************************************************** * Move window at the end of the WM_COLORMAP_WINDOWS property list on * the Netscape toplevel widget ***********************************************************************/ static void UnsetWMColormap(PluginInstance* This, Window win) { Window *list; int count = 0; if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), &list, &count) == True && count != 0) { SetLastWinList(list, count, win); XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), list, count); } if (count != 0) XFree(list); }
static void Destroy( SoXtGLAreaWidget glw) { Window * windowsReturn; Widget parentShell; Status status; int countReturn; register int i; if (glw->soxtGLArea.myList && glw->soxtGLArea.attribList) XtFree((char *) glw->soxtGLArea.attribList); if (glw->soxtGLArea.myVisual && glw->soxtGLArea.visualInfo) XtFree((char *) glw->soxtGLArea.visualInfo); // if my colormap was installed, remove it if (glw->soxtGLArea.installColormap) { // Get parent shell for (parentShell = XtParent(glw); parentShell && ! XtIsShell(parentShell); parentShell = XtParent(parentShell)) { } if (parentShell && XtWindow(parentShell)) { // make sure there is a property status = XGetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), &windowsReturn, &countReturn); // if no property, just return. If there was a property, continue if (status) { // search for a match for (i = 0; i < countReturn; i++) { if (windowsReturn[i] == XtWindow(glw)) { // we found a match, now copy the rest down for (i++; i < countReturn; i++) windowsReturn[i-1] = windowsReturn[i]; XSetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), windowsReturn, countReturn-1); break; } } XtFree((char *) windowsReturn); } } } } // Destroy()
static void Destroy(GLwDrawingAreaWidget glw) { Window *windowsReturn; Widget parentShell; Status status; int countReturn; register int i; if(glw->glwDrawingArea.myList && glw->glwDrawingArea.attribList) { XtFree((XtPointer)glw->glwDrawingArea.attribList); } if(glw->glwDrawingArea.myVisual && glw->glwDrawingArea.visualInfo) { XtFree((XtPointer)glw->glwDrawingArea.visualInfo); } /* if my colormap was installed, remove it */ if(glw->glwDrawingArea.installColormap) { /* Get parent shell */ for(parentShell=XtParent(glw); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell)); if(parentShell && XtWindow(parentShell)) { /* make sure there is a property */ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn); /* if no property, just return. If there was a property, continue */ if(status) { /* search for a match */ for(i=0; i<countReturn; i++) { if(windowsReturn[i]==XtWindow(glw)) { /* we found a match, now copy the rest down */ for(i++; i<countReturn; i++) { windowsReturn[i-1]=windowsReturn[i]; } XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowsReturn,countReturn-1); break; } } XtFree((char *)windowsReturn); } } } }
/*********************************************************************** * Remove window from the WM_COLORMAP_WINDOWS property on the Netscape * toplevel widget ***********************************************************************/ static void ResetWMColormap(PluginInstance* This, Window win) { Window *list; int count = 0; if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), &list, &count) == True && count != 0) { RemoveFromWinList(&list, &count, win); if (count > 1) XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget), list, count); else { /* remove list when it becomes useless */ Atom prop; prop = XInternAtom (RxGlobal.dpy, "WM_COLORMAP_WINDOWS", False); XDeleteProperty(RxGlobal.dpy, XtWindow(This->toplevel_widget), prop); } } if (count != 0) XFree(list); }