Code

screen: replaced get_cur_mode_id() with screen_is_visible()
authorMax Kellermann <max@duempel.org>
Thu, 25 Sep 2008 19:20:10 +0000 (21:20 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 25 Sep 2008 19:20:10 +0000 (21:20 +0200)
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.

src/screen.c
src/screen.h
src/screen_artist.c
src/screen_file.c
src/screen_lyrics.c
src/screen_play.c
src/screen_search.c

index cea637a8de9ea497c9d5642eeef85ab2f557fded..02df03b528df4a0a4231527c8210a1ab5019e777 100644 (file)
@@ -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
index 7a8b0edb3dba2dba06e13e128dc1b689a7156062..dc7e239ea838661bb1959a6153583838d259d8fc 100644 (file)
@@ -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
index 23a56d5b418b6d11edc6f2107ee49c67fbb9e493..71b168841dc73d8c18f82e5f86244ed4e025507b 100644 (file)
@@ -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();
 }
 
index 05e8ad29924441607e0ffe2935353373262a4955..24cd8afc747f40f3b78755ccb1eec91afb3306f0 100644 (file)
@@ -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();
 }
 
index 3c0393488fde736866ae6a669f20a8fbab42f23d..ec552ee3326d94117712d887561913d017bb689b 100644 (file)
@@ -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 */
index 8258e18aea96044a60833edb1ec4b9d3609d6a6b..555412905d8e83c10459effe2d00826dcaa02f90 100644 (file)
@@ -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);
 }
 
index 245eb5243c9c9bc9000895fb54dea15967585af7..b93aef01a12f067e0f8502fc21301855632aeb0e 100644 (file)
@@ -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();
 }