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

📄 tkmacwm.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 5 页
字号:
 * TkWmMapWindow -- * *	This procedure is invoked to map a top-level window.  This *	module gets a chance to update all window-manager-related *	information in properties before the window manager sees *	the map event and checks the properties.  It also gets to *	decide whether or not to even map the window after all. * * Results: *	None. * * Side effects: *	Properties of winPtr may get updated to provide up-to-date *	information to the window manager.  The window may also get *	mapped, but it may not be if this procedure decides that *	isn't appropriate (e.g. because the window is withdrawn). * *-------------------------------------------------------------- */voidTkWmMapWindow(    TkWindow *winPtr)		/* Top-level window that's about to				 * be mapped. */{    register WmInfo *wmPtr = winPtr->wmInfoPtr;    Point where = {0, 0};    int xOffset, yOffset;	        int firstMap = false;    MacDrawable *macWin;    if (wmPtr->flags & WM_NEVER_MAPPED) {	wmPtr->flags &= ~WM_NEVER_MAPPED;	firstMap = true;	/*	 * Create the underlying Mac window for this Tk window.	 */	macWin = (MacDrawable *) winPtr->window;	if (!TkMacHostToplevelExists(winPtr)) {	    TkMacMakeRealWindowExist(winPtr);	}		/*	 * Generate configure event when we first map the window.	 */	LocalToGlobal(&where);	TkMacWindowOffset((WindowRef) TkMacGetDrawablePort((Drawable) macWin),		&xOffset, &yOffset);	where.h -= xOffset;	where.v -= yOffset;	TkGenWMConfigureEvent((Tk_Window) winPtr, 		where.h, where.v, -1, -1, TK_LOCATION_CHANGED);		/*	 * This is the first time this window has ever been mapped.	 * Store all the window-manager-related information for the	 * window.	 */	if (wmPtr->titleUid == NULL) {	    wmPtr->titleUid = winPtr->nameUid;	}		if (!Tk_IsEmbedded(winPtr)) {	    TkSetWMName(winPtr, wmPtr->titleUid);	}	TkWmSetClass(winPtr);    	if (wmPtr->iconName != NULL) {	    XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);	}    	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;    }    if (wmPtr->hints.initial_state == WithdrawnState) {	return;    }        /*     * TODO: we need to display a window if it's iconic on creation.     */    if (wmPtr->hints.initial_state == IconicState) {	return;    }        /*     * Update geometry information.     */    wmPtr->flags |= WM_ABOUT_TO_MAP;    if (wmPtr->flags & WM_UPDATE_PENDING) {	Tk_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);    }    UpdateGeometryInfo((ClientData) winPtr);    wmPtr->flags &= ~WM_ABOUT_TO_MAP;    /*     * Map the window.     */    XMapWindow(winPtr->display, winPtr->window);        /*     * Now that the window is visable we can determine the offset     * from the window's content orgin to the window's decorative     * orgin (structure orgin).     */    TkMacWindowOffset((WindowRef) TkMacGetDrawablePort(Tk_WindowId(winPtr)), 	&wmPtr->xInParent, &wmPtr->yInParent);}/* *-------------------------------------------------------------- * * TkWmUnmapWindow -- * *	This procedure is invoked to unmap a top-level window. *	On the Macintosh all we do is call XUnmapWindow. * * Results: *	None. * * Side effects: *	Unmaps the window. * *-------------------------------------------------------------- */voidTkWmUnmapWindow(    TkWindow *winPtr)		/* Top-level window that's about to				 * be mapped. */{    XUnmapWindow(winPtr->display, winPtr->window);}/* *-------------------------------------------------------------- * * TkWmDeadWindow -- * *	This procedure is invoked when a top-level window is *	about to be deleted.  It cleans up the wm-related data *	structures for the window. * * Results: *	None. * * Side effects: *	The WmInfo structure for winPtr gets freed up. * *-------------------------------------------------------------- */voidTkWmDeadWindow(winPtr)    TkWindow *winPtr;		/* Top-level window that's being deleted. */{    register WmInfo *wmPtr = winPtr->wmInfoPtr;    WmInfo *wmPtr2;    if (wmPtr == NULL) {	return;    }    if (wmPtr->hints.flags & IconPixmapHint) {	Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);    }    if (wmPtr->hints.flags & IconMaskHint) {	Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask);    }    if (wmPtr->leaderName != NULL) {	ckfree(wmPtr->leaderName);    }    if (wmPtr->masterWindowName != NULL) {	ckfree(wmPtr->masterWindowName);    }    if (wmPtr->icon != NULL) {	wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;	wmPtr2->iconFor = NULL;    }    if (wmPtr->iconFor != NULL) {	wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr;	wmPtr2->icon = NULL;	wmPtr2->hints.flags &= ~IconWindowHint;    }    while (wmPtr->protPtr != NULL) {	ProtocolHandler *protPtr;	protPtr = wmPtr->protPtr;	wmPtr->protPtr = protPtr->nextPtr;	Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);    }    if (wmPtr->cmdArgv != NULL) {	ckfree((char *) wmPtr->cmdArgv);    }    if (wmPtr->clientMachine != NULL) {	ckfree((char *) wmPtr->clientMachine);    }    if (wmPtr->flags & WM_UPDATE_PENDING) {	Tk_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);    }    ckfree((char *) wmPtr);    winPtr->wmInfoPtr = NULL;}/* *-------------------------------------------------------------- * * TkWmSetClass -- * *	This procedure is invoked whenever a top-level window's *	class is changed.  If the window has been mapped then this *	procedure updates the window manager property for the *	class.  If the window hasn't been mapped, the update is *	deferred until just before the first mapping. * * Results: *	None. * * Side effects: *	A window property may get updated. * *-------------------------------------------------------------- */voidTkWmSetClass(    TkWindow *winPtr)		/* Newly-created top-level window. */{    return;}/* *---------------------------------------------------------------------- * * Tk_WmCmd -- * *	This procedure is invoked to process the "wm" Tcl command. *	See the user documentation for details on what it does. * * Results: *	A standard Tcl result. * * Side effects: *	See the user documentation. * *---------------------------------------------------------------------- */	/* ARGSUSED */intTk_WmCmd(    ClientData clientData,	/* Main window associated with				 * interpreter. */    Tcl_Interp *interp,		/* Current interpreter. */    int argc,			/* Number of arguments. */    char **argv)		/* Argument strings. */{    Tk_Window tkwin = (Tk_Window) clientData;    TkWindow *winPtr;    register WmInfo *wmPtr;    int c;    size_t length;    if (argc < 2) {	wrongNumArgs:	Tcl_AppendResult(interp, "wrong # args: should be \"",		argv[0], " option window ?arg ...?\"", (char *) NULL);	return TCL_ERROR;    }    c = argv[1][0];    length = strlen(argv[1]);    if ((c == 't') && (strncmp(argv[1], "tracing", length) == 0)	    && (length >= 3)) {	if ((argc != 2) && (argc != 3)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " tracing ?boolean?\"", (char *) NULL);	    return TCL_ERROR;	}	if (argc == 2) {	    interp->result = (wmTracing) ? "on" : "off";	    return TCL_OK;	}	return Tcl_GetBoolean(interp, argv[2], &wmTracing);    }    if (argc < 3) {	goto wrongNumArgs;    }    winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin);    if (winPtr == NULL) {	return TCL_ERROR;    }    if (!(winPtr->flags & TK_TOP_LEVEL)) {	Tcl_AppendResult(interp, "window \"", winPtr->pathName,		"\" isn't a top-level window", (char *) NULL);	return TCL_ERROR;    }    wmPtr = winPtr->wmInfoPtr;    if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0)) {	int numer1, denom1, numer2, denom2;	if ((argc != 3) && (argc != 7)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " aspect window ?minNumer minDenom ",		    "maxNumer maxDenom?\"", (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (wmPtr->sizeHintsFlags & PAspect) {		sprintf(interp->result, "%d %d %d %d", wmPtr->minAspect.x,			wmPtr->minAspect.y, wmPtr->maxAspect.x,			wmPtr->maxAspect.y);	    }	    return TCL_OK;	}	if (*argv[3] == '\0') {	    wmPtr->sizeHintsFlags &= ~PAspect;	} else {	    if ((Tcl_GetInt(interp, argv[3], &numer1) != TCL_OK)		    || (Tcl_GetInt(interp, argv[4], &denom1) != TCL_OK)		    || (Tcl_GetInt(interp, argv[5], &numer2) != TCL_OK)		    || (Tcl_GetInt(interp, argv[6], &denom2) != TCL_OK)) {		return TCL_ERROR;	    }	    if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) ||		    (denom2 <= 0)) {		interp->result = "aspect number can't be <= 0";		return TCL_ERROR;	    }	    wmPtr->minAspect.x = numer1;	    wmPtr->minAspect.y = denom1;	    wmPtr->maxAspect.x = numer2;	    wmPtr->maxAspect.y = denom2;	    wmPtr->sizeHintsFlags |= PAspect;	}	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	goto updateGeom;    } else if ((c == 'c') && (strncmp(argv[1], "client", length) == 0)	    && (length >= 2)) {	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " client window ?name?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (wmPtr->clientMachine != NULL) {		interp->result = wmPtr->clientMachine;	    }	    return TCL_OK;	}	if (argv[3][0] == 0) {	    if (wmPtr->clientMachine != NULL) {		ckfree((char *) wmPtr->clientMachine);		wmPtr->clientMachine = NULL;	    }	    return TCL_OK;	}	if (wmPtr->clientMachine != NULL) {	    ckfree((char *) wmPtr->clientMachine);	}	wmPtr->clientMachine = (char *)	    ckalloc((unsigned) (strlen(argv[3]) + 1));	strcpy(wmPtr->clientMachine, argv[3]);    } else if ((c == 'c') && (strncmp(argv[1], "colormapwindows", length) == 0)	    && (length >= 3)) {	TkWindow **cmapList;	TkWindow *winPtr2;	int i, windowArgc, gotToplevel;	char **windowArgv;	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " colormapwindows window ?windowList?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    Tk_MakeWindowExist((Tk_Window) winPtr);	    for (i = 0; i < wmPtr->cmapCount; i++) {		if ((i == (wmPtr->cmapCount-1))			&& (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) {		    break;		}		Tcl_AppendElement(interp, wmPtr->cmapList[i]->pathName);	    }	    return TCL_OK;	}	if (Tcl_SplitList(interp, argv[3], &windowArgc, &windowArgv)		!= TCL_OK) {	    return TCL_ERROR;	}	cmapList = (TkWindow **) ckalloc((unsigned)		((windowArgc+1)*sizeof(TkWindow*)));	for (i = 0; i < windowArgc; i++) {	    winPtr2 = (TkWindow *) Tk_NameToWindow(interp, windowArgv[i],		    tkwin);	    if (winPtr2 == NULL) {		ckfree((char *) cmapList);		ckfree((char *) windowArgv);		return TCL_ERROR;	    }	    if (winPtr2 == winPtr) {		gotToplevel = 1;	    }	    if (winPtr2->window == None) {		Tk_MakeWindowExist((Tk_Window) winPtr2);	    }	    cmapList[i] = winPtr2;	}	if (!gotToplevel) {	    wmPtr->flags |= WM_ADDED_TOPLEVEL_COLORMAP;	    cmapList[windowArgc] = winPtr;	    windowArgc++;	} else {	    wmPtr->flags &= ~WM_ADDED_TOPLEVEL_COLORMAP;	}	wmPtr->flags |= WM_COLORMAPS_EXPLICIT;	if (wmPtr->cmapList != NULL) {	    ckfree((char *)wmPtr->cmapList);	}	wmPtr->cmapList = cmapList;	wmPtr->cmapCount = windowArgc;	ckfree((char *) windowArgv);	/*

⌨️ 快捷键说明

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