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

📄 tkmacwindowmgr.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 3 页
字号:
 */voidXSetInputFocus(    Display* display,    Window focus,    int revert_to,    Time time){    /*     * Don't need to do a thing.  Tk manages the focus for us.     */}/* *---------------------------------------------------------------------- * * TkpChangeFocus -- * *	This procedure is a stub on the Mac because we always own the *	focus if we are a front most application. * * Results: *	The return value is the serial number of the command that *	changed the focus.  It may be needed by the caller to filter *	out focus change events that were queued before the command. *	If the procedure doesn't actually change the focus then *	it returns 0. * * Side effects: *	None. * *---------------------------------------------------------------------- */intTkpChangeFocus(winPtr, force)    TkWindow *winPtr;		/* Window that is to receive the X focus. */    int force;			/* Non-zero means claim the focus even				 * if it didn't originally belong to				 * topLevelPtr's application. */{    /*     * We don't really need to do anything on the Mac.  Tk will     * keep all this state for us.     */    if (winPtr->atts.override_redirect) {	return 0;    }    /*     * Remember the current serial number for the X server and issue     * a dummy server request.  This marks the position at which we     * changed the focus, so we can distinguish FocusIn and FocusOut     * events on either side of the mark.     */    return NextRequest(winPtr->display);}/* *---------------------------------------------------------------------- * * GenerateFocusEvent -- * *	Generate FocusIn/FocusOut events from a Macintosh Activate  *	event.  Note, the activate-on-foreground bit must be set in  *	the SIZE flags to ensure we get Activate/Deactivate in addition  *	to Susspend/Resume events. * * Results: *	Returns true if events were generate. * * Side effects: *	Queue events on Tk's event queue. * *---------------------------------------------------------------------- */static intGenerateFocusEvent(    EventRecord *eventPtr,	/* Incoming Mac event */    Window window)		/* Root X window for event. */{    XEvent event;    Tk_Window tkwin;        tkwin = Tk_IdToWindow(tkDisplayList->display, window);    if (tkwin == NULL) {	return false;    }    /*      * Generate FocusIn and FocusOut events.  This event     * is only sent to the toplevel window.     */    if (eventPtr->modifiers & activeFlag) {	event.xany.type = FocusIn;    } else {	event.xany.type = FocusOut;    }    event.xany.serial = tkDisplayList->display->request;    event.xany.send_event = False;    event.xfocus.display = tkDisplayList->display;    event.xfocus.window = window;    event.xfocus.mode = NotifyNormal;    event.xfocus.detail = NotifyDetailNone;    Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    return true;}/* *---------------------------------------------------------------------- * * GenerateKeyEvent -- * *	Given Macintosh keyUp, keyDown & autoKey events this function *	generates the appropiate X key events.  The window that is passed *	should represent the frontmost window - which will recieve the *	event. * * Results: *	True if event(s) are generated - false otherwise. * * Side effects: *	Additional events may be place on the Tk event queue. * *---------------------------------------------------------------------- */static intGenerateKeyEvent(    EventRecord *eventPtr,	/* Incoming Mac event */    Window window)		/* Root X window for event. */{    Point where;    Tk_Window tkwin;    XEvent event;    /*     * The focus must be in the FrontWindow on the Macintosh.     * We then query Tk to determine the exact Tk window     * that owns the focus.     */    tkwin = Tk_IdToWindow(tkDisplayList->display, window);    tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;    if (tkwin == NULL) {	return false;    }    where.v = eventPtr->where.v;    where.h = eventPtr->where.h;    event.xany.send_event = False;    event.xkey.same_screen = true;    event.xkey.subwindow = None;    event.xkey.time = TkpGetMS();    event.xkey.x_root = where.h;    event.xkey.y_root = where.v;    GlobalToLocal(&where);    Tk_TopCoordsToWindow(tkwin, where.h, where.v, 	    &event.xkey.x, &event.xkey.y);    event.xkey.keycode = eventPtr->message;    event.xany.serial = Tk_Display(tkwin)->request;    event.xkey.window = Tk_WindowId(tkwin);    event.xkey.display = Tk_Display(tkwin);    event.xkey.root = XRootWindow(Tk_Display(tkwin), 0);    event.xkey.state = TkMacButtonKeyState();    if (eventPtr->what == keyDown) {	event.xany.type = KeyPress;	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    } else if (eventPtr->what == keyUp) {	event.xany.type = KeyRelease;	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    } else {	/*	 * Autokey events send multiple XKey events.	 *	 * Note: the last KeyRelease will always be missed with	 * this scheme.  However, most Tk scripts don't look for	 * KeyUp events so we should be OK.	 */	event.xany.type = KeyRelease;	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);	event.xany.type = KeyPress;	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    }    return true;}/* *---------------------------------------------------------------------- * * GeneratePollingEvents -- * *	This function polls the mouse position and generates X Motion, *	Enter & Leave events.  The cursor is also updated at this *	time. * * Results: *	True if event(s) are generated - false otherwise.   * * Side effects: *	Additional events may be place on the Tk event queue. *	The cursor may be changed. * *---------------------------------------------------------------------- */static intGeneratePollingEvents(){    Tk_Window tkwin, rootwin;    Window window;    WindowRef whichwindow, frontWin;    Point whereLocal, whereGlobal;    Boolean inContentRgn;    short part;    int local_x, local_y;    int generatedEvents = false;        /*     * First we get the current mouse position and determine     * what Tk window the mouse is over (if any).     */    frontWin = FrontWindow();    if (frontWin == NULL) {	return false;    }    SetPort((GrafPort *) frontWin);       GetMouse(&whereLocal);    whereGlobal = whereLocal;    LocalToGlobal(&whereGlobal);	    part = FindWindow(whereGlobal, &whichwindow);    inContentRgn = (part == inContent || part == inGrow);    if ((frontWin != whichwindow) || !inContentRgn) {	tkwin = NULL;    } else {	window = TkMacGetXWindow(whichwindow);	rootwin = Tk_IdToWindow(tkDisplayList->display, window);	if (rootwin == NULL) {	    tkwin = NULL;	} else {	    tkwin = Tk_TopCoordsToWindow(rootwin, whereLocal.h, whereLocal.v, 		    &local_x, &local_y);	}    }        /*     * The following call will generate the appropiate X events and     * adjust any state that Tk must remember.     */    if ((tkwin == NULL) && (gGrabWinPtr != NULL)) {	tkwin = gGrabWinPtr;    }    Tk_UpdatePointer(tkwin, whereGlobal.h,  whereGlobal.v,	    TkMacButtonKeyState());        /*     * Finally, we make sure the proper cursor is installed.  The installation     * is polled to 1) make our resize hack work, and 2) make sure we have the      * proper cursor even if someone else changed the cursor out from under     * us.     */    if ((gGrabWinPtr == NULL) && (part == inGrow) && 	    TkMacResizable((TkWindow *) tkwin) && 	    (TkMacGetScrollbarGrowWindow((TkWindow *) tkwin) == NULL)) {	TkMacInstallCursor(1);    } else {	TkMacInstallCursor(0);    }    return true;}/* *---------------------------------------------------------------------- * * GeneratePollingEvents2 -- * *	This function polls the mouse position and generates X Motion, *	Enter & Leave events.  The cursor is also updated at this *	time.  NOTE: this version is for Netscape!!! * * Results: *	True if event(s) are generated - false otherwise.   * * Side effects: *	Additional events may be place on the Tk event queue. *	The cursor may be changed. * *---------------------------------------------------------------------- */static intGeneratePollingEvents2(    Window window,    int adjustCursor){    Tk_Window tkwin, rootwin;    WindowRef whichwindow, frontWin;    Point whereLocal, whereGlobal;    int local_x, local_y;    int generatedEvents = false;    Rect bounds;        /*     * First we get the current mouse position and determine     * what Tk window the mouse is over (if any).     */    frontWin = FrontWindow();    if (frontWin == NULL) {	return false;    }    SetPort((GrafPort *) frontWin);       GetMouse(&whereLocal);    whereGlobal = whereLocal;    LocalToGlobal(&whereGlobal);    /*     * Determine if we are in a Tk window or not.     */    whichwindow = (WindowRef) TkMacGetDrawablePort(window);    if (whichwindow != frontWin) {	tkwin = NULL;    } else {	rootwin = Tk_IdToWindow(tkDisplayList->display, window);	TkMacWinBounds((TkWindow *) rootwin, &bounds);	if (!PtInRect(whereLocal, &bounds)) {	    tkwin = NULL;	} else {	    tkwin = Tk_TopCoordsToWindow(rootwin, whereLocal.h, whereLocal.v, 		    &local_x, &local_y);	}    }        /*     * The following call will generate the appropiate X events and     * adjust any state that Tk must remember.     */    if ((tkwin == NULL) && (gGrabWinPtr != NULL)) {	tkwin = gGrabWinPtr;    }    Tk_UpdatePointer(tkwin, whereGlobal.h,  whereGlobal.v,	    TkMacButtonKeyState());        /*     * Finally, we make sure the proper cursor is installed.  The installation     * is polled to 1) make our resize hack work, and 2) make sure we have the      * proper cursor even if someone else changed the cursor out from under     * us.     */         if (adjustCursor) {        TkMacInstallCursor(0);    }    return true;}/* *---------------------------------------------------------------------- * * TkMacButtonKeyState -- * *	Returns the current state of the button & modifier keys. * * Results: *	A bitwise inclusive OR of a subset of the following: *	Button1Mask, ShiftMask, LockMask, ControlMask, Mod?Mask, *	Mod?Mask. * * Side effects: *	None. * *---------------------------------------------------------------------- */unsigned intTkMacButtonKeyState(){    unsigned int state = 0;    KeyMap theKeys;    if (Button() & !gEatButtonUp) {	state |= Button1Mask;    }    GetKeys(theKeys);    if (theKeys[1] & 2) {	state |= LockMask;    }    if (theKeys[1] & 1) {	state |= ShiftMask;    }    if (theKeys[1] & 8) {	state |= ControlMask;    }    if (theKeys[1] & 32768) {	state |= Mod1Mask;		/* command key */    }    if (theKeys[1] & 4) {	state |= Mod2Mask;		/* option key */    }    return state;}/* *---------------------------------------------------------------------- * * XGrabKeyboard -- * *	Simulates a keyboard grab by setting the focus. * * Results: *	Always returns GrabSuccess. * * Side effects: *	Sets the keyboard focus to the specified window. * *---------------------------------------------------------------------- */intXGrabKeyboard(    Display* display,    Window grab_window,    Bool owner_events,    int pointer_mode,    int keyboard_mode,    Time time){    gKeyboardWinPtr = Tk_IdToWindow(display, grab_window);    return GrabSuccess;}/* *---------------------------------------------------------------------- * * XUngrabKeyboard -- * *	Releases the simulated keyboard grab. * * Results: *	None. * * Side effects: *	Sets the keyboard focus back to the value before the grab. * *---------------------------------------------------------------------- */voidXUngrabKeyboard(    Display* display,    Time time){    gKeyboardWinPtr = NULL;}/* *---------------------------------------------------------------------- * * XQueryPointer -- * *	Check the current state of the mouse.  This is not a complete *	implementation of this function.  It only computes the root *	coordinates and the current mask. * * Results: *	Sets root_x_return, root_y_return, and mask_return.  Returns *	true on success. * * Side effects: *	None. * *---------------------------------------------------------------------- */BoolXQueryPointer(    Display* display,    Window w,    Window* root_return,    Window* child_return,    int* root_x_return,    int* root_y_return,    int* win_x_return,    int* win_y_return,    unsigned int* mask_return){    Point where;    GetMouse(&where);    LocalToGlobal(&where);    *root_x_return = where.h;    *root_y_return = where.v;    *mask_return = TkMacButtonKeyState();        return True;}/* *---------------------------------------------------------------------- * * TkMacGenerateTime -- * *	Returns the total number of ticks from startup  This function *	is used to generate the time of generated X events. * * Results: *	Returns the current time (ticks from startup). * * Side effects: *	None. * *---------------------------------------------------------------------- */TimeTkMacGenerateTime(){    return (Time) LMGetTicks();}

⌨️ 快捷键说明

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