Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2011-12-01 14:36:58 +00:00
commit 3197b773c8
7 changed files with 70 additions and 40 deletions

View File

@ -1628,6 +1628,19 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
return Success; return Success;
} }
static void
FreeInputClient(InputClientsPtr *other)
{
free(*other);
*other = NULL;
}
static InputClientsPtr
AllocInputClient(void)
{
return calloc(1, sizeof(InputClients));
}
int int
AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx) AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
{ {
@ -1635,7 +1648,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
if (!pWin->optional && !MakeWindowOptional(pWin)) if (!pWin->optional && !MakeWindowOptional(pWin))
return BadAlloc; return BadAlloc;
others = calloc(1, sizeof(InputClients)); others = AllocInputClient();
if (!others) if (!others)
return BadAlloc; return BadAlloc;
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin)) if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
@ -1649,7 +1662,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
return Success; return Success;
bail: bail:
free(others); FreeInputClient(&others);
return BadAlloc; return BadAlloc;
} }
@ -1665,6 +1678,13 @@ MakeInputMasks(WindowPtr pWin)
return TRUE; return TRUE;
} }
static void
FreeInputMask(OtherInputMasks **imask)
{
free(*imask);
*imask = NULL;
}
void void
RecalculateDeviceDeliverableEvents(WindowPtr pWin) RecalculateDeviceDeliverableEvents(WindowPtr pWin)
{ {
@ -1721,14 +1741,15 @@ InputClientGone(WindowPtr pWin, XID id)
if (other->resource == id) { if (other->resource == id) {
if (prev) { if (prev) {
prev->next = other->next; prev->next = other->next;
free(other); FreeInputClient(&other);
} else if (!(other->next)) { } else if (!(other->next)) {
if (ShouldFreeInputMasks(pWin, TRUE)) { if (ShouldFreeInputMasks(pWin, TRUE)) {
wOtherInputMasks(pWin)->inputClients = other->next; OtherInputMasks *mask = wOtherInputMasks(pWin);
free(wOtherInputMasks(pWin)); mask->inputClients = other->next;
FreeInputMask(&mask);
pWin->optional->inputMasks = (OtherInputMasks *) NULL; pWin->optional->inputMasks = (OtherInputMasks *) NULL;
CheckWindowOptionalNeed(pWin); CheckWindowOptionalNeed(pWin);
free(other); FreeInputClient(&other);
} else { } else {
other->resource = FakeClientID(0); other->resource = FakeClientID(0);
if (!AddResource(other->resource, RT_INPUTCLIENT, if (!AddResource(other->resource, RT_INPUTCLIENT,
@ -1737,7 +1758,7 @@ InputClientGone(WindowPtr pWin, XID id)
} }
} else { } else {
wOtherInputMasks(pWin)->inputClients = other->next; wOtherInputMasks(pWin)->inputClients = other->next;
free(other); FreeInputClient(&other);
} }
RecalculateDeviceDeliverableEvents(pWin); RecalculateDeviceDeliverableEvents(pWin);
return Success; return Success;

View File

@ -80,7 +80,6 @@ ProcXIPassiveGrabDevice(ClientPtr client)
DeviceIntPtr dev, mod_dev; DeviceIntPtr dev, mod_dev;
xXIPassiveGrabDeviceReply rep; xXIPassiveGrabDeviceReply rep;
int i, ret = Success; int i, ret = Success;
uint8_t status;
uint32_t *modifiers; uint32_t *modifiers;
xXIGrabModifierInfo *modifiers_failed; xXIGrabModifierInfo *modifiers_failed;
GrabMask mask; GrabMask mask;
@ -145,32 +144,36 @@ ProcXIPassiveGrabDevice(ClientPtr client)
if (stuff->cursor != None) if (stuff->cursor != None)
{ {
status = dixLookupResourceByType(&tmp, stuff->cursor, ret = dixLookupResourceByType(&tmp, stuff->cursor,
RT_CURSOR, client, DixUseAccess); RT_CURSOR, client, DixUseAccess);
if (status != Success) if (ret != Success)
{ {
client->errorValue = stuff->cursor; client->errorValue = stuff->cursor;
return status; goto out;
} }
} }
status = dixLookupWindow((WindowPtr*)&tmp, stuff->grab_window, client, DixSetAttrAccess); ret = dixLookupWindow((WindowPtr*)&tmp, stuff->grab_window, client, DixSetAttrAccess);
if (status != Success) if (ret != Success)
return status; goto out;
status = CheckGrabValues(client, &param); ret = CheckGrabValues(client, &param);
if (status != Success) if (ret != Success)
return status; goto out;
modifiers = (uint32_t*)&stuff[1] + stuff->mask_len; modifiers = (uint32_t*)&stuff[1] + stuff->mask_len;
modifiers_failed = calloc(stuff->num_modifiers, sizeof(xXIGrabModifierInfo)); modifiers_failed = calloc(stuff->num_modifiers, sizeof(xXIGrabModifierInfo));
if (!modifiers_failed) if (!modifiers_failed) {
return BadAlloc; ret = BadAlloc;
goto out;
}
mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);
for (i = 0; i < stuff->num_modifiers; i++, modifiers++) for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
{ {
uint8_t status = Success;
param.modifiers = *modifiers; param.modifiers = *modifiers;
switch(stuff->grab_type) switch(stuff->grab_type)
{ {
@ -208,6 +211,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
WriteToClient(client, rep.length * 4, (char*)modifiers_failed); WriteToClient(client, rep.length * 4, (char*)modifiers_failed);
free(modifiers_failed); free(modifiers_failed);
out:
return ret; return ret;
} }

View File

@ -469,10 +469,11 @@ GetXI2MaskByte(unsigned char xi2mask[][XI2MASKSIZE], DeviceIntPtr dev, int event
/** /**
* Return the windows complete XI2 mask for the given XI2 event type. * @return TRUE if the mask is set for this event from this device on the
* window, or FALSE otherwise.
*/ */
Mask Bool
GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev) WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
{ {
OtherInputMasks *inputMasks = wOtherInputMasks(win); OtherInputMasks *inputMasks = wOtherInputMasks(win);
int filter; int filter;
@ -484,7 +485,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
evtype = ((xGenericEvent*)ev)->evtype; evtype = ((xGenericEvent*)ev)->evtype;
filter = GetEventFilter(dev, ev); filter = GetEventFilter(dev, ev);
return (GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter); return !!(GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter);
} }
Mask Mask
@ -2075,7 +2076,7 @@ GetClientsForDelivery(DeviceIntPtr dev, WindowPtr win,
{ {
OtherInputMasks *inputMasks = wOtherInputMasks(win); OtherInputMasks *inputMasks = wOtherInputMasks(win);
/* Has any client selected for the event? */ /* Has any client selected for the event? */
if (!GetWindowXI2Mask(dev, win, events)) if (!WindowXI2MaskIsset(dev, win, events))
goto out; goto out;
*clients = inputMasks->inputClients; *clients = inputMasks->inputClients;
} else { } else {
@ -3787,14 +3788,13 @@ CheckPassiveGrabsOnWindow(
} }
if (!activate) if (!activate)
{ break;
return grab;
}
else if (!GetXIType(event) && !GetCoreType(event)) else if (!GetXIType(event) && !GetCoreType(event))
{ {
ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither" ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
" XI 1.x nor core\n", event->any.type); " XI 1.x nor core\n", event->any.type);
return NULL; grab = NULL;
break;
} }
/* The only consumers of corestate are Xi 1.x and core events, which /* The only consumers of corestate are Xi 1.x and core events, which
@ -3860,9 +3860,10 @@ CheckPassiveGrabsOnWindow(
} }
free(xE); free(xE);
return grab; break;
} }
return NULL;
return grab;
#undef CORE_MATCH #undef CORE_MATCH
#undef XI_MATCH #undef XI_MATCH
#undef XI2_MATCH #undef XI2_MATCH
@ -4632,7 +4633,7 @@ DeviceEnterLeaveEvent(
TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask, TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask,
filter, grab); filter, grab);
} else { } else {
if (!GetWindowXI2Mask(mouse, pWin, (xEvent*)event)) if (!WindowXI2MaskIsset(mouse, pWin, (xEvent*)event))
goto out; goto out;
DeliverEventsToWindow(mouse, pWin, (xEvent*)event, 1, filter, DeliverEventsToWindow(mouse, pWin, (xEvent*)event, 1, filter,
NullGrab); NullGrab);

View File

@ -535,7 +535,7 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
/* misc event helpers */ /* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients); extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
extern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev); extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
void FixUpEventFromWindow(SpritePtr pSprite, void FixUpEventFromWindow(SpritePtr pSprite,
xEvent *xE, xEvent *xE,
WindowPtr pWin, WindowPtr pWin,

View File

@ -72,7 +72,7 @@ extern _X_EXPORT int CountBits(const uint8_t *mask, int len);
* this number here is bumped. * this number here is bumped.
*/ */
#define XI2LASTEVENT 17 /* XI_RawMotion */ #define XI2LASTEVENT 17 /* XI_RawMotion */
#define XI2MASKSIZE ((XI2LASTEVENT + 7)/8) /* no of bits for masks */ #define XI2MASKSIZE ((XI2LASTEVENT >> 3) + 1) /* no of bytes for masks */
/** /**
* Scroll types for ::SetScrollValuator and the scroll type in the * Scroll types for ::SetScrollValuator and the scroll type in the

View File

@ -359,4 +359,11 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
extern _X_EXPORT unsigned long globalSerialNumber; extern _X_EXPORT unsigned long globalSerialNumber;
extern _X_EXPORT unsigned long serverGeneration; extern _X_EXPORT unsigned long serverGeneration;
#define BUG_WARN(cond) \
do { if (cond) { \
ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \
__FILE__, __LINE__, __func__); \
xorg_backtrace(); \
} } while(0)
#endif /* MISC_H */ #endif /* MISC_H */

View File

@ -76,7 +76,6 @@ static void dix_update_desktop_dimensions(void)
#define assert_dimensions(_x, _y, _w, _h) \ #define assert_dimensions(_x, _y, _w, _h) \
update_desktop_dimensions(); \ update_desktop_dimensions(); \
printf("%d %d %d %d\n", screenInfo.x, screenInfo.y, screenInfo.width, screenInfo.height); \
assert(screenInfo.x == _x); \ assert(screenInfo.x == _x); \
assert(screenInfo.y == _y); \ assert(screenInfo.y == _y); \
assert(screenInfo.width == _w); \ assert(screenInfo.width == _w); \
@ -88,8 +87,6 @@ static void dix_update_desktop_dimensions(void)
screenInfo.screens[idx]->width = _w; \ screenInfo.screens[idx]->width = _w; \
screenInfo.screens[idx]->height = _h; \ screenInfo.screens[idx]->height = _h; \
printf("Testing\n");
/* single screen */ /* single screen */
screenInfo.numScreens = 1; screenInfo.numScreens = 1;
set_screen(0, x, y, w, h); set_screen(0, x, y, w, h);