View Single Post
Old 09-08-08, 05:14 AM   #8
SmSpillaz
Registered User
 
Join Date: Jul 2008
Posts: 15
Default Re: nvidia-settings crashes X

Here is TryClientEvents from Server 1.4

Code:
1614	
1615	/**************************************************************************
1616	* The following procedures deal with delivering events *
1617	**************************************************************************/
1618	
1619	/**
1620	* Deliver the given events to the given client.
1621	*
1622	* More than one event may be delivered at a time. This is the case with
1623	* DeviceMotionNotifies which may be followed by DeviceValuator events.
1624	*
1625	* TryClientEvents() is the last station before actually writing the events to
1626	* the socket. Anything that is not filtered here, will get delivered to the
1627	* client.
1628	* An event is only delivered if
1629	* - mask and filter match up.
1630	* - no other client has a grab on the device that caused the event.
1631	*
1632	*
1633	* @param client The target client to deliver to.
1634	* @param pEvents The events to be delivered.
1635	* @param count Number of elements in pEvents.
1636	* @param mask Event mask as set by the window.
1637	* @param filter Mask based on event type.
1638	* @param grab Possible grab on the device that caused the event.
1639	*
1640	* @return 1 if event was delivered, 0 if not or -1 if grab was not set by the
1641	* client.
1642	*/
1643	_X_EXPORT int
1644	TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask,
1645	Mask filter, GrabPtr grab)
1646	{
1647	int i;
1648	int type;
1649	
1650	#ifdef DEBUG_EVENTS
1651	ErrorF("Event([%d, %d], mask=0x%x), client=%d",
1652	pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
1653	#endif
1654	if ((client) && (client != serverClient) && (!client->clientGone) &&
1655	((filter == CantBeFiltered) || (mask & filter)))
1656	{
1657	if (grab && !SameClient(grab, client))
1658	return -1; /* don't send, but notify caller */
1659	type = pEvents->u.u.type;
1660	if (type == MotionNotify)
1661	{
1662	if (mask & PointerMotionHintMask)
1663	{
1664	if (WID(inputInfo.pointer->valuator->motionHintWindow) ==
1665	pEvents->u.keyButtonPointer.event)
1666	{
1667	#ifdef DEBUG_EVENTS
1668	ErrorF("\n");
1669	ErrorF("motionHintWindow == keyButtonPointer.event\n");
1670	#endif
1671	return 1; /* don't send, but pretend we did */
1672	}
1673	pEvents->u.u.detail = NotifyHint;
1674	}
1675	else
1676	{
1677	pEvents->u.u.detail = NotifyNormal;
1678	}
1679	}
1680	#ifdef XINPUT
1681	else
1682	{
1683	if ((type == DeviceMotionNotify) &&
1684	MaybeSendDeviceMotionNotifyHint
1685	((deviceKeyButtonPointer*)pEvents, mask) != 0)
1686	return 1;
1687	}
1688	#endif
1689	type &= 0177;
1690	if (type != KeymapNotify)
1691	{
1692	/* all extension events must have a sequence number */
1693	for (i = 0; i < count; i++)
1694	pEvents[i].u.u.sequenceNumber = client->sequence;
1695	}
1696	
1697	if (BitIsOn(criticalEvents, type))
1698	{
1699	#ifdef SMART_SCHEDULE
1700	if (client->smart_priority < SMART_MAX_PRIORITY)
1701	client->smart_priority++;
1702	#endif
1703	SetCriticalOutputPending();
1704	}
1705	
1706	WriteEventsToClient(client, count, pEvents);
1707	#ifdef DEBUG_EVENTS
1708	ErrorF( " delivered\n");
1709	#endif
1710	return 1;
1711	}
1712	else
1713	{
1714	#ifdef DEBUG_EVENTS
1715	ErrorF("\n");
1716	#endif
1717	return 0;
1718	}
1719	}
Here is TryClientEvents from Server 1.5.999

Code:
_X_EXPORT int
TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
                 int count, Mask mask, Mask filter, GrabPtr grab)
{
    int i;
    int type;

#ifdef DEBUG_EVENTS
    ErrorF("[dix] 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(dev->valuator->motionHintWindow) ==
		    pEvents->u.keyButtonPointer.event)
		{
#ifdef DEBUG_EVENTS
		    ErrorF("[dix] \n");
	    ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n");
#endif
		    return 1; /* don't send, but pretend we did */
		}
		pEvents->u.u.detail = NotifyHint;
	    }
	    else
	    {
		pEvents->u.u.detail = NotifyNormal;
	    }
	}
	else
	{
	    if ((type == DeviceMotionNotify) &&
		MaybeSendDeviceMotionNotifyHint
			((deviceKeyButtonPointer*)pEvents, mask) != 0)
		return 1;
	}
	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))
	{
#ifdef SMART_SCHEDULE
	    if (client->smart_priority < SMART_MAX_PRIORITY)
		client->smart_priority++;
#endif
	    SetCriticalOutputPending();
	}

	WriteEventsToClient(client, count, pEvents);
#ifdef DEBUG_EVENTS
	ErrorF("[dix]  delivered\n");
#endif
	return 1;
    }
    else
    {
#ifdef DEBUG_EVENTS
	ErrorF("[dix] \n");
#endif
	return 0;
    }
}

/**
 * Deliver events to a window. At this point, we do not yet know if the event
 * actually needs to be delivered. May activate a grab if the event is a
 * button press.
 *
 * Core events are always delivered to the window owner. If the filter is
 * something other than CantBeFiltered, the event is also delivered to other
 * clients with the matching mask on the window.
 *
 * More than one event may be delivered at a time. This is the case with
 * DeviceMotionNotifies which may be followed by DeviceValuator events.
 *
 * @param pWin The window that would get the event.
 * @param pEvents The events to be delivered.
 * @param count Number of elements in pEvents.
 * @param filter Mask based on event type.
 * @param grab Possible grab on the device that caused the event.
 * @param mskidx Mask index, depending on device that caused event.
 *
 * @return Number of events delivered to various clients.
 */
The problem lies here AFAIK:

Server 1.4
TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask,
Mask filter, GrabPtr grab)

Server 1.5.99999
TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
int count, Mask mask, Mask filter, GrabPtr grab)

The problem is that there are a) Too few arguments for the function and b) DeviceIntPtr and xEvent aren't compatible with each other =)

NVIDIA's fix:

Use XQueryInputVersion (XI2_Major, XI2_Minor); to find out which function to call:

My fix:
I guess I could remove DeviceIntPtr from TryClientEvents and use the xEvent itself through a patch, not so sure how well that would work.

AaronP, any ideas?

-Sm

Last edited by SmSpillaz; 09-08-08 at 05:28 AM. Reason: Finish post
SmSpillaz is offline   Reply With Quote