From: Max Kellermann Date: Thu, 25 Sep 2008 19:20:10 +0000 (+0200) Subject: screen: replaced get_cur_mode_id() with screen_is_visible() X-Git-Tag: v0.12_alpha1~146 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3809e2f13bb6642d3a874c24df7d854aa0aea8b5;p=ncmpc.git screen: replaced get_cur_mode_id() with screen_is_visible() Screen code shouldn't know anything about the screen ids (which will be eliminated completely later). Instead of comparing ids, compare the screen_functions pointer. --- diff --git a/src/screen.c b/src/screen.c index cea637a..02df03b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -47,9 +47,10 @@ static const struct screen_functions *mode_fn = &screen_playlist; static int seek_id = -1; static int seek_target_time = 0; -gint get_cur_mode_id(void) +gboolean +screen_is_visible(const struct screen_functions *sf) { - return screen_get_id_by_index(screen.mode); + return sf == mode_fn; } static void diff --git a/src/screen.h b/src/screen.h index 7a8b0ed..dc7e239 100644 --- a/src/screen.h +++ b/src/screen.h @@ -94,8 +94,9 @@ void screen_idle(mpdclient_t *c); void screen_cmd(mpdclient_t *c, command_t cmd); gint screen_get_id(const char *name); +gboolean +screen_is_visible(const struct screen_functions *sf); -gint get_cur_mode_id(void); int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row); #endif diff --git a/src/screen_artist.c b/src/screen_artist.c index 23a56d5..71b1688 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -90,7 +90,7 @@ artist_repaint(void) static void artist_repaint_if_active(void) { - if (get_cur_mode_id() == 2) /* XXX don't use the literal number */ + if (screen_is_visible(&screen_artist)) artist_repaint(); } diff --git a/src/screen_file.c b/src/screen_file.c index 05e8ad2..24cd8af 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -49,7 +49,7 @@ file_repaint(void) static void file_repaint_if_active(void) { - if (get_cur_mode_id() == 1) /* XXX don't use the literal number */ + if (screen_is_visible(&screen_browse)) file_repaint(); } diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 3c03934..ec552ee 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -99,7 +99,7 @@ lyrics_repaint(void) static void lyrics_repaint_if_active(void) { - if (get_cur_mode_id() == 104) { /* XXX don't use the literal number */ + if (screen_is_visible(&screen_lyrics)) { lyrics_repaint(); /* XXX repaint the screen title */ diff --git a/src/screen_play.c b/src/screen_play.c index 8258e18..5554129 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -64,7 +64,7 @@ playlist_repaint(struct mpdclient *c) static void playlist_repaint_if_active(struct mpdclient *c) { - if (get_cur_mode_id() == 0) /* XXX don't use the literal number */ + if (screen_is_visible(&screen_playlist)) playlist_repaint(c); } diff --git a/src/screen_search.c b/src/screen_search.c index 245eb52..b93aef0 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -148,7 +148,7 @@ search_repaint(void) static void search_repaint_if_active(void) { - if (get_cur_mode_id() == 103) /* XXX don't use the literal number */ + if (screen_is_visible(&screen_search)) search_repaint(); }