Commit graph

13 commits

Author SHA1 Message Date
Jaroslav Kysela
e165d3413e alsamixer: remove unused variable y in display_scroll_indicators()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-11 10:41:42 +01:00
braph
0657b2a559 alsamixer: small optimizations
textbox.c, mixer_display.c:
  - Replaced manual line drawing code `for (...) mvwaddch(...)` by the
    functions `mvwhline/mvwvline` provided by standard curses

card_select.c, proc_files.c:
  - Moved duplicate code in the create() functions to menu_widget_create()
    in menu_widget.c

card_select.c:
  - Removed redundant calls to sprintf()

device_name.c:
  - Combined multiple calls to form_opts_off()
  - Recognize ASCII DEL (127) as backspace

widget.c:
  - Uncommented code for setting a dummy key handler (all existing
    widgets do provide a key handling function)

Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-01 16:10:35 +02:00
braph
32dc22c2bf alsamixer: Use a struct for storing color attributes
This commit is a preparation for the configuration file parser.

The `int attr_*` variables have been moved into a separate struct.
Members of that struct are alphabetically ordered, so an attribute can
later be accessed by its name.

Added `int get_color_pair(short fg, short bg)` for returning or
creating a color pair number.

Added call to `use_default_colors()` for enabling access to the
terminal's default color (-1).

Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-01 16:10:35 +02:00
braph
ba1c5357a1 alsamixer: added mouse support
Mouse support has been added for mixer_widget.c, card_select.c and
proc_files.c.

In the mixer widget the mouse is handled as follows:
- After an element has been printed in mixer_display.c, a call to
  clickable_set() will store the coordinates of the drawn area plus the
  command enum that should be executed on click. An optional argument
  holds an index which points to the selected mixer control.
- on_mouse_click() searches for a matching rectangle, focuses the mixer
  control and returns the command enum.

In the menu widgets, the menu_driver() function handles mouse input.

Signed-off-by: Benjamin Abendroth <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-01 16:10:35 +02:00
Clemens Ladisch
f282607273 alsamixer: fix handling of removed controls
When we get a notification that an element has been removed, we have to
recreate our internal control representation to avoid accessing freed
memory.  (And the checking for SND_CTL_EVENT_MASK_REMOVE should actually
be done correctly while we're at it.)

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2012-10-19 12:16:33 +02:00
Takashi Iwai
3bea722b3b alsamixer: Fix 64bit issues
lrint() returns a long int.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-03 14:28:28 +02:00
Clemens Ladisch
34bb514b5f alsamixer: use cubic scale for volume bars
Instead of mapping the raw volume values linearly to the screen, use
a mapping where the bar height is proportional to the audible volume,
i.e., where the amplitude is the cube of the bar height.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2010-12-06 14:07:48 +01:00
Clemens Ladisch
c9b86f49a8 alsamixer: handle out-of-range volume values
Ensure that control volume values are in their allowed range; otherwise,
the displayed values could be outside the range 0..100 and mess up the
layout.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2010-02-22 09:42:03 +01:00
Clemens Ladisch
5a016b583b alsamixer: fix division by zero
The attempt to divide by max-min fails if a control has only one valid
value.  In this case, adjust the maximum so that the computation can
succeed; the control will look like 0%.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2010-02-19 17:07:20 +01:00
Clemens Ladisch
077467a87e alsamixer: fix display of inactive volume bar
Fix the volume bar color selection logic so that the current attribute
is used for inactive controls.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-06-19 08:40:00 +02:00
Clemens Ladisch
7a3e59cbc5 alsamixer: rename attr to ch
Rename the attr variable because it contains not only the character's
attributes but also the character itself.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-06-19 08:39:24 +02:00
Takashi Iwai
29a7dbc552 alsamixer - Tricolorize volume bars
A little of bit of Italian taste was missing...

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-18 14:42:28 +02:00
Clemens Ladisch
5b6b5fd14b alsamixer: show channel names for multichannel controls
For multichannel mixer controls, add the channel name to each screen
control.

Also make some other small changes.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-05-25 10:26:22 +02:00