ibus: make context release explicit
This commit is contained in:
33
ibus.c
33
ibus.c
@@ -19,12 +19,6 @@ enum
|
||||
Ibussupermask = 1<<26,
|
||||
};
|
||||
|
||||
typedef struct Watch Watch;
|
||||
struct Watch
|
||||
{
|
||||
DBusWatch *w;
|
||||
};
|
||||
|
||||
typedef struct Ictx Ictx;
|
||||
struct Ictx
|
||||
{
|
||||
@@ -34,7 +28,7 @@ struct Ictx
|
||||
Caret caret;
|
||||
};
|
||||
|
||||
static Watch watches[Maxwatches];
|
||||
static DBusWatch *watches[Maxwatches];
|
||||
static int nwatches;
|
||||
static DBusConnection *conns[Maxconns];
|
||||
static int nconns;
|
||||
@@ -205,13 +199,13 @@ addwatch(DBusWatch *w, void *_)
|
||||
|
||||
USED(_);
|
||||
for(i = 0; i < nwatches; i++)
|
||||
if(watches[i].w == nil){
|
||||
watches[i].w = w;
|
||||
if(watches[i] == nil){
|
||||
watches[i] = w;
|
||||
return TRUE;
|
||||
}
|
||||
if(nwatches >= Maxwatches)
|
||||
return FALSE;
|
||||
watches[nwatches++].w = w;
|
||||
watches[nwatches++] = w;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -222,8 +216,8 @@ removewatch(DBusWatch *w, void *_)
|
||||
|
||||
USED(_);
|
||||
for(i = 0; i < nwatches; i++)
|
||||
if(watches[i].w == w){
|
||||
watches[i].w = nil;
|
||||
if(watches[i] == w){
|
||||
watches[i] = nil;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -309,11 +303,10 @@ releasecontext(Ictx *ctx)
|
||||
{
|
||||
Keyres res;
|
||||
|
||||
if(replyc != nil)
|
||||
if(ctx->focused)
|
||||
sendrequest(ctx, Keyrelease, 0, 0, &res);
|
||||
ctx->focused = 0;
|
||||
memset(&ctx->caret, 0, sizeof ctx->caret);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -752,17 +745,17 @@ ibusthread(void *_)
|
||||
for(;;){
|
||||
n = 0;
|
||||
for(i = 0; i < nwatches && n < Maxwatches; i++){
|
||||
if(watches[i].w == nil)
|
||||
if(watches[i] == nil)
|
||||
continue;
|
||||
if(!dbus_watch_get_enabled(watches[i].w))
|
||||
if(!dbus_watch_get_enabled(watches[i]))
|
||||
continue;
|
||||
pfds[n].fd = dbus_watch_get_unix_fd(watches[i].w);
|
||||
pfds[n].fd = dbus_watch_get_unix_fd(watches[i]);
|
||||
pfds[n].events = 0;
|
||||
f = dbus_watch_get_flags(watches[i].w);
|
||||
f = dbus_watch_get_flags(watches[i]);
|
||||
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;
|
||||
polled[n] = watches[i];
|
||||
n++;
|
||||
}
|
||||
rv = poll(pfds, n, 200);
|
||||
@@ -771,7 +764,7 @@ ibusthread(void *_)
|
||||
for(i = 0; i < n; i++){
|
||||
if(pfds[i].revents == 0)
|
||||
continue;
|
||||
if(watches[wi[i]].w != polled[i])
|
||||
if(watches[wi[i]] != polled[i])
|
||||
continue;
|
||||
f = 0;
|
||||
if(pfds[i].revents & POLLIN) f |= DBUS_WATCH_READABLE;
|
||||
|
||||
Reference in New Issue
Block a user