Commit graph

33 commits

Author SHA1 Message Date
Daniel Eklöf
d6e7710a7e
particle: on-click: tilde expansion
We now do tilde expansion of the *first* argument in on-click
handlers.

That is:

  ~/bin/foobar.sh ~/arg1

is expanded to

  $HOME/bin/foobar.sh ~/arg1

(meaning, the handler will most likely *not* do what you’d expect)

Related to #307
2023-07-11 10:31:40 +02:00
Peter Rice
6ed576c719
particle/on-click: support next/previous buttons 2022-10-04 21:14:29 +02:00
Daniel Eklöf
fd014dc33b
Don’t loop 65536 FDs, trying to close them, when fork+exec:ing
All FDs should now have the CLOEXEC flag set, and thus there’s no
longer needed to manually loop “all” possible FDs and (trying to)
close them.

Note: the alsa module (alsalib, actually) is “racy” - while booting
up, it temporarily opens the asoundrc file without CLOEXEC. If
e.g. the script module starts its script inside this window, it’ll
have a leaked FD. Not much we can do about it though :/

Closes #169
2022-03-29 18:23:55 +02:00
Daniel Eklöf
ffccabbb13
config: add inheritable option “font-shaping”
This patch adds an inheritable option, “font-shaping”, that controls
whether a particle that renders text should enable font-shaping or
not.

The option works similar to the ‘font’ option: one can set it at the
top-level, and it gets inherited down through all modules and to their
particles.

Or, you can set it on a module and it gets inherited to all its
particles, but not to other modules’ particles.

Finally, you can set it on individual particles, in which case it only
applies to them (or “child” particles).

When font-shaping is enabled (the default), the string particle shapes
full text runs using the fcft_rasterize_text_run_utf32() API. In fcft,
this results in HarfBuzz being used to shape the string.

When disabled, the string particle instead uses the simpler
fcft_rasterize_char_utf32() API, which rasterizes individual
characters.

This gives user greater control over the font rendering. One example
is bitmap fonts, which HarfBuzz often doesn’t get right.

Closes #159
2022-02-23 18:43:13 +01:00
Baptiste Daroussin
2e6847077e signal: add the signal header needed for the signal functions 2021-10-01 10:52:00 +02:00
Daniel Eklöf
7d3851046e
log: pull in log.{c,h} from foot 2021-08-15 11:41:12 +02:00
Daniel Eklöf
4e2c4e1e3a
particle: on-mouse: close the read pipe after reading from it, in parent 2021-07-01 17:15:53 +02:00
Daniel Eklöf
13ef977eeb
particle: on-mouse: don’t close our own pipe FD before the execvp() 2021-07-01 17:15:53 +02:00
Daniel Eklöf
34d832cd22
config+particle: add support for mouse wheel up/down 2021-07-01 17:15:53 +02:00
Daniel Eklöf
c79ffbe057
Add support binding on-click handlers to other buttons than LEFT
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>
2021-07-01 17:15:53 +02:00
Daniel Eklöf
af163d3f77
exposable: log button name in debug log 2021-07-01 17:15:53 +02:00
Daniel Eklöf
dd724d1bc2
exposable: add ‘btn’ argument to on_mouse() 2021-07-01 17:15:52 +02:00
Daniel Eklöf
d0360f2de1
particle: reset signals and signal mask when executing an on-click handler 2020-11-25 20:41:09 +01:00
Daniel Eklöf
03a5c8746f
fcft: adjust to fcft-2.0 API changes
* font_*() -> fcft_*()
* struct font -> struct fcft_font
* struct glyph -> struct fcft_glyph
* enum subpixel_order -> enum fcft_subpixel
2020-04-22 11:50:29 +02:00
Daniel Eklöf
288428ca22
particle: add missing argument to debug log 2019-09-23 18:34:23 +02:00
Daniel Eklöf
384e9d0849
particle: add on-click handler to debug log message 2019-09-23 18:33:57 +02:00
Daniel Eklöf
c11fee4ce3
cairo: replace cairo with pixman in decos, particles and modules
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.
2019-09-22 01:56:58 +02:00
Daniel Eklöf
48da200924 particle: ignore write() return value
We're in a subprocess about to exit anyway, with stdout/stderr
typically closed. We can't do anything but ignore write() failures.

Fixes building with -D_FORTIFY_SOURCE=2
2019-05-04 11:26:58 +02:00
Daniel Eklöf
bec50782b8 particle: improve error handling in on-click handler
* Make sure to _exit() in all forked code paths that doesn't end in a
  successful exec()
* Report errno to parent process on failure so that we can log it

The second point is implemented by a) manually double forking instead
of calling daemon(), and b) using a pipe in the inner fork to be able
to wait for the child process to either succeed in its exec() call, or
write errno to the pipe on failure.

This fixes hangs and crashes when e.g. the binary we're trying to
execute doesn't exist.
2019-04-23 19:02:21 +02:00
Daniel Eklöf
2123956b14 particle: refactor command line tokenization 2019-03-07 21:31:30 +01:00
Daniel Eklöf
6bba9200cf particles: use calloc() instead of malloc()
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.
2019-02-09 11:05:12 +01:00
Daniel Eklöf
ae5029826b cmake: break out bar stuff to separate CMakeLists.txt 2019-02-07 12:06:16 +01:00
Daniel Eklöf
7776135454 particles: caller of from_conf() must provide base particle instance 2019-01-13 13:25:14 +01:00
Daniel Eklöf
22507ae26c particle: add utility function to render a particle's decoration 2018-12-29 21:00:03 +01:00
Daniel Eklöf
ed86061532 particle: refactor 2018-12-29 17:04:39 +01:00
Daniel Eklöf
620017860e particle: handle ON_MOUSE_CLICK
If a particle has an on-click handler, execute it when we receive an
ON_MOUSE_CLICK event.

This is done by first tokenizing the command string. We currently
handle one level of quotes, but no escape characters.

Then, fork(). Main process waits for child to finish. Child daemonizes
and then execvp() the tokenized argument vector.
2018-12-29 16:24:22 +01:00
Daniel Eklöf
cecab625ac particle: implement a default on_mouse handler
Which changes the cursor to a hand when there's a non-NULL on-click
handler.
2018-12-29 14:40:45 +01:00
Daniel Eklöf
5164d1d6ea particle: add an 'on_click_template' to base constructor.
This is intended to be a format-like string, with the possibility to
use tag formatters.

The expanded string will later be passed to the system() call.
2018-12-29 14:36:18 +01:00
Daniel Eklöf
e8d8bf70d3 exposable: add a "common" constructor and default destructor 2018-12-29 12:51:31 +01:00
Daniel Eklöf
4d173326e4 particle: remove 'parent' (it wasn't used anyway) 2018-12-29 12:49:00 +01:00
Daniel Eklöf
1427d6a98b particle: provide a default destroy() function
This allows us to destroy the associated decoration.
2018-12-26 21:34:19 +01:00
Daniel Eklöf
f65a18b655 particle: initialize 'deco' member to NULL
Fixes valgrind warnings about uninitialized variable. This happened
for every particle that did *not* have a decoration.
2018-12-26 21:33:35 +01:00
Daniel Eklöf
8bf8a398b9 initial commit: wip 2018-11-17 11:30:33 +01:00