Use a libev prepare watcher for calling awesome_refresh()
Before this, awesome_refresh() could be called multiple times per mainloop and one had to make sure to add awesome_refresh() calls in the right places. Now, the prepare handler is invoked just before libev puts the process to sleep (e.g. by calling select()) and awesome_refresh() does its thing. All redundant calls to awesome_refresh() are removed, but the one in selection.c has to stay because this function blocks in xcb_wait_for_event() without using libev. Signed-off-by: Uli Schlachter <psychon@znc.in> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
5ad4cdcaf6
commit
55524ece8d
17
awesome.c
17
awesome.c
|
@ -189,6 +189,12 @@ scan(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
a_refresh_cb(EV_P_ ev_prepare *w, int revents)
|
||||||
|
{
|
||||||
|
awesome_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
a_xcb_check_cb(EV_P_ ev_check *w, int revents)
|
a_xcb_check_cb(EV_P_ ev_check *w, int revents)
|
||||||
{
|
{
|
||||||
|
@ -217,8 +223,6 @@ a_xcb_check_cb(EV_P_ ev_check *w, int revents)
|
||||||
xcb_event_handle(&globalconf.evenths, mouse);
|
xcb_event_handle(&globalconf.evenths, mouse);
|
||||||
p_delete(&mouse);
|
p_delete(&mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
awesome_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -346,6 +350,7 @@ main(int argc, char **argv)
|
||||||
/* event loop watchers */
|
/* event loop watchers */
|
||||||
ev_io xio = { .fd = -1 };
|
ev_io xio = { .fd = -1 };
|
||||||
ev_check xcheck;
|
ev_check xcheck;
|
||||||
|
ev_prepare a_refresh;
|
||||||
ev_signal sigint;
|
ev_signal sigint;
|
||||||
ev_signal sigterm;
|
ev_signal sigterm;
|
||||||
ev_signal sighup;
|
ev_signal sighup;
|
||||||
|
@ -449,6 +454,9 @@ main(int argc, char **argv)
|
||||||
ev_check_init(&xcheck, &a_xcb_check_cb);
|
ev_check_init(&xcheck, &a_xcb_check_cb);
|
||||||
ev_check_start(globalconf.loop, &xcheck);
|
ev_check_start(globalconf.loop, &xcheck);
|
||||||
ev_unref(globalconf.loop);
|
ev_unref(globalconf.loop);
|
||||||
|
ev_prepare_init(&a_refresh, &a_refresh_cb);
|
||||||
|
ev_prepare_start(globalconf.loop, &a_refresh);
|
||||||
|
ev_unref(globalconf.loop);
|
||||||
|
|
||||||
/* Allocate a handler which will holds all errors and events */
|
/* Allocate a handler which will holds all errors and events */
|
||||||
xcb_event_handlers_init(globalconf.connection, &globalconf.evenths);
|
xcb_event_handlers_init(globalconf.connection, &globalconf.evenths);
|
||||||
|
@ -549,9 +557,6 @@ main(int argc, char **argv)
|
||||||
xcb_ungrab_server(globalconf.connection);
|
xcb_ungrab_server(globalconf.connection);
|
||||||
xcb_flush(globalconf.connection);
|
xcb_flush(globalconf.connection);
|
||||||
|
|
||||||
/* refresh everything before waiting events */
|
|
||||||
awesome_refresh();
|
|
||||||
|
|
||||||
/* main event loop */
|
/* main event loop */
|
||||||
ev_loop(globalconf.loop, 0);
|
ev_loop(globalconf.loop, 0);
|
||||||
|
|
||||||
|
@ -559,6 +564,8 @@ main(int argc, char **argv)
|
||||||
ev_ref(globalconf.loop);
|
ev_ref(globalconf.loop);
|
||||||
ev_check_stop(globalconf.loop, &xcheck);
|
ev_check_stop(globalconf.loop, &xcheck);
|
||||||
ev_ref(globalconf.loop);
|
ev_ref(globalconf.loop);
|
||||||
|
ev_prepare_stop(globalconf.loop, &a_refresh);
|
||||||
|
ev_ref(globalconf.loop);
|
||||||
ev_io_stop(globalconf.loop, &xio);
|
ev_io_stop(globalconf.loop, &xio);
|
||||||
|
|
||||||
awesome_atexit();
|
awesome_atexit();
|
||||||
|
|
2
dbus.c
2
dbus.c
|
@ -392,8 +392,6 @@ a_dbus_process_requests_on_bus(DBusConnection *dbus_connection, ev_io *dbusio)
|
||||||
|
|
||||||
if(nmsg)
|
if(nmsg)
|
||||||
dbus_connection_flush(dbus_connection);
|
dbus_connection_flush(dbus_connection);
|
||||||
|
|
||||||
awesome_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
1
luaa.c
1
luaa.c
|
@ -862,7 +862,6 @@ luaA_on_timer(EV_P_ ev_timer *w, int revents)
|
||||||
{
|
{
|
||||||
if(globalconf.hooks.timer != LUA_REFNIL)
|
if(globalconf.hooks.timer != LUA_REFNIL)
|
||||||
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.timer, 0, 0);
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.timer, 0, 0);
|
||||||
awesome_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Push a color as a string onto the stack
|
/** Push a color as a string onto the stack
|
||||||
|
|
Loading…
Reference in New Issue