Changeset d106110 for window.c


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:
d39f68c
Parents:
6b93305
git-author:
David Benjamin <davidben@mit.edu> (05/27/10 13:19:26)
git-committer:
David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
Message:
Make the size callbacks listen for parent sizing

This probably matches better with how we'll usually use it. Keep the
imperative functions around for now. They may be useful.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • window.c

    r6b93305 rd106110  
    2323  void (*redraw_cbdata_destroy)(void *);
    2424
    25   void (*resize_cb)(owl_window *, void *);
    26   void *resize_cbdata;
    27   void (*resize_cbdata_destroy)(void *);
     25  void (*size_cb)(owl_window *, void *);
     26  void *size_cbdata;
     27  void (*size_cbdata_destroy)(void *);
    2828
    2929  void (*destroy_cb)(owl_window *, void *);
     
    6969/** Creation and Destruction **/
    7070
    71 owl_window *owl_window_new(owl_window *parent, int nlines, int ncols, int begin_y, int begin_x)
     71owl_window *owl_window_new(owl_window *parent)
    7272{
    7373  if (!parent)
    7474    parent = owl_window_get_screen();
    75   return _owl_window_new(parent, nlines, ncols, begin_y, begin_x);
     75  return _owl_window_new(parent, 0, 0, 0, 0);
    7676}
    7777
     
    108108  /* clear all cbs */
    109109  owl_window_set_redraw_cb(w, 0, 0, 0);
    110   owl_window_set_resize_cb(w, 0, 0, 0);
     110  owl_window_set_size_cb(w, 0, 0, 0);
    111111  owl_window_set_destroy_cb(w, 0, 0, 0);
    112112
     
    140140}
    141141
    142 void owl_window_set_resize_cb(owl_window *w, void (*cb)(owl_window*, void*), void *cbdata, void (*cbdata_destroy)(void*))
    143 {
    144   if (w->resize_cbdata_destroy) {
    145     w->resize_cbdata_destroy(w->resize_cbdata);
    146     w->resize_cbdata = 0;
    147     w->resize_cbdata_destroy = 0;
    148   }
    149 
    150   w->resize_cb = cb;
    151   w->resize_cbdata = cbdata;
    152   w->resize_cbdata_destroy = cbdata_destroy;
     142void owl_window_set_size_cb(owl_window *w, void (*cb)(owl_window*, void*), void *cbdata, void (*cbdata_destroy)(void*))
     143{
     144  if (w->size_cbdata_destroy) {
     145    w->size_cbdata_destroy(w->size_cbdata);
     146    w->size_cbdata = 0;
     147    w->size_cbdata_destroy = 0;
     148  }
     149
     150  w->size_cb = cb;
     151  w->size_cbdata = cbdata;
     152  w->size_cbdata_destroy = cbdata_destroy;
     153
     154  owl_window_recompute_position(w);
    153155}
    154156
     
    439441    _owl_window_unmap_internal(w);
    440442  }
    441   /* call the resize hooks BEFORE remapping, so that everything can resize */
    442   if (w->resize_cb)
    443     w->resize_cb(w, w->resize_cbdata);
     443  /* recalculate children sizes BEFORE remapping, so that everything can resize */
     444  owl_window_children_foreach_onearg(w, owl_window_recompute_position);
    444445  if (w->mapped) {
    445446    _owl_window_map_internal(w);
     
    451452  owl_window_set_position(w, nlines, ncols, w->begin_y, w->begin_x);
    452453}
     454
     455void owl_window_recompute_position(owl_window *w)
     456{
     457  if (w->size_cb) {
     458    /* TODO: size_cb probably wants to actually take four int*s */
     459    w->size_cb(w, w->size_cbdata);
     460  }
     461}
     462
    453463
    454464/** Stacking order **/
Note: See TracChangeset for help on using the changeset viewer.