diff options
author | Takashi Iwai <tiwai@suse.de> | 2004-12-15 15:15:56 +0000 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2004-12-15 15:15:56 +0000 |
commit | 30b608001f99c4f00961516ee29b679035e3ad3c (patch) | |
tree | 4bc5f884ac3e3fd6ea65729445a49164e212ddd3 /alsamixer | |
parent | 063ff485e2516dc4f3f5a82c45c3376a280a88b9 (diff) | |
download | alsa-utils-30b608001f99c4f00961516ee29b679035e3ad3c.tar.gz |
Reinitialize the size calculation at view change
The volume bar and space sizes are recalculated at each time when
the view mode is changed. This will fix the problem when the view
with fewer volumes is switched to the view with more volumes.
Diffstat (limited to 'alsamixer')
-rw-r--r-- | alsamixer/alsamixer.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 8344d6e..c23651b 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -1458,6 +1458,30 @@ mixer_init (void) strcpy(mixer_device_name, snd_ctl_card_info_get_mixername(hw_info)); } +/* init mixer screen + */ +static void +recalc_screen_size (void) +{ + getmaxyx (mixer_window, mixer_max_y, mixer_max_x); + if (mixer_minimize) + { + mixer_max_x = MIXER_MIN_X; + mixer_max_y = MIXER_MIN_Y; + } + mixer_ofs_x = 2 /* extra begin padding: */ + 1; + + /* required allocations */ + mixer_n_vis_elems = (mixer_max_x - mixer_ofs_x * 2 + 1) / 9; + mixer_n_vis_elems = CLAMP (mixer_n_vis_elems, 1, mixer_n_view_elems); + mixer_extra_space = mixer_max_x - mixer_ofs_x * 2 + 1 - mixer_n_vis_elems * 9; + mixer_extra_space = MAX (0, mixer_extra_space / (mixer_n_vis_elems + 1)); + if (MIXER_TEXT_Y + 10 < mixer_max_y) + mixer_cbar_height = 10 + MAX (0, mixer_max_y - MIXER_TEXT_Y - 10 ) / 2; + else + mixer_cbar_height = MAX (1, mixer_max_y - MIXER_TEXT_Y); +} + static void mixer_reinit (void) { @@ -1588,6 +1612,7 @@ __again: } mixer_n_view_elems = elem_index; + recalc_screen_size(); mixer_focus_elem = 0; if (focus_type >= 0) { for (elem_index = 0; elem_index < mixer_n_view_elems; elem_index++) { @@ -1630,25 +1655,7 @@ mixer_init_window (void) keypad (mixer_window, TRUE); GETCH_BLOCK (1); - /* init mixer screen - */ - getmaxyx (mixer_window, mixer_max_y, mixer_max_x); - if (mixer_minimize) - { - mixer_max_x = MIXER_MIN_X; - mixer_max_y = MIXER_MIN_Y; - } - mixer_ofs_x = 2 /* extra begin padding: */ + 1; - - /* required allocations */ - mixer_n_vis_elems = (mixer_max_x - mixer_ofs_x * 2 + 1) / 9; - mixer_n_vis_elems = CLAMP (mixer_n_vis_elems, 1, mixer_n_view_elems); - mixer_extra_space = mixer_max_x - mixer_ofs_x * 2 + 1 - mixer_n_vis_elems * 9; - mixer_extra_space = MAX (0, mixer_extra_space / (mixer_n_vis_elems + 1)); - if (MIXER_TEXT_Y + 10 < mixer_max_y) - mixer_cbar_height = 10 + MAX (0, mixer_max_y - MIXER_TEXT_Y - 10 ) / 2; - else - mixer_cbar_height = MAX (1, mixer_max_y - MIXER_TEXT_Y); + recalc_screen_size(); mixer_clear (TRUE); } |