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

📄 tkwinwm.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  * tkWinWm.c -- * *	This module takes care of the interactions between a Tk-based *	application and the window manager.  Among other things, it *	implements the "wm" command and passes geometry information *	to the window manager. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tkWinWm.c 1.67 97/09/23 17:39:47 */#include "tkWinInt.h"/* * Event structure for synthetic activation events.  These events are * placed on the event queue whenever a toplevel gets a WM_MOUSEACTIVATE * message. */typedef struct ActivateEvent {    Tcl_Event ev;    TkWindow *winPtr;} ActivateEvent;/* * A data structure of the following type holds information for * each window manager protocol (such as WM_DELETE_WINDOW) for * which a handler (i.e. a Tcl command) has been defined for a * particular top-level window. */typedef struct ProtocolHandler {    Atom protocol;		/* Identifies the protocol. */    struct ProtocolHandler *nextPtr;				/* Next in list of protocol handlers for				 * the same top-level window, or NULL for				 * end of list. */    Tcl_Interp *interp;		/* Interpreter in which to invoke command. */    char command[4];		/* Tcl command to invoke when a client				 * message for this protocol arrives. 				 * The actual size of the structure varies				 * to accommodate the needs of the actual				 * command. THIS MUST BE THE LAST FIELD OF				 * THE STRUCTURE. */} ProtocolHandler;#define HANDLER_SIZE(cmdLength) \    ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))/* * A data structure of the following type holds window-manager-related * information for each top-level window in an application. */typedef struct TkWmInfo {    TkWindow *winPtr;		/* Pointer to main Tk information for				 * this window. */    HWND wrapper;		/* This is the decorative frame window				 * created by the window manager to wrap				 * a toplevel window.  This window is				 * a direct child of the root window. */    Tk_Uid titleUid;		/* Title to display in window caption.  If				 * NULL, use name of widget. */    Tk_Uid iconName;		/* Name to display in icon. */    TkWindow *masterPtr;	/* Master window for TRANSIENT_FOR property,				 * or NULL. */    XWMHints hints;		/* Various pieces of information for				 * window manager. */    char *leaderName;		/* Path name of leader of window group				 * (corresponds to hints.window_group).				 * Malloc-ed. Note:  this field doesn't				 * get updated if leader is destroyed. */    Tk_Window icon;		/* Window to use as icon for this window,				 * or NULL. */    Tk_Window iconFor;		/* Window for which this window is icon, or				 * NULL if this isn't an icon for anyone. */    /*     * Information used to construct an XSizeHints structure for     * the window manager:     */    int defMinWidth, defMinHeight, defMaxWidth, defMaxHeight;				/* Default resize limits given by system. */    int sizeHintsFlags;		/* Flags word for XSizeHints structure.				 * If the PBaseSize flag is set then the				 * window is gridded;  otherwise it isn't				 * gridded. */    int minWidth, minHeight;	/* Minimum dimensions of window, in				 * grid units, not pixels. */    int maxWidth, maxHeight;	/* Maximum dimensions of window, in				 * grid units, not pixels, or 0 to default. */    Tk_Window gridWin;		/* Identifies the window that controls				 * gridding for this top-level, or NULL if				 * the top-level isn't currently gridded. */    int widthInc, heightInc;	/* Increments for size changes (# pixels				 * per step). */    struct {	int x;	/* numerator */	int y;  /* denominator */    } minAspect, maxAspect;	/* Min/max aspect ratios for window. */    int reqGridWidth, reqGridHeight;				/* The dimensions of the window (in				 * grid units) requested through				 * the geometry manager. */    int gravity;		/* Desired window gravity. */    /*     * Information used to manage the size and location of a window.     */    int width, height;		/* Desired dimensions of window, specified				 * in grid units.  These values are				 * set by the "wm geometry" command and by				 * ConfigureNotify events (for when wm				 * resizes window).  -1 means user hasn't				 * requested dimensions. */    int x, y;			/* Desired X and Y coordinates for window.				 * These values are set by "wm geometry",				 * plus by ConfigureNotify events (when wm				 * moves window).  These numbers are				 * different than the numbers stored in				 * winPtr->changes because (a) they could be				 * measured from the right or bottom edge				 * of the screen (see WM_NEGATIVE_X and				 * WM_NEGATIVE_Y flags) and (b) if the window				 * has been reparented then they refer to the				 * parent rather than the window itself. */    int borderWidth, borderHeight;				/* Width and height of window dressing, in				 * pixels for the current style/exStyle.  This				 * includes the border on both sides of the				 * window. */    int configWidth, configHeight;				/* Dimensions passed to last request that we				 * issued to change geometry of window.  Used				 * to eliminate redundant resize operations. */    HMENU hMenu;		/* the hMenu associated with this menu */    DWORD style, exStyle;	/* Style flags for the wrapper window. */    /*     * List of children of the toplevel which have private colormaps.     */    TkWindow **cmapList;	/* Array of window with private colormaps. */    int cmapCount;		/* Number of windows in array. */    /*     * Miscellaneous information.     */    ProtocolHandler *protPtr;	/* First in list of protocol handlers for				 * this window (NULL means none). */    int cmdArgc;		/* Number of elements in cmdArgv below. */    char **cmdArgv;		/* Array of strings to store in the				 * WM_COMMAND property.  NULL means nothing				 * available. */    char *clientMachine;	/* String to store in WM_CLIENT_MACHINE				 * property, or NULL. */    int flags;			/* Miscellaneous flags, defined below. */    struct TkWmInfo *nextPtr;	/* Next in list of all top-level windows. */} WmInfo;/* * Flag values for WmInfo structures: * * WM_NEVER_MAPPED -		non-zero means window has never been *				mapped;  need to update all info when *				window is first mapped. * WM_UPDATE_PENDING -		non-zero means a call to UpdateGeometryInfo *				has already been scheduled for this *				window;  no need to schedule another one. * WM_NEGATIVE_X -		non-zero means x-coordinate is measured in *				pixels from right edge of screen, rather *				than from left edge. * WM_NEGATIVE_Y -		non-zero means y-coordinate is measured in *				pixels up from bottom of screen, rather than *				down from top. * WM_UPDATE_SIZE_HINTS -	non-zero means that new size hints need to be *				propagated to window manager. * WM_SYNC_PENDING -		set to non-zero while waiting for the window *				manager to respond to some state change. * WM_MOVE_PENDING -		non-zero means the application has requested *				a new position for the window, but it hasn't *				been reflected through the window manager *				yet. * WM_COLORAMPS_EXPLICIT -	non-zero means the colormap windows were *				set explicitly via "wm colormapwindows". * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows" *				was called the top-level itself wasn't *				specified, so we added it implicitly at *				the end of the list. */#define WM_NEVER_MAPPED			(1<<0)#define WM_UPDATE_PENDING		(1<<1)#define WM_NEGATIVE_X			(1<<2)#define WM_NEGATIVE_Y			(1<<3)#define WM_UPDATE_SIZE_HINTS		(1<<4)#define WM_SYNC_PENDING			(1<<5)#define WM_CREATE_PENDING		(1<<6)#define WM_MOVE_PENDING			(1<<7)#define WM_COLORMAPS_EXPLICIT		(1<<8)#define WM_ADDED_TOPLEVEL_COLORMAP	(1<<9)#define WM_WIDTH_NOT_RESIZABLE		(1<<10)#define WM_HEIGHT_NOT_RESIZABLE		(1<<11)/* * Window styles for various types of toplevel windows. */#define WM_OVERRIDE_STYLE (WS_POPUP|WS_CLIPCHILDREN|CS_DBLCLKS)#define EX_OVERRIDE_STYLE (WS_EX_TOOLWINDOW)#define WM_TOPLEVEL_STYLE (WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|CS_DBLCLKS)#define EX_TOPLEVEL_STYLE (0)#define WM_TRANSIENT_STYLE \		(WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_CLIPSIBLINGS|CS_DBLCLKS)#define EX_TRANSIENT_STYLE \		(WS_EX_TOOLWINDOW|WS_EX_DLGMODALFRAME)/* * This module keeps a list of all top-level windows. */static WmInfo *firstWmPtr = NULL;	/* Points to first top-level window. */static WmInfo *foregroundWmPtr = NULL; /* Points to the foreground window. *//* * The variable below is used to enable or disable tracing in this * module.  If tracing is enabled, then information is printed on * standard output about interesting interactions with the window * manager. */static int wmTracing = 0;/* * The following structure is the official type record for geometry * management of top-level windows. */static void		TopLevelReqProc(ClientData dummy, Tk_Window tkwin);static Tk_GeomMgr wmMgrType = {    "wm",				/* name */    TopLevelReqProc,			/* requestProc */    (Tk_GeomLostSlaveProc *) NULL,	/* lostSlaveProc */};/* * Global system palette.  This value always refers to the currently * installed foreground logical palette. */static HPALETTE systemPalette = NULL;/* * Window that is being constructed.  This value is set immediately * before a call to CreateWindowEx, and is used by SetLimits. * This is a gross hack needed to work around Windows brain damage * where it sends the WM_GETMINMAXINFO message before the WM_CREATE * window. */static TkWindow *createWindow = NULL;/* * Flag indicating whether this module has been initialized yet. */static int initialized = 0;/* * Class for toplevel windows. */static WNDCLASS toplevelClass;/* * This flag is cleared when the first window is mapped in a non-iconic * state. */static int firstWindow = 1;/* * Forward declarations for procedures defined in this file: */static int		ActivateWindow _ANSI_ARGS_((Tcl_Event *evPtr,			    int flags));static void		ConfigureEvent _ANSI_ARGS_((TkWindow *winPtr,			    XConfigureEvent *eventPtr));static void		ConfigureTopLevel _ANSI_ARGS_((WINDOWPOS *pos));static void		GenerateConfigureNotify _ANSI_ARGS_((			    TkWindow *winPtr));static void		GetMaxSize _ANSI_ARGS_((WmInfo *wmPtr,			    int *maxWidthPtr, int *maxHeightPtr));static void		GetMinSize _ANSI_ARGS_((WmInfo *wmPtr,			    int *minWidthPtr, int *minHeightPtr));static TkWindow *	GetTopLevel _ANSI_ARGS_((HWND hwnd));static void		InitWm _ANSI_ARGS_((void));static int		InstallColormaps _ANSI_ARGS_((HWND hwnd, int message,			    int isForemost));static void		InvalidateSubTree _ANSI_ARGS_((TkWindow *winPtr,			    Colormap colormap));static int		ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,			    char *string, TkWindow *winPtr));static void		RefreshColormap _ANSI_ARGS_((Colormap colormap));static void		SetLimits _ANSI_ARGS_((HWND hwnd, MINMAXINFO *info));static LRESULT CALLBACK	TopLevelProc _ANSI_ARGS_((HWND hwnd, UINT message,			    WPARAM wParam, LPARAM lParam));static void		TopLevelEventProc _ANSI_ARGS_((ClientData clientData,			    XEvent *eventPtr));static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,			    Tk_Window tkwin));static void		UpdateGeometryInfo _ANSI_ARGS_((			    ClientData clientData));static void		UpdateWrapper _ANSI_ARGS_((TkWindow *winPtr));static LRESULT CALLBACK	WmProc _ANSI_ARGS_((HWND hwnd, UINT message,			    WPARAM wParam, LPARAM lParam));/* *---------------------------------------------------------------------- * * InitWm -- * *	This routine creates the Wm toplevel decorative frame class. * * Results: *	None. * * Side effects: *	Registers a new window class. * *---------------------------------------------------------------------- */static voidInitWm(void){    if (initialized) {        return;    }    initialized = 1;    toplevelClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;    toplevelClass.cbClsExtra = 0;    toplevelClass.cbWndExtra = 0;    toplevelClass.hInstance = Tk_GetHINSTANCE();    toplevelClass.hbrBackground = NULL;    toplevelClass.lpszMenuName = NULL;    toplevelClass.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME;    toplevelClass.lpfnWndProc = WmProc;    toplevelClass.hIcon = LoadIcon(Tk_GetHINSTANCE(), "tk");    toplevelClass.hCursor = LoadCursor(NULL, IDC_ARROW);    if (!RegisterClass(&toplevelClass)) {	panic("Unable to register TkTopLevel class");    }}/* *---------------------------------------------------------------------- * * GetTopLevel -- * *	This function retrieves the TkWindow associated with the *	given HWND. * * Results: *	Returns the matching TkWindow. * * Side effects: *	None. * *---------------------------------------------------------------------- */static TkWindow *GetTopLevel(hwnd)    HWND hwnd;{    /*     * If this function is called before the CreateWindowEx call     * has completed, then the user data slot will not have been     * set yet, so we use the global createWindow variable.     */    if (createWindow) {	return createWindow;    }    return (TkWindow *) GetWindowLong(hwnd, GWL_USERDATA);}/* *---------------------------------------------------------------------- * * SetLimits -- * *	Updates the minimum and maximum window size constraints. * * Results: *	None. * * Side effects: *	Changes the values of the info pointer to reflect the current *	minimum and maximum size values. * *---------------------------------------------------------------------- */static voidSetLimits(hwnd, info)    HWND hwnd;    MINMAXINFO *info;{    register WmInfo *wmPtr;    int maxWidth, maxHeight;    int minWidth, minHeight;    int base;    TkWindow *winPtr = GetTopLevel(hwnd);    if (winPtr == NULL) {	return;    }    wmPtr = winPtr->wmInfoPtr;        /*     * Copy latest constraint info.     */    wmPtr->defMinWidth = info->ptMinTrackSize.x;

⌨️ 快捷键说明

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