From e33b7fabd6718aae78bdd0daac8cf152ca794b58 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 4 Mar 2004 13:58:03 +0000 Subject: [PATCH] Pass window size to watchers via inprogress file; show it on the list. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@265 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- Changelog | 4 ++++ TODO | 3 +++ dgamelaunch.c | 10 ++++++---- dgamelaunch.h | 1 + dgl-common.c | 30 +++++++++++++++++++++++++++--- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 7533ef8..321f5c2 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ 1.4.4 (????/??/??) * Show total number of games in progress below the list, useful if there are more than fits on the screen. + * Use client-supplied window size again; try to detect broken + clients and force them to 80x24. + * Pass window size to watchers via inprogress file; show it on the + list. 1.4.3 (2004/02/28) * Make ttyplay use the 'strip' value it remembered from last view. diff --git a/TODO b/TODO index c5a8faf..a744e36 100644 --- a/TODO +++ b/TODO @@ -3,3 +3,6 @@ - Localization of variables, code clean up - Use /var/run/nologin and/or dgl-specific nologin file + +- Honor window size changes (currently the player has to relogin if window + size changes) diff --git a/dgamelaunch.c b/dgamelaunch.c index c7be452..21a033d 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -165,12 +165,13 @@ gen_ttyrec_filename () char* gen_inprogress_lock (pid_t pid, char* ttyrec_filename) { - char *lockfile = NULL, pidbuf[16]; + char *lockfile = NULL, filebuf[80]; int fd; size_t len; struct flock fl = { 0 }; - snprintf (pidbuf, 16, "%d", pid); + snprintf (filebuf, sizeof(filebuf), "%d\n%d\n%d\n", + pid, win.ws_row, win.ws_col); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; @@ -187,7 +188,7 @@ gen_inprogress_lock (pid_t pid, char* ttyrec_filename) if (fcntl (fd, F_SETLKW, &fl) == -1) graceful_exit (68); - write (fd, pidbuf, strlen (pidbuf)); + write (fd, filebuf, strlen (filebuf)); return lockfile; } @@ -330,8 +331,9 @@ inprogressmenu () if (i + offset >= len) break; - mvprintw (7 + i, 1, "%c) %-15s %s %s (%ldm %lds idle)", + mvprintw (7 + i, 1, "%c) %-15s (%3dx%3d) %s %s (%ldm %lds idle)", i + 97, games[i + offset]->name, + games[i + offset]->ws_col, games[i + offset]->ws_row, games[i + offset]->date, games[i + offset]->time, (time (&ctime) - games[i + offset]->idle_time) / 60, (time (&ctime) - games[i + offset]->idle_time) % 60); diff --git a/dgamelaunch.h b/dgamelaunch.h index 75fe657..7990531 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -39,6 +39,7 @@ struct dg_game char *date; char *time; time_t idle_time; + int ws_row, ws_col; /* Window size */ }; struct dg_config diff --git a/dgl-common.c b/dgl-common.c index af70c70..95338c0 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -41,12 +41,12 @@ char *chosen_name; struct dg_game ** populate_games (int *l) { - int fd, len; + int fd, len, n; DIR *pdir; struct dirent *pdirent; struct stat pstat; - char fullname[130], ttyrecname[130]; - char *replacestr, *dir; + char fullname[130], ttyrecname[130], pidws[80]; + char *replacestr, *dir, *p; struct dg_game **games = NULL; struct flock fl = { 0 }; size_t slen; @@ -109,6 +109,30 @@ populate_games (int *l) games[len]->idle_time = pstat.st_mtime; + n = read(fd, pidws, sizeof(pidws) - 1); + if (n > 0) + { + pidws[n] = '\0'; + p = pidws; + } + else + p = ""; + while (*p != '\0' && *p != '\n') + p++; + if (*p != '\0') + p++; + games[len]->ws_row = atoi(p); + while (*p != '\0' && *p != '\n') + p++; + if (*p != '\0') + p++; + games[len]->ws_col = atoi(p); + if (games[len]->ws_row < 4 || games[len]->ws_col < 4) + { + games[len]->ws_row = 24; + games[len]->ws_col = 80; + } + len++; } } -- 2.47.3