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

📄 tkwinwm.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 5 页
字号:
    wmPtr->defMinHeight = info->ptMinTrackSize.y;    wmPtr->defMaxWidth = info->ptMaxTrackSize.x;    wmPtr->defMaxHeight = info->ptMaxTrackSize.y;        GetMaxSize(wmPtr, &maxWidth, &maxHeight);    GetMinSize(wmPtr, &minWidth, &minHeight);    if (wmPtr->gridWin != NULL) {	base = winPtr->reqWidth - (wmPtr->reqGridWidth * wmPtr->widthInc);	if (base < 0) {	    base = 0;	}	base += wmPtr->borderWidth;	info->ptMinTrackSize.x = base + (minWidth * wmPtr->widthInc);	info->ptMaxTrackSize.x = base + (maxWidth * wmPtr->widthInc);	base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc);	if (base < 0) {	    base = 0;	}	base += wmPtr->borderHeight;	info->ptMinTrackSize.y = base + (minHeight * wmPtr->heightInc);	info->ptMaxTrackSize.y = base + (maxHeight * wmPtr->heightInc);    } else {	info->ptMaxTrackSize.x = maxWidth + wmPtr->borderWidth;	info->ptMaxTrackSize.y = maxHeight + wmPtr->borderHeight;	info->ptMinTrackSize.x = minWidth + wmPtr->borderWidth;	info->ptMinTrackSize.y = minHeight + wmPtr->borderHeight;    }    /*     * If the window isn't supposed to be resizable, then set the     * minimum and maximum dimensions to be the same as the current size.     */    if (!(wmPtr->flags & WM_SYNC_PENDING)) {	if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) {	    info->ptMinTrackSize.x = winPtr->changes.width		+ wmPtr->borderWidth;	    info->ptMaxTrackSize.x = info->ptMinTrackSize.x;	}	if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {	    info->ptMinTrackSize.y = winPtr->changes.height 		+ wmPtr->borderHeight;	    info->ptMaxTrackSize.y = info->ptMinTrackSize.y;	}    }}/* *---------------------------------------------------------------------- * * TkWinWmCleanup -- * *	Unregisters classes registered by the window manager. This is *	called from the DLL main entry point when the DLL is unloaded. * * Results: *	None. * * Side effects: *	The window classes are discarded. * *---------------------------------------------------------------------- */voidTkWinWmCleanup(hInstance)    HINSTANCE hInstance;{    if (!initialized) {        return;    }    initialized = 0;        UnregisterClass(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);}/* *-------------------------------------------------------------- * * TkWmNewWindow -- * *	This procedure is invoked whenever a new top-level *	window is created.  Its job is to initialize the WmInfo *	structure for the window. * * Results: *	None. * * Side effects: *	A WmInfo structure gets allocated and initialized. * *-------------------------------------------------------------- */voidTkWmNewWindow(winPtr)    TkWindow *winPtr;		/* Newly-created top-level window. */{    register WmInfo *wmPtr;    wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));    winPtr->wmInfoPtr = wmPtr;    wmPtr->winPtr = winPtr;    wmPtr->wrapper = NULL;    wmPtr->titleUid = NULL;    wmPtr->iconName = NULL;    wmPtr->masterPtr = NULL;    wmPtr->hints.flags = InputHint | StateHint;    wmPtr->hints.input = True;    wmPtr->hints.initial_state = NormalState;    wmPtr->hints.icon_pixmap = None;    wmPtr->hints.icon_window = None;    wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0;    wmPtr->hints.icon_mask = None;    wmPtr->hints.window_group = None;    wmPtr->leaderName = NULL;    wmPtr->icon = NULL;    wmPtr->iconFor = NULL;    wmPtr->sizeHintsFlags = 0;    /*     * Default the maximum dimensions to the size of the display.     */    wmPtr->defMinWidth = wmPtr->defMinHeight = 0;    wmPtr->defMaxWidth = DisplayWidth(winPtr->display,	    winPtr->screenNum);    wmPtr->defMaxHeight = DisplayHeight(winPtr->display,	    winPtr->screenNum);    wmPtr->minWidth = wmPtr->minHeight = 1;    wmPtr->maxWidth = wmPtr->maxHeight = 0;    wmPtr->gridWin = NULL;    wmPtr->widthInc = wmPtr->heightInc = 1;    wmPtr->minAspect.x = wmPtr->minAspect.y = 1;    wmPtr->maxAspect.x = wmPtr->maxAspect.y = 1;    wmPtr->reqGridWidth = wmPtr->reqGridHeight = -1;    wmPtr->gravity = NorthWestGravity;    wmPtr->width = -1;    wmPtr->height = -1;    wmPtr->hMenu = NULL;    wmPtr->x = winPtr->changes.x;    wmPtr->y = winPtr->changes.y;    wmPtr->borderWidth = 0;    wmPtr->borderHeight = 0;        wmPtr->cmapList = NULL;    wmPtr->cmapCount = 0;    wmPtr->configWidth = -1;    wmPtr->configHeight = -1;    wmPtr->protPtr = NULL;    wmPtr->cmdArgv = NULL;    wmPtr->clientMachine = NULL;    wmPtr->flags = WM_NEVER_MAPPED;    wmPtr->nextPtr = firstWmPtr;    firstWmPtr = wmPtr;    /*     * Tk must monitor structure events for top-level windows, in order     * to detect size and position changes caused by window managers.     */    Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask,	    TopLevelEventProc, (ClientData) winPtr);    /*     * Arrange for geometry requests to be reflected from the window     * to the window manager.     */    Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0);}/* *---------------------------------------------------------------------- * * UpdateWrapper -- * *	This function creates the wrapper window that contains the *	window decorations and menus for a toplevel.  This function *	may be called after a window is mapped to change the window *	style. * * Results: *	None. * * Side effects: *	Destroys any old wrapper window and replaces it with a newly *	created wrapper. * *---------------------------------------------------------------------- */static voidUpdateWrapper(winPtr)    TkWindow *winPtr;		/* Top-level window to redecorate. */{    register WmInfo *wmPtr = winPtr->wmInfoPtr;    HWND parentHWND = NULL, oldWrapper;    HWND child = TkWinGetHWND(winPtr->window);    int x, y, width, height, state;    WINDOWPLACEMENT place;    parentHWND = NULL;    child = TkWinGetHWND(winPtr->window);     if (winPtr->flags & TK_EMBEDDED) {	wmPtr->wrapper = (HWND) winPtr->privatePtr;	if (wmPtr->wrapper == NULL) {	    panic("TkWmMapWindow: Cannot find container window");	}	if (!IsWindow(wmPtr->wrapper)) {	    panic("TkWmMapWindow: Container was destroyed");	}    } else {	/*	 * Pick the decorative frame style.  Override redirect windows get	 * created as undecorated popups.  Transient windows get a modal	 * dialog frame.  Neither override, nor transient windows appear in	 * the Win95 taskbar.  Note that a transient window does not resize	 * by default, so we need to explicitly add the WS_THICKFRAME style	 * if we want it to be resizeable.	 */		if (winPtr->atts.override_redirect) {	    wmPtr->style = WM_OVERRIDE_STYLE;	    wmPtr->exStyle = EX_OVERRIDE_STYLE;	} else if (wmPtr->masterPtr) {	    wmPtr->style = WM_TRANSIENT_STYLE;	    wmPtr->exStyle = EX_TRANSIENT_STYLE;	    parentHWND = Tk_GetHWND(Tk_WindowId(wmPtr->masterPtr));	    if (! ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && 		    (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE))) {		wmPtr->style |= WS_THICKFRAME;	    }	} else {	    wmPtr->style = WM_TOPLEVEL_STYLE;	    wmPtr->exStyle = EX_TOPLEVEL_STYLE;	}	/*	 * Compute the geometry of the parent and child windows.	 */	wmPtr->flags |= WM_CREATE_PENDING|WM_MOVE_PENDING;	UpdateGeometryInfo((ClientData)winPtr);	wmPtr->flags &= ~(WM_CREATE_PENDING|WM_MOVE_PENDING);	width = wmPtr->borderWidth + winPtr->changes.width;	height = wmPtr->borderHeight + winPtr->changes.height;	/*	 * Set the initial position from the user or program specified	 * location.  If nothing has been specified, then let the system	 * pick a location.	 */   	if (!(wmPtr->sizeHintsFlags & (USPosition | PPosition))		&& (wmPtr->flags & WM_NEVER_MAPPED)) {	    x = CW_USEDEFAULT;	    y = CW_USEDEFAULT;	} else {	    x = winPtr->changes.x;	    y = winPtr->changes.y;	}	/*	 * Create the containing window, and set the user data to point	 * to the TkWindow.	 */	createWindow = winPtr;	wmPtr->wrapper = CreateWindowEx(wmPtr->exStyle,		TK_WIN_TOPLEVEL_CLASS_NAME,		wmPtr->titleUid, wmPtr->style, x, y, width, height,		parentHWND, NULL, Tk_GetHINSTANCE(), NULL);	SetWindowLong(wmPtr->wrapper, GWL_USERDATA, (LONG) winPtr);	createWindow = NULL;	place.length = sizeof(WINDOWPLACEMENT);	GetWindowPlacement(wmPtr->wrapper, &place);	wmPtr->x = place.rcNormalPosition.left;	wmPtr->y = place.rcNormalPosition.top;	TkInstallFrameMenu((Tk_Window) winPtr);    }    /*     * Now we need to reparent the contained window and set its     * style appropriately.  Be sure to update the style first so that     * Windows doesn't try to set the focus to the child window.     */    SetWindowLong(child, GWL_STYLE,	    WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);    if (winPtr->flags & TK_EMBEDDED) {	SetWindowLong(child, GWL_WNDPROC, (LONG) TopLevelProc);    }    oldWrapper = SetParent(child, wmPtr->wrapper);    if (oldWrapper && (oldWrapper != wmPtr->wrapper) 	    && (oldWrapper != GetDesktopWindow())) {	SetWindowLong(oldWrapper, GWL_USERDATA, (LONG) NULL);	/*	 * Remove the menubar before destroying the window so the menubar	 * isn't destroyed.	 */	SetMenu(oldWrapper, NULL);	DestroyWindow(oldWrapper);    }    wmPtr->flags &= ~WM_NEVER_MAPPED;    SendMessage(wmPtr->wrapper, TK_ATTACHWINDOW, (WPARAM) child, 0);    /*     * Force an initial transition from withdrawn to the real     * initial state.	      */    state = wmPtr->hints.initial_state;    wmPtr->hints.initial_state = WithdrawnState;    TkpWmSetState(winPtr, state);    /*     * If we are embedded then force a mapping of the window now,     * because we do not necessarily own the wrapper and may not     * get another opportunity to map ourselves. We should not be     * in either iconified or zoomed states when we get here, so     * it is safe to just check for TK_EMBEDDED without checking     * what state we are supposed to be in (default to NormalState).     */    if (winPtr->flags & TK_EMBEDDED) {	XMapWindow(winPtr->display, winPtr->window);    }    /*     * Set up menus on the wrapper if required.     */            if (wmPtr->hMenu != NULL) {	wmPtr->flags = WM_SYNC_PENDING;	SetMenu(wmPtr->wrapper, wmPtr->hMenu);	wmPtr->flags &= ~WM_SYNC_PENDING;    }    /*     * If this is the first window created by the application, then     * we should activate the initial window.     */    if (firstWindow) {	firstWindow = 0;	SetActiveWindow(wmPtr->wrapper);    }}/* *-------------------------------------------------------------- * * 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(winPtr)    TkWindow *winPtr;		/* Top-level window that's about to				 * be mapped. */{    register WmInfo *wmPtr = winPtr->wmInfoPtr;    if (!initialized) {	InitWm();    }    if (!(wmPtr->flags & WM_NEVER_MAPPED)) {	if (wmPtr->hints.initial_state == WithdrawnState) {	    return;	}	/*	 * Map the window in either the iconified or normal state.  Note that	 * we only send a map event if the window is in the normal state.	 */	TkpWmSetState(winPtr, wmPtr->hints.initial_state);    }    /*     * 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;    }    UpdateWrapper(winPtr);}/* *-------------------------------------------------------------- * * TkWmUnmapWindow -- * *	This procedure is invoked to unmap a top-level window.  The *	only thing it does special is unmap the decorative frame before *	unmapping the toplevel window. * * Results: *	None. * * Side effects: *	Unmaps the decorative frame and the window. * *-------------------------------------------------------------- */voidTkWmUnmapWindow(winPtr)    TkWindow *winPtr;		/* Top-level window that's about to

⌨️ 快捷键说明

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