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
This commit is contained in:
Jilles Tjoelker 2004-03-04 13:58:03 +00:00
parent 2f258f13c7
commit e33b7fabd6
5 changed files with 41 additions and 7 deletions

View File

@ -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.

3
TODO
View File

@ -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)

View File

@ -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);

View File

@ -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

View File

@ -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++;
}
}