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

📄 tkmacembed.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 3 页
字号:
/*  * tkMacEmbed.c -- * *	This file contains platform-specific procedures for theMac to provide *	basic operations needed for application embedding (where one *	application can use as its main window an internal window from *	some other application). *	Currently only Toplevel embedding within the same Tk application is *      allowed on the Macintosh. * * Copyright (c) 1996-97 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: @(#) tkMacEmbed.c 1.6 97/10/31 17:20:22 */#include "tkInt.h"#include "tkPort.h"#include "X.h"#include "Xlib.h"#include <stdio.h>#include <Windows.h>#include <QDOffscreen.h>#include "tkMacInt.h"/* * One of the following structures exists for each container in this * application.  It keeps track of the container window and its * associated embedded window. */typedef struct Container {    Window parent;		/* The Mac Drawable for the parent of				 * the pair (the container). */    TkWindow *parentPtr;	/* Tk's information about the container,				 * or NULL if the container isn't				 * in this process. */    Window embedded;		/* The MacDrawable for the embedded				 * window.  Starts off as None, but				 * gets filled in when the window is				 * eventually created. */    TkWindow *embeddedPtr;	/* Tk's information about the embedded				 * window, or NULL if the				 * embedded application isn't in				 * this process. */    struct Container *nextPtr;	/* Next in list of all containers in				 * this process. */} Container;static Container *firstContainerPtr = NULL;					/* First in list of all containers					 * managed by this process.  *//* * Globals defined in this file */TkMacEmbedHandler *gMacEmbedHandler = NULL;/* * Prototypes for static procedures defined in this file: */static void		ContainerEventProc _ANSI_ARGS_((			    ClientData clientData, XEvent *eventPtr));static void		EmbeddedEventProc _ANSI_ARGS_((			    ClientData clientData, XEvent *eventPtr));static void		EmbedActivateProc _ANSI_ARGS_((ClientData clientData,                             XEvent *eventPtr));static void		EmbedFocusProc _ANSI_ARGS_((ClientData clientData,			    XEvent *eventPtr));static void		EmbedGeometryRequest _ANSI_ARGS_((			    Container * containerPtr, int width, int height));static void		EmbedSendConfigure _ANSI_ARGS_((			    Container *containerPtr));static void		EmbedStructureProc _ANSI_ARGS_((ClientData clientData,			    XEvent *eventPtr));static void		EmbedWindowDeleted _ANSI_ARGS_((TkWindow *winPtr));/* *---------------------------------------------------------------------- * * Tk_MacSetEmbedHandler -- * *	Registers a handler for an in process form of embedding, like  *	Netscape plugins, where Tk is loaded into the process, but does *	not control the main window * * Results: *	None * * Side effects: *	The embed handler is set. * *---------------------------------------------------------------------- */voidTk_MacSetEmbedHandler(    Tk_MacEmbedRegisterWinProc *registerWinProc,    Tk_MacEmbedGetGrafPortProc *getPortProc,    Tk_MacEmbedMakeContainerExistProc *containerExistProc,    Tk_MacEmbedGetClipProc *getClipProc,    Tk_MacEmbedGetOffsetInParentProc *getOffsetProc){    if (gMacEmbedHandler == NULL) {    	gMacEmbedHandler = (TkMacEmbedHandler *) ckalloc(sizeof(TkMacEmbedHandler));    }    gMacEmbedHandler->registerWinProc = registerWinProc;    gMacEmbedHandler->getPortProc = getPortProc;    gMacEmbedHandler->containerExistProc = containerExistProc;    gMacEmbedHandler->getClipProc = getClipProc;    gMacEmbedHandler->getOffsetProc = getOffsetProc;    }/* *---------------------------------------------------------------------- * * TkpMakeWindow -- * *	Creates an X Window (Mac subwindow). * * Results: *	The window id is returned. * * Side effects: *	None. * *---------------------------------------------------------------------- */WindowTkpMakeWindow(    TkWindow *winPtr,    Window parent){    MacDrawable *macWin;    XEvent event;    /*     * If this window is marked as embedded then     * the window structure should have already been     * created in the TkpUseWindow function.     */        if (Tk_IsEmbedded(winPtr)) {	return (Window) winPtr->privatePtr;    }        /*     * Allocate sub window     */        macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable));    if (macWin == NULL) {	winPtr->privatePtr = NULL;	return None;    }    macWin->winPtr = winPtr;    winPtr->privatePtr = macWin;    macWin->clipRgn = NewRgn();    macWin->aboveClipRgn = NewRgn();    macWin->referenceCount = 0;    macWin->flags = TK_CLIP_INVALID;    if (Tk_IsTopLevel(macWin->winPtr)) {		/*	 *This will be set when we are mapped.	 */		macWin->portPtr = (GWorldPtr) NULL;  	macWin->toplevel = macWin;	macWin->xOff = 0;	macWin->yOff = 0;    } else {	macWin->portPtr = NULL;	macWin->xOff = winPtr->parentPtr->privatePtr->xOff +	    winPtr->parentPtr->changes.border_width +	    winPtr->changes.x;	macWin->yOff = winPtr->parentPtr->privatePtr->yOff +	    winPtr->parentPtr->changes.border_width +	    winPtr->changes.y;	macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;    }    macWin->toplevel->referenceCount++;        /*      * TODO: need general solution for visibility events.     */    event.xany.serial = Tk_Display(winPtr)->request;    event.xany.send_event = False;    event.xany.display = Tk_Display(winPtr);	    event.xvisibility.type = VisibilityNotify;    event.xvisibility.window = (Window) macWin;;    event.xvisibility.state = VisibilityUnobscured;    Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    return (Window) macWin;}/* *---------------------------------------------------------------------- * * TkpUseWindow -- * *	This procedure causes a Tk window to use a given X window as *	its parent window, rather than the root window for the screen. *	It is invoked by an embedded application to specify the window *	in which it is embedded. * * Results: *	The return value is normally TCL_OK.  If an error occurs (such *	as string not being a valid window spec), then the return value *	is TCL_ERROR and an error message is left in interp->result if *	interp is non-NULL. * * Side effects: *	None. * *---------------------------------------------------------------------- */intTkpUseWindow(    Tcl_Interp *interp,		/* If not NULL, used for error reporting				 * if string is bogus. */    Tk_Window tkwin,		/* Tk window that does not yet have an				 * associated X window. */    char *string)		/* String identifying an X window to use				 * for tkwin;  must be an integer value. */{    TkWindow *winPtr = (TkWindow *) tkwin;    MacDrawable *parent, *macWin;    Container *containerPtr;    XEvent event;    int result;    if (winPtr->window != None) {	panic("TkpUseWindow: X window already assigned");    }        /*     * Decode the container pointer, and look for it among the      *list of available containers.     *     * N.B. For now, we are limiting the containers to be in the same Tk     * application as tkwin, since otherwise they would not be in our list     * of containers.     *     */         if (Tcl_GetInt(interp, string, &result) != TCL_OK) {	return TCL_ERROR;    }    parent = (MacDrawable *) result;    /*     * Save information about the container and the embedded window     * in a Container structure.  Currently, there must already be an existing     * Container structure, since we only allow the case where both container      * and embedded app. are in the same process.     */    for (containerPtr = firstContainerPtr; containerPtr != NULL;	    containerPtr = containerPtr->nextPtr) {	if (containerPtr->parent == (Window) parent) {	    winPtr->flags |= TK_BOTH_HALVES;	    containerPtr->parentPtr->flags |= TK_BOTH_HALVES;	    break;	}    }        /*     * Make the embedded window.       */    macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable));    if (macWin == NULL) {	winPtr->privatePtr = NULL;	return TCL_ERROR;    }        macWin->winPtr = winPtr;    winPtr->privatePtr = macWin;    /*     * The portPtr will be NULL for a Tk in Tk embedded window.     * It is none of our business what it is for a Tk not in Tk embedded window,     * but we will initialize it to NULL, and let the registerWinProc      * set it.  In any case, you must always use TkMacGetDrawablePort      * to get the portPtr.  It will correctly find the container's port.     */    macWin->portPtr = (GWorldPtr) NULL;    macWin->clipRgn = NewRgn();    macWin->aboveClipRgn = NewRgn();    macWin->referenceCount = 0;    macWin->flags = TK_CLIP_INVALID;    macWin->toplevel = macWin;    macWin->toplevel->referenceCount++;       winPtr->flags |= TK_EMBEDDED;            /*     * Make a copy of the TK_EMBEDDED flag, since sometimes     * we need this to get the port after the TkWindow structure     * has been freed.     */         macWin->flags |= TK_EMBEDDED;        /*     * Now check whether it is embedded in another Tk widget.  If not (the first     * case below) we see if there is an in-process embedding handler registered,     * and if so, let that fill in the rest of the macWin.     */        if (containerPtr == NULL) {	/*	 * If someone has registered an in process embedding handler, then 	 * see if it can handle this window...	 */		if (gMacEmbedHandler == NULL ||		gMacEmbedHandler->registerWinProc(result, (Tk_Window) winPtr) != TCL_OK) {	    Tcl_AppendResult(interp, "The window ID ", string,	            " does not correspond to a valid Tk Window.",		     (char *) NULL);	    return TCL_ERROR;		} else {	    containerPtr = (Container *) ckalloc(sizeof(Container));	    containerPtr->parentPtr = NULL;	    containerPtr->embedded = (Window) macWin;	    containerPtr->embeddedPtr = macWin->winPtr;	    containerPtr->nextPtr = firstContainerPtr;	    firstContainerPtr = containerPtr;	    	}        } else {        	/*          * The window is embedded in another Tk window.         */ 		macWin->xOff = parent->winPtr->privatePtr->xOff +	        parent->winPtr->changes.border_width +	        winPtr->changes.x;	macWin->yOff = parent->winPtr->privatePtr->yOff +	        parent->winPtr->changes.border_width +	        winPtr->changes.y;                /*         * Finish filling up the container structure with the embedded window's          * information.         */     	containerPtr->embedded = (Window) macWin;	containerPtr->embeddedPtr = macWin->winPtr;	/*         * Create an event handler to clean up the Container structure when         * tkwin is eventually deleted.         */        Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,	        (ClientData) winPtr);    }   /*      * TODO: need general solution for visibility events.     */         event.xany.serial = Tk_Display(winPtr)->request;    event.xany.send_event = False;    event.xany.display = Tk_Display(winPtr);	    event.xvisibility.type = VisibilityNotify;    event.xvisibility.window = (Window) macWin;;    event.xvisibility.state = VisibilityUnobscured;    Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);        /*      * TODO: need general solution for visibility events.     */     

⌨️ 快捷键说明

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