From ebc0c56b87e71b4a0ee3a6bfdeaff35f053a3e80 Mon Sep 17 00:00:00 2001 From: Jeffrey Middleton Date: Thu, 5 Mar 2009 17:06:42 -0600 Subject: [PATCH] screen: Added screen swap command Screen swap command toggles to the previous (most recently used) screen. Particularly useful to return from lyrics/info screen. --- src/command.c | 2 ++ src/command.h | 1 + src/screen.c | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/src/command.c b/src/command.c index 809f449..3c8a405 100644 --- a/src/command.c +++ b/src/command.c @@ -193,6 +193,8 @@ static command_definition_t cmds[] = { N_("Next screen") }, { { STAB, 0, 0 }, 0, CMD_SCREEN_PREVIOUS, "screen-prev", N_("Previous screen") }, + { { '~', 0, 0 }, 0, CMD_SCREEN_SWAP, "screen-swap", + N_("Swap to most recent screen") }, /* find */ diff --git a/src/command.h b/src/command.h index 3adc3d2..a714582 100644 --- a/src/command.h +++ b/src/command.h @@ -82,6 +82,7 @@ typedef enum { CMD_SCREEN_UPDATE, CMD_SCREEN_PREVIOUS, CMD_SCREEN_NEXT, + CMD_SCREEN_SWAP, CMD_SCREEN_PLAY, CMD_SCREEN_FILE, CMD_SCREEN_ARTIST, diff --git a/src/screen.c b/src/screen.c index 924cf4b..b53fcf4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -60,6 +60,7 @@ static gboolean welcome = TRUE; struct screen screen; static const struct screen_functions *mode_fn = &screen_playlist; +static const struct screen_functions *mode_fn_prev = &screen_playlist; static int seek_id = -1; static int seek_target_time = 0; @@ -77,6 +78,8 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c) if (sf == mode_fn) return; + mode_fn_prev = mode_fn; + /* close the old mode */ if (mode_fn->close != NULL) mode_fn->close(); @@ -857,7 +860,11 @@ screen_cmd(mpdclient_t *c, command_t cmd) case CMD_SCREEN_OUTPUTS: screen_switch(&screen_outputs, c); break; + case CMD_SCREEN_SWAP: + screen_switch(mode_fn_prev, c); + break; #endif + default: break; } -- 2.30.2