From b512802eb2babc879a109d16ce4a32b2fb1c22ef Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 27 Nov 2008 18:05:28 +0100 Subject: [PATCH] list_window: converted "flags" to one "bool" variable Currently, there is only one known list_window flag ("hide_cursor"). Replace the "flags" bit field with a boolean variable. If we run out of space some day, we can convert that to bool:1. --- src/list_window.c | 2 +- src/list_window.h | 5 ++--- src/screen_help.c | 2 +- src/screen_lyrics.c | 2 +- src/screen_play.c | 6 +++--- src/screen_search.c | 4 ++-- src/screen_song.c | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/list_window.c b/src/list_window.c index b12e8eb..ea4b3c2 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -166,7 +166,7 @@ list_window_paint(struct list_window *lw, { unsigned i; bool fill = options.wide_cursor; - bool show_cursor = !(lw->flags & LW_HIDE_CURSOR); + bool show_cursor = !lw->hide_cursor; if (show_cursor) { if (lw->selected < lw->start) diff --git a/src/list_window.h b/src/list_window.h index bcf3e32..8e9411a 100644 --- a/src/list_window.h +++ b/src/list_window.h @@ -13,8 +13,6 @@ #include #endif -#define LW_HIDE_CURSOR 0x01 - typedef const char *(*list_window_callback_fn_t)(unsigned index, bool *highlight, void *data); @@ -26,7 +24,8 @@ typedef struct list_window { unsigned start; unsigned selected; unsigned xoffset; - int flags; + + bool hide_cursor; } list_window_t; diff --git a/src/screen_help.c b/src/screen_help.c index 0cc15a3..c8a3d84 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -182,7 +182,7 @@ static void help_init(WINDOW *w, int cols, int rows) { lw = list_window_init(w, cols, rows); - lw->flags = LW_HIDE_CURSOR; + lw->hide_cursor = true; } static void diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index d54333d..e5635bd 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -245,7 +245,7 @@ lyrics_screen_init(WINDOW *w, int cols, int rows) { current.lines = g_ptr_array_new(); lw = list_window_init(w, cols, rows); - lw->flags = LW_HIDE_CURSOR; + lw->hide_cursor = true; } static void diff --git a/src/screen_play.c b/src/screen_play.c index 7ee0a9f..5acde45 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -396,7 +396,7 @@ timer_hide_cursor(gpointer data) /* hide the cursor when mpd is playing and the user is inactive */ if (c->status != NULL && c->status->state == MPD_STATUS_STATE_PLAY) { - lw->flags |= LW_HIDE_CURSOR; + lw->hide_cursor = true; playlist_repaint(); } else timer_hide_cursor_id = g_timeout_add(options.hide_cursor * 1000, @@ -414,7 +414,7 @@ play_open(mpdclient_t *c) assert(timer_hide_cursor_id == 0); if (options.hide_cursor > 0) { - lw->flags &= ~LW_HIDE_CURSOR; + lw->hide_cursor = false; timer_hide_cursor_id = g_timeout_add(options.hide_cursor * 1000, timer_hide_cursor, c); } @@ -530,7 +530,7 @@ handle_mouse_event(struct mpdclient *c) static bool play_cmd(mpdclient_t *c, command_t cmd) { - lw->flags &= ~LW_HIDE_CURSOR; + lw->hide_cursor = false; if (options.hide_cursor > 0) { if (timer_hide_cursor_id != 0) diff --git a/src/screen_search.c b/src/screen_search.c index 3c0a18b..235eeee 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -382,10 +382,10 @@ static void paint(void) { if (browser.filelist) { - browser.lw->flags = 0; + browser.lw->hide_cursor = false; list_window_paint(browser.lw, browser_lw_callback, browser.filelist); } else { - browser.lw->flags = LW_HIDE_CURSOR; + browser.lw->hide_cursor = true; list_window_paint(browser.lw, lw_search_help_callback, NULL); } } diff --git a/src/screen_song.c b/src/screen_song.c index 2c73ea6..4a8f716 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -78,7 +78,7 @@ screen_song_init(WINDOW *w, int cols, int rows) { current.lines = g_ptr_array_new(); lw = list_window_init(w, cols, rows); - lw->flags = LW_HIDE_CURSOR; + lw->hide_cursor = true; } static void -- 2.30.2