-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Andrei Thorp wrote:
> Excerpts from Uli Schlachter's message of Thu Jun 18 13:15:32 -0400 2009:
>> I can't live without submiting a patch, the result of this OCD is attached.
>
> ... so you just manually inlined a function? Heh.
I manually inlined a function in a place where it made no sense to have it as a
seperate function. ;)
So you want something better than that? Does the attached patch satisfy your
demands?
JD: I'm not sure about the ev_ref()/ev_unref() stuff, is this necessary? Did I
get it right?
Cheers,
Uli
- --
"Do you know that books smell like nutmeg or some spice from a foreign land?"
-- Faber in Fahrenheit 451
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iQEcBAEBCAAGBQJKOo4dAAoJECLkKOvLj8sGp/oIAJDWrT5dgSLwcohBRJlgA4ch
zDK1V2simbb7HUbBVLX8l1zohTsm7kMLwYFt6KpH0q++YBYgKRiUVNkqMPMSmOqJ
0pce7kr+5EZa8ygdx0tpVwYOI5pRWVgvFxRiqzErPWbtaO8ALWpLAE+GIdS/m4j7
7Cb6HkU3m7EXgtpJKh8xN7QX26p1KEBmfMS+0S6yF1jzwvhWiOs0s+X9zRzDQIwU
J+oh7i6qtf8P0wXtjadTlOXCSXqMPgKiJOdFnOZ5kuaidSFgazUsJc5VHRL1MLdJ
BuUnXOCgqMKG+tiHNxOUJj27bcnS7KJLMNAbTG/KHQ1IPVvc6CPQLVNB1r8hwuY=
=0eZ+
-----END PGP SIGNATURE-----
>From 4ffdb07e398dce886e45e9e56b357b3313d7833a Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Thu, 18 Jun 2009 19:02:59 +0200
Subject: [PATCH] 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 <[email protected]>
---
awesome.c | 17 ++++++++++++-----
dbus.c | 2 --
luaa.c | 1 -
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/awesome.c b/awesome.c
index 04439cb..785f473 100644
--- a/awesome.c
+++ b/awesome.c
@@ -190,6 +190,12 @@ scan(void)
}
static void
+a_refresh_cb(EV_P_ ev_prepare *w, int revents)
+{
+ awesome_refresh();
+}
+
+static void
a_xcb_check_cb(EV_P_ ev_check *w, int revents)
{
xcb_generic_event_t *mouse = NULL, *event;
@@ -217,8 +223,6 @@ a_xcb_check_cb(EV_P_ ev_check *w, int revents)
xcb_event_handle(&globalconf.evenths, mouse);
p_delete(&mouse);
}
-
- awesome_refresh();
}
static void
@@ -346,6 +350,7 @@ main(int argc, char **argv)
/* event loop watchers */
ev_io xio = { .fd = -1 };
ev_check xcheck;
+ ev_prepare a_refresh;
ev_signal sigint;
ev_signal sigterm;
ev_signal sighup;
@@ -449,6 +454,9 @@ main(int argc, char **argv)
ev_check_init(&xcheck, &a_xcb_check_cb);
ev_check_start(globalconf.loop, &xcheck);
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 */
xcb_event_handlers_init(globalconf.connection, &globalconf.evenths);
@@ -549,9 +557,6 @@ main(int argc, char **argv)
xcb_ungrab_server(globalconf.connection);
xcb_flush(globalconf.connection);
- /* refresh everything before waiting events */
- awesome_refresh();
-
/* main event loop */
ev_loop(globalconf.loop, 0);
@@ -559,6 +564,8 @@ main(int argc, char **argv)
ev_ref(globalconf.loop);
ev_check_stop(globalconf.loop, &xcheck);
ev_ref(globalconf.loop);
+ ev_prepare_stop(globalconf.loop, &a_refresh);
+ ev_ref(globalconf.loop);
ev_io_stop(globalconf.loop, &xio);
awesome_atexit();
diff --git a/dbus.c b/dbus.c
index d74fba9..2fa1824 100644
--- a/dbus.c
+++ b/dbus.c
@@ -392,8 +392,6 @@ a_dbus_process_requests_on_bus(DBusConnection *dbus_connection, ev_io *dbusio)
if(nmsg)
dbus_connection_flush(dbus_connection);
-
- awesome_refresh();
}
static void
diff --git a/luaa.c b/luaa.c
index aa92f3f..d5b3539 100644
--- a/luaa.c
+++ b/luaa.c
@@ -862,7 +862,6 @@ luaA_on_timer(EV_P_ ev_timer *w, int revents)
{
if(globalconf.hooks.timer != LUA_REFNIL)
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.timer, 0, 0);
- awesome_refresh();
}
/** Push a color as a string onto the stack
--
1.6.3.1