]> skyeroc.xyz Git - dgamelaunch/commitdiff
Pass window size to watchers via inprogress file; show it on the list.
authorJilles Tjoelker <jilles@stack.nl>
Thu, 4 Mar 2004 13:58:03 +0000 (13:58 +0000)
committerJilles Tjoelker <jilles@stack.nl>
Thu, 4 Mar 2004 13:58:03 +0000 (13:58 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@265 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Changelog
TODO
dgamelaunch.c
dgamelaunch.h
dgl-common.c

index 7533ef880fdde3d48aee03fa26ce73e8ede5b78a..321f5c2dc0d21dcb76d103c870c3661077919a70 100644 (file)
--- 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 c5a8faf34688606cc2413efb95bbfc9a5d63ac4d..a744e3618c9eb6404dea678e4d30002a2737911e 100644 (file)
--- 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)
index c7be452059de9c3f779cdf31bba8371ffce30aea..21a033d991b510c9268d1c447752544397ba4b23 100644 (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);
index 75fe657d4e515c6d514fc7d4135f1e954d91f40f..799053142954e1a85c0b72c9fc0da2bbca1eb4ea 100644 (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
index af70c7038d14d686c8288369b6403056aed5f73e..95338c0cd5784addaa07260838761e34b5e87231 100644 (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++;
             }
         }