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

📄 events.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 5 页
字号:
		ComputeFreezes();	    }	    break;	case NOT_GRABBED:		/* Replay */	    if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT)	    {		if (thisSynced)		    thisDev->sync.other = NullGrab;		syncEvents.replayDev = thisDev;		syncEvents.replayWin = thisDev->grab->window;		(*thisDev->DeactivateGrab)(thisDev);		syncEvents.replayDev = (DeviceIntPtr)NULL;	    }	    break;	case THAW_OTHERS:		/* AsyncOthers */	    if (othersFrozen)	    {		for (dev = inputInfo.devices; dev; dev = dev->next)		{		    if (dev == thisDev)			continue;		    if (dev->grab && SameClient(dev->grab, client))			dev->sync.state = THAWED;		    if (dev->sync.other && SameClient(dev->sync.other, client))			dev->sync.other = NullGrab;		}		ComputeFreezes();	    }	    break;    }}intProcAllowEvents(client)    register ClientPtr client;{    TimeStamp		time;    DeviceIntPtr	mouse = inputInfo.pointer;    DeviceIntPtr	keybd = inputInfo.keyboard;    REQUEST(xAllowEventsReq);    REQUEST_SIZE_MATCH(xAllowEventsReq);    time = ClientTimeToServerTime(stuff->time);    switch (stuff->mode)    {	case ReplayPointer:	    AllowSome(client, time, mouse, NOT_GRABBED);	    break;	case SyncPointer: 	    AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);	    break;	case AsyncPointer: 	    AllowSome(client, time, mouse, THAWED);	    break;	case ReplayKeyboard: 	    AllowSome(client, time, keybd, NOT_GRABBED);	    break;	case SyncKeyboard: 	    AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);	    break;	case AsyncKeyboard: 	    AllowSome(client, time, keybd, THAWED);	    break;	case SyncBoth:	    AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);	    break;	case AsyncBoth:	    AllowSome(client, time, keybd, THAWED_BOTH);	    break;	default: 	    client->errorValue = stuff->mode;	    return BadValue;    }    return Success;}voidReleaseActiveGrabs(client)    ClientPtr client;{    register DeviceIntPtr dev;    Bool    done;    /* XXX CloseDownClient should remove passive grabs before     * releasing active grabs.     */    do {    	done = TRUE;    	for (dev = inputInfo.devices; dev; dev = dev->next)    	{	    if (dev->grab && SameClient(dev->grab, client))	    {	    	(*dev->DeactivateGrab)(dev);	    	done = FALSE;	    }    	}    } while (!done);}/************************************************************************** *            The following procedures deal with delivering events        * **************************************************************************/intTryClientEvents (client, pEvents, count, mask, filter, grab)    ClientPtr client;    GrabPtr grab;    xEvent *pEvents;    int count;    Mask mask, filter;{    int i;    int type;#ifdef DEBUG    if (debug_events) ErrorF(	"Event([%d, %d], mask=0x%x), client=%d",	pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);#endif    if ((client) && (client != serverClient) && (!client->clientGone) &&	((filter == CantBeFiltered) || (mask & filter)))    {	if (grab && !SameClient(grab, client))	    return -1; /* don't send, but notify caller */	type = pEvents->u.u.type;	if (type == MotionNotify)	{	    if (mask & PointerMotionHintMask)	    {		if (WID(inputInfo.pointer->valuator->motionHintWindow) ==		    pEvents->u.keyButtonPointer.event)		{#ifdef DEBUG		    if (debug_events) ErrorF("\n");#endif		    return 1; /* don't send, but pretend we did */		}		pEvents->u.u.detail = NotifyHint;	    }	    else	    {		pEvents->u.u.detail = NotifyNormal;	    }	}#ifdef XINPUT	else	{	    if ((type == DeviceMotionNotify) &&		MaybeSendDeviceMotionNotifyHint			((deviceKeyButtonPointer*)pEvents, mask) != 0)		return 1;	}#endif	type &= 0177;	if (type != KeymapNotify)	{	    /* all extension events must have a sequence number */	    for (i = 0; i < count; i++)		pEvents[i].u.u.sequenceNumber = client->sequence;	}	if (BitIsOn(criticalEvents, type))	    SetCriticalOutputPending();	WriteEventsToClient(client, count, pEvents);#ifdef DEBUG	if (debug_events) ErrorF(  " delivered\n");#endif	return 1;    }    else    {#ifdef DEBUG	if (debug_events) ErrorF("\n");#endif	return 0;    }}intDeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx)    register WindowPtr pWin;    GrabPtr grab;    xEvent *pEvents;    int count;    Mask filter;    int mskidx;{    int deliveries = 0, nondeliveries = 0;    int attempt;    register InputClients *other;    ClientPtr client = NullClient;    Mask deliveryMask; 	/* If a grab occurs due to a button press, then		              this mask is the mask of the grab. */    int type = pEvents->u.u.type;    /* CantBeFiltered means only window owner gets the event */    if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE))    {	/* if nobody ever wants to see this event, skip some work */	if (filter != CantBeFiltered &&	    !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))	    return 0;	if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,				      pWin->eventMask, filter, grab)) )	{	    if (attempt > 0)	    {		deliveries++;		client = wClient(pWin);		deliveryMask = pWin->eventMask;	    } else		nondeliveries--;	}    }    if (filter != CantBeFiltered)    {	if (type & EXTENSION_EVENT_BASE)	{	    OtherInputMasks *inputMasks;	    inputMasks = wOtherInputMasks(pWin);	    if (!inputMasks ||		!(inputMasks->inputEvents[mskidx] & filter))		return 0;	    other = inputMasks->inputClients;	}	else	    other = (InputClients *)wOtherClients(pWin);	for (; other; other = other->next)	{	    if ( (attempt = TryClientEvents(rClient(other), pEvents, count,					  other->mask[mskidx], filter, grab)) )	    {		if (attempt > 0)		{		    deliveries++;		    client = rClient(other);		    deliveryMask = other->mask[mskidx];		} else		    nondeliveries--;	    }	}    }    if ((type == ButtonPress) && deliveries && (!grab))    {	GrabRec tempGrab;	tempGrab.device = inputInfo.pointer;	tempGrab.resource = client->clientAsMask;	tempGrab.window = pWin;	tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;	tempGrab.eventMask = deliveryMask;	tempGrab.keyboardMode = GrabModeAsync;	tempGrab.pointerMode = GrabModeAsync;	tempGrab.confineTo = NullWindow;	tempGrab.cursor = NullCursor;	(*inputInfo.pointer->ActivateGrab)(inputInfo.pointer, &tempGrab,					   currentTime, TRUE);    }    else if ((type == MotionNotify) && deliveries)	inputInfo.pointer->valuator->motionHintWindow = pWin;#ifdef XINPUT    else    {	if (((type == DeviceMotionNotify) || (type == DeviceButtonPress)) &&	    deliveries)	    CheckDeviceGrabAndHintWindow (pWin, type,					  (deviceKeyButtonPointer*) pEvents,					  grab, client, deliveryMask);    }#endif    if (deliveries)	return deliveries;    return nondeliveries;}/* If the event goes to dontClient, don't send it and return 0.  if   send works,  return 1 or if send didn't work, return 2.   Only works for core events.*/intMaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)    register WindowPtr pWin;    xEvent *pEvents;    int count;    Mask filter;    ClientPtr dontClient;{    register OtherClients *other;    if (pWin->eventMask & filter)    {        if (wClient(pWin) == dontClient)	    return 0;	return TryClientEvents(wClient(pWin), pEvents, count,			       pWin->eventMask, filter, NullGrab);    }    for (other = wOtherClients(pWin); other; other = other->next)    {	if (other->mask & filter)	{            if (SameClient(other, dontClient))		return 0;	    return TryClientEvents(rClient(other), pEvents, count,				   other->mask, filter, NullGrab);	}    }    return 2;}static void#if NeedFunctionPrototypesFixUpEventFromWindow(    xEvent *xE,    WindowPtr pWin,    Window child,    Bool calcChild)#elseFixUpEventFromWindow(xE, pWin, child, calcChild)    xEvent *xE;    WindowPtr pWin;    Window child;    Bool calcChild;#endif{    if (calcChild)    {        WindowPtr w=spriteTrace[spriteTraceGood-1];	/* If the search ends up past the root should the child field be 	 	set to none or should the value in the argument be passed 		through. It probably doesn't matter since everyone calls 		this function with child == None anyway. */        while (w)         {            /* If the source window is same as event window, child should be		none.  Don't bother going all all the way back to the root. */ 	    if (w == pWin)	    {    		child = None; 		break;	    }	    	    if (w->parent == pWin)	    {		child = w->drawable.id;		break;            } 	    w = w->parent;        } 	        }    xE->u.keyButtonPointer.root = ROOT->drawable.id;    xE->u.keyButtonPointer.event = pWin->drawable.id;    if (sprite.hot.pScreen == pWin->drawable.pScreen)    {	xE->u.keyButtonPointer.sameScreen = xTrue;	xE->u.keyButtonPointer.child = child;	xE->u.keyButtonPointer.eventX =	    xE->u.keyButtonPointer.rootX - pWin->drawable.x;	xE->u.keyButtonPointer.eventY =	    xE->u.keyButtonPointer.rootY - pWin->drawable.y;    }    else    {	xE->u.keyButtonPointer.sameScreen = xFalse;	xE->u.keyButtonPointer.child = None;	xE->u.keyButtonPointer.eventX = 0;	xE->u.keyButtonPointer.eventY = 0;    }}intDeliverDeviceEvents(pWin, xE, grab, stopAt, dev, count)    register WindowPtr pWin, stopAt;    register xEvent *xE;    GrabPtr grab;    DeviceIntPtr dev;    int count;{    Window child = None;    int type = xE->u.u.type;    Mask filter = filters[type];    int deliveries = 0;    if (type & EXTENSION_EVENT_BASE)    {	register OtherInputMasks *inputMasks;	int mskidx = dev->id;	inputMasks = wOtherInputMasks(pWin);	if (inputMasks && !(filter & inputMasks->deliverableEvents[mskidx]))	    return 0;	while (pWin)	{	    if (inputMasks && (inputMasks->inputEvents[mskidx] & filter))	    {		FixUpEventFromWindow(xE, pWin, child, FALSE);		deliveries = DeliverEventsToWindow(pWin, xE, count, filter,						   grab, mskidx);		if (deliveries > 0)		    return deliveries;	    }	    if ((deliveries < 0) ||		(pWin == stopAt) ||		(inputMasks &&		 (filter & inputMasks->dontPropagateMask[mskidx])))		return 0;	    child = pWin->drawable.id;	    pWin = pWin->parent;	    if (pWin)		inputMasks = wOtherInputMasks(pWin);	}    }    else    {	if (!(filter & pWin->deliverableEvents))	    return 0;	while (pWin)	{	    if ((wOtherEventMasks(pWin)|pWin->eventMask) & filter)	    {		FixUpEventFromWindow(xE, pWin, child, FALSE);		deliveries = DeliverEventsToWindow(pWin, xE, count, filter,						   grab, 0);		if (deliveries > 0)		    return deliveries;	    }	    if ((deliveries < 0) ||		(pWin == stopAt) ||		(filter & wDontPropagateMask(pWin)))		return 0;	    child = pWin->drawable.id;	    pWin = pWin->parent;	}    }    return 0;}/* not useful for events that propagate up the tree or extension events */intDeliverEvents(pWin, xE, count, otherParent)    register WindowPtr pWin, otherParent;    register xEvent *xE;    int count;{    Mask filter;    int     deliveries;    if (!count)	return 0;    filter = filters[xE->u.u.type];    if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify))	xE->u.destroyNotify.event = pWin->drawable.id;    if (filter != StructureAndSubMask)	return DeliverEventsToWindow(pWin, xE, count, filter, NullGrab, 0);    deliveries = DeliverEventsToWindow(pWin, xE, count, StructureNotifyMask,				       NullGrab, 0);    if (pWin->parent)    {	xE->u.destroyNotify.event = pWin->parent->drawable.id;	deliveries += DeliverEventsToWindow(pWin->parent, xE, count,					    SubstructureNotifyMask, NullGrab,					    0);	if (xE->u.u.type == ReparentNotify)	{	    xE->u.destroyNotify.event = otherParent->drawable.id;	    deliveries += DeliverEventsToWindow(otherParent, xE, count,						SubstructureNotifyMask,						NullGrab, 0);	}    }    return deliveries;}static WindowPtr #if NeedFunctionPrototypesXYToWindow(int x, int y)#elseXYToWindow(x, y)	int x, y;#endif{    register WindowPtr  pWin;#ifdef SHAPE    BoxRec		box;#endif    spriteTraceGood = 1;	/* root window still there */    pWin = ROOT->firstChild;    while (pWin)    {	if ((pWin->mapped) &&		(x >= pWin->drawable.x - wBorderWidth (pWin)) &&		(x < pWin->drawable.x + (int)pWin->drawable.width +		    wBorderWidth(pWin)) &&

⌨️ 快捷键说明

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