Commit 2d3afb68 authored by Egbert Eich's avatar Egbert Eich

Fixed some lockups in XIM code when the application is running with multi...

Fixed some lockups in XIM code when the application is running with multi thread support. These lockups occur deep down in XFilterEvents() which itself locks when another Xlib function gets called that also locks. This fixes two instances by separating those Xlib functions into an internal (non-locking) call and a locking wrapper that is used as an external function. There may be several other such instances therefore another more general patch is eventually required (Bugzilla #1182).
parent e689746c
......@@ -1298,6 +1298,15 @@ extern void _XSetClipRectangles (
int n,
int ordering);
Status _XGetWindowAttributes(
register Display *dpy,
Window w,
XWindowAttributes *attr);
int _XPutBackEvent (
register Display *dpy,
register XEvent *event);
_XFUNCPROTOEND
#endif /* _XLIBINT_H_ */
......@@ -463,7 +463,7 @@ _XimGetWindowEventmask(
Xim im = (Xim )ic->core.im;
XWindowAttributes atr;
if (!XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
if (!_XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
return 0;
return (EVENTMASK)atr.your_event_mask;
}
......
......@@ -73,7 +73,7 @@ _XimLocalFilter(d, w, ev, client_data)
ic->private.local.composed = p;
/* return back to client KeyPressEvent keycode == 0 */
ev->xkey.keycode = 0;
XPutBackEvent(d, ev);
_XPutBackEvent(d, ev);
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
return(True);
......
......@@ -24,7 +24,6 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86$ */
#define NEED_REPLIES
#include "Xlibint.h"
......@@ -84,10 +83,11 @@ _XWAttrsHandler(
return True;
}
Status XGetWindowAttributes(dpy, w, attr)
register Display *dpy;
Window w;
XWindowAttributes *attr;
Status
_XGetWindowAttributes(
register Display *dpy,
Window w,
XWindowAttributes *attr)
{
xGetGeometryReply rep;
register xResourceReq *req;
......@@ -96,7 +96,6 @@ Status XGetWindowAttributes(dpy, w, attr)
_XAsyncHandler async;
_XWAttrsState async_state;
LockDisplay(dpy);
GetResReq(GetWindowAttributes, w, req);
async_state.attr_seq = dpy->request;
......@@ -113,14 +112,10 @@ Status XGetWindowAttributes(dpy, w, attr)
if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
DeqAsyncHandler(dpy, &async);
UnlockDisplay(dpy);
SyncHandle();
return (0);
}
DeqAsyncHandler(dpy, &async);
if (!async_state.attr) {
UnlockDisplay(dpy);
SyncHandle();
return (0);
}
attr->x = cvtINT16toInt (rep.x);
......@@ -138,8 +133,22 @@ Status XGetWindowAttributes(dpy, w, attr)
break;
}
}
return(1);
}
Status
XGetWindowAttributes(
Display *dpy,
Window w,
XWindowAttributes *attr)
{
Status ret;
LockDisplay(dpy);
ret = _XGetWindowAttributes(dpy, w, attr);
UnlockDisplay(dpy);
SyncHandle();
return(1);
return ret;
}
......@@ -33,16 +33,14 @@ from The Open Group.
#include "Xlibint.h"
int
XPutBackEvent (dpy, event)
register Display *dpy;
register XEvent *event;
_XPutBackEvent (
register Display *dpy,
register XEvent *event)
{
register _XQEvent *qelt;
LockDisplay(dpy);
if (!dpy->qfree) {
if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
UnlockDisplay(dpy);
return 0;
}
dpy->qfree->next = NULL;
......@@ -56,6 +54,18 @@ XPutBackEvent (dpy, event)
if (dpy->tail == NULL)
dpy->tail = qelt;
dpy->qlen++;
UnlockDisplay(dpy);
return 0;
}
int
XPutBackEvent (
register Display * dpy,
register XEvent *event)
{
int ret;
LockDisplay(dpy);
ret = _XPutBackEvent(dpy, event);
UnlockDisplay(dpy);
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment