Do not have a ->name char * field, but a char[32] instead. This isn't a
big problem, the longest color in /etc/X11/rgb.txt is 23 chars long, and
if it becomes a problem one day, one could just strip the name and
generate an hexadecimal representation on the fly instead. But allocating
the name is asking for a lot of trouble.
Since we do not allocate anything anymore, just don't allocate anything
anymore at all, it avoids the mess of xcolor_copy/_wipe and fixes a lot of
sleeping bugs (p_dup were used e.g., which is wrong).
Pass xcolor_t *, xcolor_t becomes too big to be passed by value. Add
consts at some places.
xcolor_new allocates nothing, hence is renamed xcolor_init, has xcolor_t
as a first argument (OO-style, this is self), and doesn't touch the
structure at all if it returns false, which allow us to skip a lot of
intermediates values.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
This avoid flickering when you repeteadly click on a client.
Also make the function client_focus void, it always returned true, and
nobody cares about the result.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
it's useless to escape anything if text_len is 0, also some clients seem
to have a NULL name, so use NONULL(p->priv).
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This improves lots of code efficiency (we *know* how many tags we have
now, YA'RLY).
Also fix a \todo in client.c: since knowing the number of tags is cheap,
ignore props that don't match it.
Use many p_alloca for things that depends on the number of tags (no sane
user will have *thousands* of tags. This saves a few more mallocs.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
For that matter, use elements as a filter for elements we care about, and
let the hook implement whatever it needs without duplicating everything.
The resulting algorithm is still O(n²) where n is the number of filtered
elements (3 at most right now), which isn't bad if we don't need to get
too many elements, but at least it's not quadratic in the number of
attributes anymore.
Speedup improvements could be done using gperf btw.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Do not preemptively allocate a g_markup_escape_text for substitutions,
just remember what we want to substitute markup with, and substitute it in
the final buffer efficiently.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>