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

📄 tkmacwm.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK)		|| (Tcl_GetInt(interp, argv[4], &height) != TCL_OK)) {	    return TCL_ERROR;	}	wmPtr->maxWidth = width;	wmPtr->maxHeight = height;	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	goto updateGeom;    } else if ((c == 'm') && (strncmp(argv[1], "minsize", length) == 0)	    && (length >= 2)) {	int width, height;	if ((argc != 3) && (argc != 5)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		   argv[0], " minsize window ?width height?\"", (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    sprintf(interp->result, "%d %d", wmPtr->minWidth,		    wmPtr->minHeight);	    return TCL_OK;	}	if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK)		|| (Tcl_GetInt(interp, argv[4], &height) != TCL_OK)) {	    return TCL_ERROR;	}	wmPtr->minWidth = width;	wmPtr->minHeight = height;	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	goto updateGeom;    } else if ((c == 'o')	    && (strncmp(argv[1], "overrideredirect", length) == 0)) {	int boolean;	XSetWindowAttributes atts;	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " overrideredirect window ?boolean?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {		interp->result = "1";	    } else {		interp->result = "0";	    }	    return TCL_OK;	}	if (Tcl_GetBoolean(interp, argv[3], &boolean) != TCL_OK) {	    return TCL_ERROR;	}	atts.override_redirect = (boolean) ? True : False;	Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect,		&atts);	wmPtr->style = (boolean) ? plainDBox : documentProc;    } else if ((c == 'p') && (strncmp(argv[1], "positionfrom", length) == 0)	    && (length >= 2)) {	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " positionfrom window ?user/program?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (wmPtr->sizeHintsFlags & USPosition) {		interp->result = "user";	    } else if (wmPtr->sizeHintsFlags & PPosition) {		interp->result = "program";	    }	    return TCL_OK;	}	if (*argv[3] == '\0') {	    wmPtr->sizeHintsFlags &= ~(USPosition|PPosition);	} else {	    c = argv[3][0];	    length = strlen(argv[3]);	    if ((c == 'u') && (strncmp(argv[3], "user", length) == 0)) {		wmPtr->sizeHintsFlags &= ~PPosition;		wmPtr->sizeHintsFlags |= USPosition;	    } else if ((c == 'p') &&		    (strncmp(argv[3], "program", length) == 0)) {		wmPtr->sizeHintsFlags &= ~USPosition;		wmPtr->sizeHintsFlags |= PPosition;	    } else {		Tcl_AppendResult(interp, "bad argument \"", argv[3],			"\": must be program or user", (char *) NULL);		return TCL_ERROR;	    }	}	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	goto updateGeom;    } else if ((c == 'p') && (strncmp(argv[1], "protocol", length) == 0)	    && (length >= 2)) {	register ProtocolHandler *protPtr, *prevPtr;	Atom protocol;	int cmdLength;	if ((argc < 3) || (argc > 5)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " protocol window ?name? ?command?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    /*	     * Return a list of all defined protocols for the window.	     */	    for (protPtr = wmPtr->protPtr; protPtr != NULL;					   protPtr = protPtr->nextPtr) {		Tcl_AppendElement(interp,			Tk_GetAtomName((Tk_Window) winPtr, protPtr->protocol));	    }	    return TCL_OK;	}	protocol = Tk_InternAtom((Tk_Window) winPtr, argv[3]);	if (argc == 4) {	    /*	     * Return the command to handle a given protocol.	     */	    for (protPtr = wmPtr->protPtr; protPtr != NULL;					   protPtr = protPtr->nextPtr) {		if (protPtr->protocol == protocol) {		    interp->result = protPtr->command;		    return TCL_OK;		}	    }	    return TCL_OK;	}	/*	 * Delete any current protocol handler, then create a new	 * one with the specified command, unless the command is	 * empty.	 */	for (protPtr = wmPtr->protPtr, prevPtr = NULL; protPtr != NULL;	       prevPtr = protPtr, protPtr = protPtr->nextPtr) {	    if (protPtr->protocol == protocol) {		if (prevPtr == NULL) {		    wmPtr->protPtr = protPtr->nextPtr;		} else {		    prevPtr->nextPtr = protPtr->nextPtr;		}		Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);		break;	    }	}	cmdLength = strlen(argv[4]);	if (cmdLength > 0) {	    protPtr = (ProtocolHandler *) ckalloc(HANDLER_SIZE(cmdLength));	    protPtr->protocol = protocol;	    protPtr->nextPtr = wmPtr->protPtr;	    wmPtr->protPtr = protPtr;	    protPtr->interp = interp;	    strcpy(protPtr->command, argv[4]);	}    } else if ((c == 'r') && (strncmp(argv[1], "resizable", length) == 0)) {	int width, height;	if ((argc != 3) && (argc != 5)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " resizable window ?width height?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    sprintf(interp->result, "%d %d",		    (wmPtr->flags  & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1,		    (wmPtr->flags  & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1);	    return TCL_OK;	}	if ((Tcl_GetBoolean(interp, argv[3], &width) != TCL_OK)		|| (Tcl_GetBoolean(interp, argv[4], &height) != TCL_OK)) {	    return TCL_ERROR;	}	if (width) {	    wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE;	} else {	    wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE;	}	if (height) {	    wmPtr->flags &= ~WM_HEIGHT_NOT_RESIZABLE;	} else {	    wmPtr->flags |= WM_HEIGHT_NOT_RESIZABLE;	}	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	if (wmPtr->scrollWinPtr != NULL) {	    TkScrollbarEventuallyRedraw(		(TkScrollbar *) wmPtr->scrollWinPtr->instanceData);	}	goto updateGeom;    } else if ((c == 's') && (strncmp(argv[1], "sizefrom", length) == 0)	    && (length >= 2)) {	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " sizefrom window ?user|program?\"",		    (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (wmPtr->sizeHintsFlags & USSize) {		interp->result = "user";	    } else if (wmPtr->sizeHintsFlags & PSize) {		interp->result = "program";	    }	    return TCL_OK;	}	if (*argv[3] == '\0') {	    wmPtr->sizeHintsFlags &= ~(USSize|PSize);	} else {	    c = argv[3][0];	    length = strlen(argv[3]);	    if ((c == 'u') && (strncmp(argv[3], "user", length) == 0)) {		wmPtr->sizeHintsFlags &= ~PSize;		wmPtr->sizeHintsFlags |= USSize;	    } else if ((c == 'p')		    && (strncmp(argv[3], "program", length) == 0)) {		wmPtr->sizeHintsFlags &= ~USSize;		wmPtr->sizeHintsFlags |= PSize;	    } else {		Tcl_AppendResult(interp, "bad argument \"", argv[3],			"\": must be program or user", (char *) NULL);		return TCL_ERROR;	    }	}	wmPtr->flags |= WM_UPDATE_SIZE_HINTS;	goto updateGeom;    } else if ((c == 's') && (strncmp(argv[1], "state", length) == 0)	    && (length >= 2)) {	if (argc != 3) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " state window\"", (char *) NULL);	    return TCL_ERROR;	}	if (wmPtr->iconFor != NULL) {	    interp->result = "icon";	} else {	    switch (wmPtr->hints.initial_state) {		case NormalState:		    interp->result = "normal";		    break;		case IconicState:		    interp->result = "iconic";		    break;		case WithdrawnState:		    interp->result = "withdrawn";		    break;		case ZoomState:		    interp->result = "zoomed";		    break;	    }	}    } else if ((c == 't') && (strncmp(argv[1], "title", length) == 0)	    && (length >= 2)) {	if (argc > 4) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " title window ?newTitle?\"", (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    interp->result = (wmPtr->titleUid != NULL) ? wmPtr->titleUid		: winPtr->nameUid;	    return TCL_OK;	} else {	    wmPtr->titleUid = Tk_GetUid(argv[3]);	    if (!(wmPtr->flags & WM_NEVER_MAPPED) && !Tk_IsEmbedded(winPtr)) {		TkSetWMName(winPtr, wmPtr->titleUid);	    }	}    } else if ((c == 't') && (strncmp(argv[1], "transient", length) == 0)	    && (length >= 3)) {	Tk_Window master;	if ((argc != 3) && (argc != 4)) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " transient window ?master?\"", (char *) NULL);	    return TCL_ERROR;	}	if (argc == 3) {	    if (wmPtr->master != None) {		interp->result = wmPtr->masterWindowName;	    }	    return TCL_OK;	}	if (argv[3][0] == '\0') {	    wmPtr->master = None;	    if (wmPtr->masterWindowName != NULL) {		ckfree(wmPtr->masterWindowName);	    }	    wmPtr->masterWindowName = NULL;	    wmPtr->style = documentProc;	} else {	    master = Tk_NameToWindow(interp, argv[3], tkwin);	    if (master == NULL) {		return TCL_ERROR;	    }	    Tk_MakeWindowExist(master);	    wmPtr->master = Tk_WindowId(master);	    wmPtr->masterWindowName = ckalloc((unsigned) (strlen(argv[3])+1));	    strcpy(wmPtr->masterWindowName, argv[3]);	    wmPtr->style = plainDBox;	}    } else if ((c == 'w') && (strncmp(argv[1], "withdraw", length) == 0)) {	if (argc != 3) {	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",		    argv[0], " withdraw window\"", (char *) NULL);	    return TCL_ERROR;	}	if (wmPtr->iconFor != NULL) {	    Tcl_AppendResult(interp, "can't withdraw ", argv[2],		    ": it is an icon for ", Tk_PathName(wmPtr->iconFor),		    (char *) NULL);	    return TCL_ERROR;	}	TkpWmSetState(winPtr, WithdrawnState);    } else {	Tcl_AppendResult(interp, "unknown or ambiguous option \"", argv[1],		"\": must be aspect, client, command, deiconify, ",		"focusmodel, frame, geometry, grid, group, iconbitmap, ",		"iconify, iconmask, iconname, iconposition, ",		"iconwindow, maxsize, minsize, overrideredirect, ",		"positionfrom, protocol, resizable, sizefrom, state, title, ",		"transient, or withdraw",		(char *) NULL);	return TCL_ERROR;    }    return TCL_OK;    updateGeom:    if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {	Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);	wmPtr->flags |= WM_UPDATE_PENDING;    }    return TCL_OK;}/* *---------------------------------------------------------------------- * * Tk_SetGrid -- * *	This procedure is invoked by a widget when it wishes to set a grid *	coordinate system that controls the size of a top-level window. *	It provides a C interface equivalent to the "wm grid" command and *	is usually asscoiated with the -setgrid option. * * Results: *	None. * * Side effects: *	Grid-related information will be passed to the window manager, so *	that the top-level window associated with tkwin will resize on *	even grid units.  If some other window already controls gridding *	for the top-level window then this procedure call has no effect. * *---------------------------------------------------------------------- */voidTk_SetGrid(    Tk_Window tkwin,		/* Token for window.  New window mgr info				 * will be posted for the top-level window				 * associated with this window. */    int reqWidth,		/* Width (in grid units) corresponding to				 * the requested geometry for tkwin. */    int reqHeight,		/* Height (in grid units) corresponding to				 * the requested geometry for tkwin. */    int widthInc, int heightInc)/* Pixel increments corresponding to a				 * change of one grid unit. */{    TkWindow *winPtr = (TkWindow *) tkwin;    register WmInfo *wmPtr;    /*     * Find the top-level window for tkwin, plus the window manager     * information.     */    while (!(winPtr->flags & TK_TOP_LEVEL)) {	winPtr = winPtr->parentPtr;    }    wmPtr = winPtr->wmInfoPtr;    if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) {	return;    }    if ((wmPtr->reqGridWidth == reqWidth)	    && (wmPtr->reqGridHeight == reqHeight)	    && (wmPtr->widthInc == widthInc)	    && (wmPtr->heightInc == heightInc)	    && ((wmPtr->sizeHintsFlags & (PBaseSize|PResizeInc))		    == PBaseSize|PResizeInc)) {	return;    }    /*     * If gridding was previously off, then forget about any window     * size requests made by the user or via "wm geometry":  these are     * in pixel units and there's no easy way to translate them to     * grid units since the new requested size of the top-level window in     * pixels may not yet have been registered yet (it may filter up     * the hierarchy in DoWhenIdle handlers).  However, if the window     * has never been mapped yet then just leave the window size alone:     * assume that it is intended to be in grid units but just happened     * to have been specified before this procedure was called.     */    if ((wmPtr->gridWin == NULL) && !(wmPtr->flags & WM_NEVER_MAPPED)) {	wmPtr->width = -1;	wmPtr->height = -1;    }    /*      * Set the new gridding information, and start the process of passing     * all of this information to the window manager.     */    wmPtr->gridWin = tkwin;    wmPtr->reqGridWidth = reqWidth;    wmPtr->reqGridHeight = reqHeight;    wmPtr->widthInc = widthInc;    wmPtr->heightInc = heightInc;    wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc;    wmPtr->flags |= WM_UPDATE_SIZE_HINTS;    if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {	Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);	wmPtr->flags |= WM_UPDATE_PENDING;

⌨️ 快捷键说明

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