summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-18 16:41:32 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-18 16:48:17 +0100
commitcc3b72eaf8fd1a88cb5b26f2604a966673033902 (patch)
treeecbd586a299cb708a41d52553912831994fdfdd9 /src
parent27675c45d74167b08446e4d36425a1738c8e1609 (diff)
downloadpa-sink-ctl-cc3b72eaf8fd1a88cb5b26f2604a966673033902.tar.gz
pa-sink-ctl-cc3b72eaf8fd1a88cb5b26f2604a966673033902.tar.bz2
pa-sink-ctl-cc3b72eaf8fd1a88cb5b26f2604a966673033902.zip
interface: Stop keeping track of cursor position ourself
Diffstat (limited to 'src')
-rw-r--r--src/interface.c40
-rw-r--r--src/pa-sink-ctl.h1
2 files changed, 20 insertions, 21 deletions
diff --git a/src/interface.c b/src/interface.c
index fe3dbc3..eda6535 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -113,22 +113,21 @@ interface_resize(gpointer data)
static void
print_volume(struct context *ctx, struct vol_ctl *ctl)
{
- gint x = 2 /* left */ + 2 /* index num width */ + 1 /* space */ +
- 1 /* space */ + ctx->max_name_len;
+ gint x, y, volume_bar_len, vol;
+ getyx(ctx->menu_win, y, x);
/* mute button + brackets + space */
- int volume_bar_len = getmaxx(ctx->menu_win) - x - 7;
- gint vol = (gint) (volume_bar_len * ctl->vol / PA_VOLUME_NORM);
+ volume_bar_len = getmaxx(ctx->menu_win) - x - 8;
+ vol = (gint) (volume_bar_len * ctl->vol / PA_VOLUME_NORM);
- mvwprintw(ctx->menu_win, ctx->y, x - 1, " [%c]", ctl->mute ? 'M' : ' ');
- x += 4;
+ wprintw(ctx->menu_win, " [%c]", ctl->mute ? 'M' : ' ');
- mvwprintw(ctx->menu_win, ctx->y, x - 1 , "[");
+ wprintw(ctx->menu_win, "[");
for (gint i = 0; i < vol; ++i)
- mvwprintw(ctx->menu_win, ctx->y, x + i, "=");
+ wprintw(ctx->menu_win, "=");
for (gint i = vol; i < volume_bar_len; ++i)
- mvwprintw(ctx->menu_win, ctx->y, x + i, " ");
- mvwprintw(ctx->menu_win, ctx->y, x + volume_bar_len, "]");
+ wprintw(ctx->menu_win, " ");
+ wprintw(ctx->menu_win, "]");
}
static void
@@ -136,22 +135,23 @@ print_vol_ctl(gpointer data, gpointer user_data)
{
struct vol_ctl *ctl = data;
struct context *ctx = user_data;
- gint x = 2;
+ gint x, y;
gboolean selected = (ctl == interface_get_current_ctl(ctx, NULL));
+ getyx(ctx->menu_win, y, x);
if (selected)
wattron(ctx->menu_win, A_REVERSE);
- if (!ctl->hide_index) {
- mvwprintw(ctx->menu_win, ctx->y, x, "%2u ", ctl->index);
- x += 3;
- }
- mvwprintw(ctx->menu_win, ctx->y, x, "%*s%-*s",
- ctl->indent + (ctl->hide_index ? 2+1 : 0), "",
- ctx->max_name_len - ctl->indent, ctl->name);
+
+ if (!ctl->hide_index)
+ wprintw(ctx->menu_win, "%2u ", ctl->index);
+ wprintw(ctx->menu_win, "%*s%-*s",
+ ctl->indent + (ctl->hide_index ? 2+1 : 0), "",
+ ctx->max_name_len - ctl->indent, ctl->name);
+
if (selected)
wattroff(ctx->menu_win, A_REVERSE);
print_volume(ctx, ctl);
- ctx->y++;
+ wmove(ctx->menu_win, y+1, x);
if (ctl->childs_foreach)
ctl->childs_foreach(ctl, print_vol_ctl, ctx);
@@ -178,7 +178,7 @@ interface_redraw(struct context *ctx)
werase(ctx->menu_win);
box(ctx->menu_win, 0, 0);
- ctx->y = 2; /* top border + 1 empty line */
+ wmove(ctx->menu_win, 2, 2); /* set initial cursor offset */
ctx->max_name_len = 0;
g_list_foreach(ctx->sink_list, max_name_len_helper, ctx);
diff --git a/src/pa-sink-ctl.h b/src/pa-sink-ctl.h
index 01fd3e8..97801d4 100644
--- a/src/pa-sink-ctl.h
+++ b/src/pa-sink-ctl.h
@@ -33,7 +33,6 @@ struct context {
WINDOW *menu_win;
WINDOW *msg_win;
- gint y;
guint resize_source_id;
#ifdef HAVE_SIGNALFD