aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/screen.c15
-rw-r--r--src/screen.h2
-rw-r--r--src/screen_list.c22
-rw-r--r--src/screen_list.h5
4 files changed, 14 insertions, 30 deletions
diff --git a/src/screen.c b/src/screen.c
index 2124a2b74..9c7ca50a5 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -56,22 +56,17 @@ screen_is_visible(const struct screen_functions *sf)
static void
switch_screen_mode(const struct screen_functions *sf, mpdclient_t *c)
{
- gint new_mode;
+ assert(sf != NULL);
if (sf == mode_fn)
return;
- new_mode = lookup_mode(sf);
- if (new_mode < 0)
- return;
-
/* close the old mode */
if (mode_fn->close != NULL)
mode_fn->close();
/* get functions for the new mode */
mode_fn = sf;
- screen.mode = new_mode;
screen.painted = 0;
/* open the new mode */
@@ -96,9 +91,10 @@ screen_next_mode(mpdclient_t *c, int offset)
{
int max = g_strv_length(options.screen_list);
int current, next;
+ const struct screen_functions *sf;
/* find current screen */
- current = find_configured_screen(screen_get_name(screen.mode));
+ current = find_configured_screen(screen_get_name(mode_fn));
next = current + offset;
if (next<0)
next = max-1;
@@ -106,7 +102,9 @@ screen_next_mode(mpdclient_t *c, int offset)
next = 0;
D("current mode: %d:%d next:%d\n", current, max, next);
- switch_screen_mode(screen_lookup_name(options.screen_list[next]), c);
+ sf = screen_lookup_name(options.screen_list[next]);
+ if (sf != NULL)
+ switch_screen_mode(sf, c);
}
static void
@@ -447,7 +445,6 @@ screen_init(mpdclient_t *c)
exit(EXIT_FAILURE);
}
- screen.mode = 0;
screen.cols = COLS;
screen.rows = LINES;
diff --git a/src/screen.h b/src/screen.h
index dc7e239ea..1eac4d682 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -32,8 +32,6 @@ typedef struct screen {
unsigned cols, rows;
- int mode;
-
char *buf;
size_t buf_size;
diff --git a/src/screen_list.c b/src/screen_list.c
index fddeeb025..31e8adaf1 100644
--- a/src/screen_list.c
+++ b/src/screen_list.c
@@ -86,11 +86,15 @@ screen_list_resize(unsigned cols, unsigned rows)
}
const char *
-screen_get_name(unsigned i)
+screen_get_name(const struct screen_functions *sf)
{
- assert(i < NUM_SCREENS);
+ unsigned i;
+
+ for (i = 0; i < NUM_SCREENS; ++i)
+ if (screens[i].functions == sf)
+ return screens[i].name;
- return screens[i].name;
+ return NULL;
}
const struct screen_functions *
@@ -104,15 +108,3 @@ screen_lookup_name(const char *name)
return NULL;
}
-
-int
-lookup_mode(const struct screen_functions *sf)
-{
- unsigned i;
-
- for (i = 0; i < NUM_SCREENS; ++i)
- if (screens[i].functions == sf)
- return i;
-
- return -1;
-}
diff --git a/src/screen_list.h b/src/screen_list.h
index 583c225b0..1293b74d9 100644
--- a/src/screen_list.h
+++ b/src/screen_list.h
@@ -50,7 +50,7 @@ void
screen_list_resize(unsigned cols, unsigned rows);
const char *
-screen_get_name(unsigned i);
+screen_get_name(const struct screen_functions *sf);
const struct screen_functions *
screen_lookup_name(const char *name);
@@ -58,7 +58,4 @@ screen_lookup_name(const char *name);
int
screen_get_id(const char *name);
-int
-lookup_mode(const struct screen_functions *sf);
-
#endif