summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 758546d)
raw | patch | inline | side by side (parent: 758546d)
author | Max Kellermann <max.kellermann@gmail.com> | |
Mon, 20 Mar 2017 19:46:42 +0000 (20:46 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Mon, 20 Mar 2017 19:46:42 +0000 (20:46 +0100) |
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/src/screen.c b/src/screen.c
index 0d242de017fe6d1d34110a74250a664ef92183cc..a08cf595dab01ad5c1616aeff53b2ffa8b362f52 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
/* screens */
-struct screen screen;
-static const struct screen_functions *mode_fn = &screen_queue;
-static const struct screen_functions *mode_fn_prev = &screen_queue;
+struct screen screen = {
+ .current_page = &screen_queue,
+};
-gboolean
-screen_is_visible(const struct screen_functions *sf)
-{
- return sf == mode_fn;
-}
+static const struct screen_functions *mode_fn_prev = &screen_queue;
void
screen_switch(const struct screen_functions *sf, struct mpdclient *c)
{
assert(sf != NULL);
- if (sf == mode_fn)
+ if (sf == screen.current_page)
return;
- mode_fn_prev = mode_fn;
+ mode_fn_prev = screen.current_page;
/* close the old mode */
- if (mode_fn->close != NULL)
- mode_fn->close();
+ if (screen.current_page->close != NULL)
+ screen.current_page->close();
/* get functions for the new mode */
- mode_fn = sf;
+ screen.current_page = sf;
/* open the new mode */
- if (mode_fn->open != NULL)
- mode_fn->open(c);
+ if (sf->open != NULL)
+ sf->open(c);
screen_paint(c, true);
}
int max = g_strv_length(options.screen_list);
/* find current screen */
- int current = find_configured_screen(screen_get_name(mode_fn));
+ int current = find_configured_screen(screen_get_name(screen.current_page));
int next = current + offset;
if (next<0)
next = max-1;
#ifndef NCMPC_MINI
screen.welcome_source_id == 0 &&
#endif
- mode_fn->get_title != NULL
- ? mode_fn->get_title(screen.buf, screen.buf_size)
+ screen.current_page->get_title != NULL
+ ? screen.current_page->get_title(screen.buf, screen.buf_size)
: "";
assert(title != NULL);
void
screen_exit(void)
{
- if (mode_fn->close != NULL)
- mode_fn->close();
+ if (screen.current_page->close != NULL)
+ screen.current_page->close();
screen_list_exit();
screen_list_init(screen.main_window.w,
screen.main_window.cols, screen.main_window.rows);
- if (mode_fn->open != NULL)
- mode_fn->open(c);
+ if (screen.current_page->open != NULL)
+ screen.current_page->open(c);
}
void
if (main_dirty) {
wclear(screen.main_window.w);
- if (mode_fn->paint != NULL)
- mode_fn->paint();
+ if (screen.current_page->paint != NULL)
+ screen.current_page->paint();
}
/* move the cursor to the origin */
#endif
/* update the main window */
- if (mode_fn->update != NULL)
- mode_fn->update(c);
+ if (screen.current_page->update != NULL)
+ screen.current_page->update(c);
screen_paint(c, false);
}
}
#endif
- if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd))
+ if (screen.current_page->cmd != NULL &&
+ screen.current_page->cmd(c, cmd))
return;
if (handle_player_command(c, cmd))
diff --git a/src/screen.h b/src/screen.h
index c546e281b1b91183b3dde806a11e49e7bec6eafc..7c2d2140da2c26c1e58953f57fdfb7426680b7a5 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
#include <glib.h>
+#include <stdbool.h>
+
struct mpdclient;
struct screen_functions;
struct progress_bar progress_bar;
struct status_bar status_bar;
+ const struct screen_functions *current_page;
+
char *buf;
size_t buf_size;
void
screen_swap(struct mpdclient *c, const struct mpd_song *song);
-gboolean
-screen_is_visible(const struct screen_functions *sf);
+static inline bool
+screen_is_visible(const struct screen_functions *sf)
+{
+ return sf == screen.current_page;
+}
int
screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row);