fix: harden caret and IBus dispatch
This commit is contained in:
7
ibus.c
7
ibus.c
@@ -558,7 +558,6 @@ handlecursor(DBusConnection *c, DBusMessage *m, Ictx *ctx)
|
||||
ctx->caret.valid = 1;
|
||||
ctx->caret.x = x;
|
||||
ctx->caret.y = y;
|
||||
ctx->caret.w = w;
|
||||
ctx->caret.h = h;
|
||||
if(ctx->focused)
|
||||
sendrequest(ctx, Keycaret, 0, 0, &res);
|
||||
@@ -743,6 +742,7 @@ void
|
||||
ibusthread(void *_)
|
||||
{
|
||||
struct pollfd pfds[Maxwatches];
|
||||
DBusWatch *polled[Maxwatches];
|
||||
int wi[Maxwatches];
|
||||
int i, n, rv;
|
||||
unsigned int f;
|
||||
@@ -765,6 +765,7 @@ ibusthread(void *_)
|
||||
if(f & DBUS_WATCH_READABLE) pfds[n].events |= POLLIN;
|
||||
if(f & DBUS_WATCH_WRITABLE) pfds[n].events |= POLLOUT;
|
||||
wi[n] = i;
|
||||
polled[n] = watches[i].w;
|
||||
n++;
|
||||
}
|
||||
rv = poll(pfds, n, 200);
|
||||
@@ -773,14 +774,14 @@ ibusthread(void *_)
|
||||
for(i = 0; i < n; i++){
|
||||
if(pfds[i].revents == 0)
|
||||
continue;
|
||||
if(watches[wi[i]].w == nil)
|
||||
if(watches[wi[i]].w != polled[i])
|
||||
continue;
|
||||
f = 0;
|
||||
if(pfds[i].revents & POLLIN) f |= DBUS_WATCH_READABLE;
|
||||
if(pfds[i].revents & POLLOUT) f |= DBUS_WATCH_WRITABLE;
|
||||
if(pfds[i].revents & POLLHUP) f |= DBUS_WATCH_HANGUP;
|
||||
if(pfds[i].revents & POLLERR) f |= DBUS_WATCH_ERROR;
|
||||
dbus_watch_handle(watches[wi[i]].w, f);
|
||||
dbus_watch_handle(polled[i], f);
|
||||
}
|
||||
for(i = 0; i < nconns; i++)
|
||||
while(dbus_connection_dispatch(conns[i]) == DBUS_DISPATCH_DATA_REMAINS)
|
||||
|
||||
Reference in New Issue
Block a user