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

📄 tkunixwm.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 5 页
字号:
	    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 if (wmPtr->withdrawn) {	    interp->result = "withdrawn";	} else if (Tk_IsMapped((Tk_Window) winPtr)		|| ((wmPtr->flags & WM_NEVER_MAPPED)		&& (wmPtr->hints.initial_state == NormalState))) {	    interp->result = "normal";	} else {	    interp->result = "iconic";	}    } 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->title != NULL) ? wmPtr->title		    : winPtr->nameUid;	    return TCL_OK;	} else {	    wmPtr->title = ckalloc((unsigned) (strlen(argv[3]) + 1));	    strcpy(wmPtr->title, argv[3]);	    if (!(wmPtr->flags & WM_NEVER_MAPPED)) {		XTextProperty textProp;		if (XStringListToTextProperty(&wmPtr->title, 1,			&textProp)  != 0) {		    XSetWMName(winPtr->display, wmPtr->wrapperPtr->window,			    &textProp);		    XFree((char *) textProp.value);		}	    }	}    } else if ((c == 't') && (strncmp(argv[1], "transient", length) == 0)	    && (length >= 3)) {	Tk_Window master;	WmInfo *wmPtr2;	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;	} else {	    master = Tk_NameToWindow(interp, argv[3], tkwin);	    if (master == NULL) {		return TCL_ERROR;	    }	    while (!Tk_IsTopLevel(master)) {		/*		 * Ensure that the master window is actually a Tk toplevel.		 */		master = Tk_Parent(master);	    }	    Tk_MakeWindowExist(master);	    wmPtr2 = ((TkWindow *) master)->wmInfoPtr;	    if (wmPtr2->wrapperPtr == NULL) {		CreateWrapper(wmPtr2);	    }	    wmPtr->master = Tk_WindowId(wmPtr2->wrapperPtr);	    wmPtr->masterWindowName = ckalloc((unsigned) (strlen(argv[3])+1));	    strcpy(wmPtr->masterWindowName, argv[3]);	}	if (!(wmPtr->flags & WM_NEVER_MAPPED)) {	    XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window,		    wmPtr->master);	}    } else if ((c == 'w') && (strncmp(argv[1], "withdraw", length) == 0)	    && (length >= 2)) {	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;	}	wmPtr->hints.initial_state = WithdrawnState;	wmPtr->withdrawn = 1;	if (wmPtr->flags & WM_NEVER_MAPPED) {	    return TCL_OK;	}	if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,		winPtr->screenNum) == 0) {	    interp->result =		    "couldn't send withdraw message to window manager";	    return TCL_ERROR;	}	WaitForMapNotify(winPtr, 0);    } 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))) {	Tcl_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(tkwin, reqWidth, reqHeight, widthInc, heightInc)    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, 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;	if (winPtr == NULL) {	    /*	     * The window is being deleted... just skip this operation.	     */	    return;	}    }    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))) {	Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);	wmPtr->flags |= WM_UPDATE_PENDING;    }}/* *---------------------------------------------------------------------- * * Tk_UnsetGrid -- * *	This procedure cancels the effect of a previous call *	to Tk_SetGrid. * * Results: *	None. * * Side effects: *	If tkwin currently controls gridding for its top-level window, *	gridding is cancelled for that top-level window;  if some other *	window controls gridding then this procedure has no effect. * *---------------------------------------------------------------------- */voidTk_UnsetGrid(tkwin)    Tk_Window tkwin;		/* Token for window that is currently				 * controlling gridding. */{    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;	if (winPtr == NULL) {	    /*	     * The window is being deleted... just skip this operation.	     */	    return;	}    }    wmPtr = winPtr->wmInfoPtr;    if (tkwin != wmPtr->gridWin) {	return;    }    wmPtr->gridWin = NULL;    wmPtr->sizeHintsFlags &= ~(PBaseSize|PResizeInc);    if (wmPtr->width != -1) {	wmPtr->width = winPtr->reqWidth + (wmPtr->width		- wmPtr->reqGridWidth)*wmPtr->widthInc;	wmPtr->height = winPtr->reqHeight + (wmPtr->height		- wmPtr->reqGridHeight)*wmPtr->heightInc;    }    wmPtr->widthInc = 1;    wmPtr->heightInc = 1;    wmPtr->flags |= WM_UPDATE_SIZE_HINTS;    if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {	Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);	wmPtr->flags |= WM_UPDATE_PENDING;    }}/* *---------------------------------------------------------------------- * * ConfigureEvent -- * *	This procedure is called to handle ConfigureNotify events on *	wrapper windows. * * Results: *	None. * * Side effects: *	Information gets updated in the WmInfo structure for the window *	and the toplevel itself gets repositioned within the wrapper. * *---------------------------------------------------------------------- */static voidConfigureEvent(wmPtr, configEventPtr)    WmInfo *wmPtr;			/* Information about toplevel window. */    XConfigureEvent *configEventPtr;	/* Event that just occurred for					 * wmPtr->wrapperPtr. */{    TkWindow *wrapperPtr = wmPtr->wrapperPtr;    TkWindow *winPtr = wmPtr->winPtr;    /*      * Update size information from the event.  There are a couple of     * tricky points here:     *     * 1. If the user changed the size externally then set wmPtr->width     *    and wmPtr->height just as if a "wm geometry" command had been     *    invoked with the same information.     * 2. However, if the size is changing in response to a request     *    coming from us (WM_SYNC_PENDING is set), then don't set wmPtr->width     *    or wmPtr->height if they were previously -1 (otherwise the     *    window will stop tracking geometry manager requests).     */    if (((wrapperPtr->changes.width != configEventPtr->width)	    || (wrapperPtr->changes.height != configEventPtr->height))	    && !(wmPtr->flags & WM_SYNC_PENDING)){	if (wmTracing) {	    printf("TopLevelEventProc: user changed %s size to %dx%d\n",		    winPtr->pathName, configEventPtr->width,		    configEventPtr->height);	}	if ((wmPtr->width == -1)		&& (configEventPtr->width == winPtr->reqWidth)) {	    /*	     * Don't set external width, since the user didn't change it	     * from what the widgets asked for.	     */	} else {	    /*	     * Note: if this window is embedded then don't set the external	     * size, since it came from the containing application, not the	     * user.  In this case we want to keep sending our size requests	     * to the containing application;  if the user fixes the size	     * of that application then it will still percolate down to us	     * in the right way.	     */	    if (!(winPtr->flags & TK_EMBEDDED)) {		if (wmPtr->gridWin != NULL) {		    wmPtr->width = wmPtr->reqGridWidth			    + (configEventPtr->width			    - winPtr->reqWidth)/wmPtr->widthInc;		    if (wmPtr->width < 0) {			wmPtr->width = 0;		    }		} else {		    wmPtr->width = configEventPtr->width;		}	    }	}	if ((wmPtr->height == -1)		&& (configEventPtr->height ==			(winPtr->reqHeight + wmPtr->menuHeight))) {	    /*	     * Don't set external height, since the user didn't change it	     * from what the widgets asked for.	     */	} else {	    /*	     * See note for wmPtr->width about no

⌨️ 快捷键说明

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