Changeset d39f68c


Ignore:
Timestamp:
May 29, 2010, 1:14:57 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
ae11191
Parents:
d106110
git-author:
David Benjamin <davidben@mit.edu> (05/27/10 16:33:36)
git-committer:
David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
Message:
Compute the terminal size in the screen's size callback

We do some roundabout thing with clearing g->lines and g->cols to
preserve the old logic of allowing us to force a value. (Not that it was
every used. We also apparently flipped x and y.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r4e33cb2 rd39f68c  
    475475 * fail.
    476476 */
    477 static void _owl_global_get_size(int *lines, int *cols) {
     477void owl_global_get_terminal_size(int *lines, int *cols) {
    478478  struct winsize size;
    479479  /* get the new size */
     
    492492}
    493493
    494 void owl_global_resize(owl_global *g, int x, int y) {
     494void owl_global_resize(owl_global *g, int lines, int cols) {
    495495  /* resize the screen.  If x or y is 0 use the terminal size */
    496496  if (!g->resizepending) return;
    497497  g->resizepending = 0;
    498498
    499   _owl_global_get_size(&g->lines, &g->cols);
    500   if (x != 0) {
    501     g->lines = x;
    502   }
    503   if (y != 0) {
    504     g->cols = y;
    505   }
    506 
    507   owl_window_resize(owl_window_get_screen(), g->lines, g->cols);
     499  g->lines = lines;
     500  g->cols = cols;
     501  owl_window_recompute_position(owl_window_get_screen());
    508502
    509503  owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols);
  • window.c

    rd106110 rd39f68c  
    5454}
    5555
     56static void _screen_calculate_size(owl_window *screen, void *user_data)
     57{
     58  owl_global *g = user_data;
     59  int lines, cols;
     60  owl_global_get_terminal_size(&lines, &cols);
     61  if (!g->lines) g->lines = lines;
     62  if (!g->cols) g->cols = cols;
     63  owl_window_resize(screen, g->lines, g->cols);
     64}
     65
    5666owl_window *owl_window_get_screen(void)
    5767{
     
    6272    screen = _owl_window_new(NULL, g.lines, g.cols, 0, 0);
    6373    screen->is_screen = 1;
     74    owl_window_set_size_cb(screen, _screen_calculate_size, &g, 0);
    6475    owl_window_map(screen, 0);
    6576  }
Note: See TracChangeset for help on using the changeset viewer.