dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 5870e0bdc31952267519a8e09be59fb94fa39d82
parent 9c3192a0201098ddbe08e278d61f5d97d165d2d6
Author: Frank LENORMAND <lenormf@gmail.com>
Date:   Sat,  1 Oct 2016 16:28:56 +0300

Allow focusing windows through the command FIFO

This commit adds a `focus` command to the list of supported commands
available through the external FIFO, which switches focus to the window
whose id is equal to the one passed as parameter.

Diffstat:
config.def.h | 1+
dvtm.c | 17+++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -189,6 +189,7 @@ static Button buttons[] = { static Cmd commands[] = { { "create", { create, { NULL } } }, + { "focus", { focusid, { NULL } } }, }; /* gets executed when dvtm is started */ diff --git a/dvtm.c b/dvtm.c @@ -179,6 +179,7 @@ typedef struct { static void create(const char *args[]); static void copymode(const char *args[]); static void focusn(const char *args[]); +static void focusid(const char *args[]); static void focusnext(const char *args[]); static void focusnextnm(const char *args[]); static void focusprev(const char *args[]); @@ -1126,6 +1127,22 @@ focusn(const char *args[]) { } static void +focusid(const char *args[]) { + if (!args[0]) + return; + + const int win_id = atoi(args[0]); + for (Client *c = nextvisible(clients); c; c = nextvisible(c->next)) { + if (c->id == win_id) { + focus(c); + if (c->minimized) + toggleminimize(NULL); + return; + } + } +} + +static void focusnext(const char *args[]) { Client *c; if (!sel)