One can now bind the left/middle/right mouse buttons to on-click. In
fact, you can have all three buttons bound to different handlers for
the same particle. The new syntax is
on-click:
left: <command>
middle: <command>
right: <command>
Leaving one out is the same thing as not mapping it at
all. Furthermore,
on-click: <command>
is still valid, and is a shorthand for
on-click:
left: <commsnd>
a5bbf0b769 introduced text-run
shaping.
Do avoid having to re-shape non-changing strings every time the bar is
refreshed, the *particle* (i.e. not the exposable) caches the last
shaped text-run.
Then, in expose(), it then assumes that that cached text-run is
the *same* text-run as returned from begin_expose().
This is true in most cases, but *not* when a single particle is
re-used to instantiate multiple exposables, as is commonly done by
modules generating dynlists. For example, the i3/sway module.
This fixes it, by making the cache growable, and by adding a “lock” to
each cache entry.
The lock is set in begin_expose(), to indicate that this particular
cache entry is needed in expose().
If we can’t find a matching cache entry, we first try to find a free
“slot” by searching for either unused, or used-but-not-locked cache
entries.
If that fails, we grow the cache and add a new entry.
In expose(), we unset the lock.
Closes#47
This enables support for text shaping, and is required to render
e.g. 👩👩👧👧 correctly.
Since text-shaping is a fairly expensive operation, and since many
times the text is unchanged, we cache the last *rendered* string.
That is, we hash the instantiated string, and cache it along with the
text-run from fcft in the *particle* object (i.e. not the exposable).
This means two things:
* we only need to call fcft_text_run_rasterize() once per string
* if the string is the same as last time, we don’t have to call it at
all.
All decoration, particle and module interfaces now takes a
pixman_image_t parameter, and all drawing is done using pixman APIs.
The wayland/xcb backends implement a new interface functions,
get_pixman_image(), that should return a pixman image instance that is
suitable for rendering.
In the wayland backend, the image uses the same backing data as the
cairo surface.
In the XCB backend, we create a new image each time, and then blit it
to the cairo surface at commit time.
In cases where it makes sense, use calloc() instead of malloc():
* When allocating large objects with many members, many for which
NULL/0 is a good default value.
* Arrays etc where we explicitly initialize to NULL anyway.
In begin_expose(), we call cairo_scaled_font_text_to_glyphs()
with (x,y) = (0,0), in order to calculate the glyph extents (needed
for width calculation).
Then, in expose(), we called it again, but with correct (x,y) offsets.
Simplify this, by caching the glyphs from begin_expose(). Then, in
expose(), simply adjust the glyph offsets before calling
cairo_show_text_glyphs().
When limiting a string (due to it exceeding it's max length), make
sure not to cut it in the middle of an utf-8 multibyte, as this
results in an invalid utf-8 string.
In particular, use cairo_scaled_font_text_to_glyphs() to calculate the
extents, since the cairo_scaled_font_text_extents() will leave the
scaled font in an error state, which is impossible to recuperate from.
Since this struct only contained function pointers, make all particles
export those functions directly.
The plugin manager now defines a particle interface struct, and fills
it it by dlsym:ing the functions that used to be in particle_info.
This allows us to a) move away from cairo's "toy" API, and b) let the
user specify font options in a single font "name" string:
Serif:size=10:weight=bold:slant=italic
This also allows us to simplify the font code significantly (except
for the fontconfig parts...); the font no longer sets itself in a
cairo surface - font users do that; the font simply returns a
cairo_scaled_font_t.
Furthermore, font_clone() has now been simplified to basically just
refcount the scaled font. I.e. there's no need to run the full
constructor and lookup and instantiate the cairo scaled font again.