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

📄 tkpointer.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 2 页
字号:
		/*		 * If we are releasing a restrict window, then we need		 * to send the button event followed by mouse motion from		 * the restrict window to the current mouse position.		 */		if (restrictWinPtr) {		    InitializeEvent(&event, restrictWinPtr, type, x, y,			    lastState, b);		    Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);		    lastState &= ~mask;		    lastWinPtr = restrictWinPtr;		    restrictWinPtr = NULL;		    GenerateEnterLeave(winPtr, x, y, lastState);		    lastPos = pos;		    continue;		}			    }	    /*	     * If a restrict window is set, make sure the pointer event	     * is reported relative to that window.  Otherwise, if a	     * global grab is in effect then events outside of windows	     * managed by Tk should be reported to the grab window.	     */	    if (restrictWinPtr) {		targetWinPtr = restrictWinPtr;	    } else if (grabWinPtr && !winPtr) {		targetWinPtr = grabWinPtr;	    } else {		targetWinPtr = winPtr;	    }	    /*	     * If we still have a target window, send the event.	     */	    if (winPtr != NULL) {		InitializeEvent(&event, targetWinPtr, type, x, y,			lastState, b);		Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);	    }	    /*	     * Update the state for the next iteration.	     */	    lastState = (type == ButtonPress)		? (lastState | mask) : (lastState & ~mask);	    lastPos = pos;	}    }    /*     * Make sure the cursor window is up to date.     */    if (restrictWinPtr) {	targetWinPtr = restrictWinPtr;    } else if (grabWinPtr) {	targetWinPtr = (TkPositionInTree(winPtr, grabWinPtr)		== TK_GRAB_IN_TREE) ? winPtr : grabWinPtr;    } else {	targetWinPtr = winPtr;    }    UpdateCursor(targetWinPtr);    /*     * If no other events caused the position to be updated,     * generate a motion event.     */    if (lastPos.x != pos.x || lastPos.y != pos.y) {	if (restrictWinPtr) {	    targetWinPtr = restrictWinPtr;	} else if (grabWinPtr && !winPtr) {	    targetWinPtr = grabWinPtr;	}	if (targetWinPtr != NULL) {	    InitializeEvent(&event, targetWinPtr, MotionNotify, x, y,		    lastState, NotifyNormal);	    Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);	}	lastPos = pos;    }}/* *---------------------------------------------------------------------- * * XGrabPointer -- * *	Capture the mouse so event are reported outside of toplevels. *	Note that this is a very limited implementation that only *	supports GrabModeAsync and owner_events True. * * Results: *	Always returns GrabSuccess. * * Side effects: *	Turns on mouse capture, sets the global grab pointer, and *	clears any window restrictions. * *---------------------------------------------------------------------- */intXGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode,	keyboard_mode, confine_to, cursor, time)    Display* display;    Window grab_window;    Bool owner_events;    unsigned int event_mask;    int pointer_mode;    int keyboard_mode;    Window confine_to;    Cursor cursor;    Time time;{    display->request++;    grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window);    restrictWinPtr = NULL;    TkpSetCapture(grabWinPtr);    if (TkPositionInTree(lastWinPtr, grabWinPtr) != TK_GRAB_IN_TREE) {	UpdateCursor(grabWinPtr);    }    return GrabSuccess;}/* *---------------------------------------------------------------------- * * XUngrabPointer -- * *	Release the current grab. * * Results: *	None. * * Side effects: *	Releases the mouse capture. * *---------------------------------------------------------------------- */voidXUngrabPointer(display, time)    Display* display;    Time time;{    display->request++;    grabWinPtr = NULL;    restrictWinPtr = NULL;    TkpSetCapture(NULL);    UpdateCursor(lastWinPtr);}/* *---------------------------------------------------------------------- * * TkPointerDeadWindow -- * *	Clean up pointer module state when a window is destroyed. * * Results: *	None. * * Side effects: *	May release the current capture window. * *---------------------------------------------------------------------- */voidTkPointerDeadWindow(winPtr)    TkWindow *winPtr;{    if (winPtr == lastWinPtr) {	lastWinPtr = NULL;    }    if (winPtr == grabWinPtr) {	grabWinPtr = NULL;    }    if (winPtr == restrictWinPtr) {	restrictWinPtr = NULL;    }    if (!(restrictWinPtr || grabWinPtr)) {	TkpSetCapture(NULL);    }}/* *---------------------------------------------------------------------- * * UpdateCursor -- * *	Set the windows global cursor to the cursor associated with *	the given Tk window. * * Results: *	None. * * Side effects: *	Changes the mouse cursor. * *---------------------------------------------------------------------- */static voidUpdateCursor(winPtr)    TkWindow *winPtr;{    Cursor cursor = None;    /*     * A window inherits its cursor from its parent if it doesn't     * have one of its own.  Top level windows inherit the default     * cursor.     */    cursorWinPtr = winPtr;    while (winPtr != NULL) {	if (winPtr->atts.cursor != None) {	    cursor = winPtr->atts.cursor;	    break;	} else if (winPtr->flags & TK_TOP_LEVEL) {	    break;	}	winPtr = winPtr->parentPtr;    }    TkpSetCursor((TkpCursor) cursor);}/* *---------------------------------------------------------------------- * * XDefineCursor -- * *	This function is called to update the cursor on a window. *	Since the mouse might be in the specified window, we need to *	check the specified window against the current mouse position *	and grab state. * * Results: *	None. * * Side effects: *	May update the cursor. * *---------------------------------------------------------------------- */voidXDefineCursor(display, w, cursor)    Display* display;    Window w;    Cursor cursor;{    TkWindow *winPtr = (TkWindow *)Tk_IdToWindow(display, w);    if (cursorWinPtr == winPtr) {	UpdateCursor(winPtr);    }    display->request++;}/* *---------------------------------------------------------------------- * * TkGenerateActivateEvents -- * *	This function is called by the Mac and Windows window manager *	routines when a toplevel window is activated or deactivated. *	Activate/Deactivate events will be sent to every subwindow of *	the toplevel followed by a FocusIn/FocusOut message. * * Results: *	None. * * Side effects: *	Generates X events. * *---------------------------------------------------------------------- */voidTkGenerateActivateEvents(winPtr, active)    TkWindow *winPtr;		/* Toplevel to activate. */    int active;			/* Non-zero if the window is being				 * activated, else 0.*/{    XEvent event;        /*      * Generate Activate and Deactivate events.  This event     * is sent to every subwindow in a toplevel window.     */    event.xany.serial = winPtr->display->request++;    event.xany.send_event = False;    event.xany.display = winPtr->display;    event.xany.window = winPtr->window;    event.xany.type = active ? ActivateNotify : DeactivateNotify;    TkQueueEventForAllChildren(winPtr, &event);    }

⌨️ 快捷键说明

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