Changeset d106110
- Timestamp:
- May 29, 2010, 1:14:57 PM (14 years ago)
- Branches:
- master, release-1.10, 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)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
popwin.c
rd3814ff rd106110 9 9 int owl_popwin_up(owl_popwin *pw) 10 10 { 11 /* make them zero-size for now */ 12 pw->border = owl_window_new(0, 0, 0, 0, 0); 13 pw->content = owl_window_new(pw->border, 0, 0, 0, 0); 14 11 pw->border = owl_window_new(NULL); 12 pw->content = owl_window_new(pw->border); 15 13 owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0); 16 owl_window_set_resize_cb(pw->border, owl_popwin_resize_content, pw, 0); 17 /* HACK */ 18 owl_window_set_resize_cb(owl_window_get_screen(), owl_popwin_reposition, pw, 0); 19 20 /* calculate position, THEN map the windows maybe setting a resize hook 21 * should just cause it to get called? */ 22 owl_popwin_reposition(owl_window_get_screen(), pw); 14 owl_window_set_size_cb(pw->border, owl_popwin_size_border, 0, 0); 15 owl_window_set_size_cb(pw->content, owl_popwin_size_content, 0, 0); 23 16 owl_window_map(pw->border, 1); 24 17 … … 27 20 } 28 21 29 void owl_popwin_ reposition(owl_window *screen, void *user_data)22 void owl_popwin_size_border(owl_window *border, void *user_data) 30 23 { 31 owl_popwin *pw = user_data;32 24 int lines, cols, startline, startcol; 33 25 int glines, gcols; 26 owl_window *parent = owl_window_get_parent(border); 34 27 35 owl_window_get_position( screen, &glines, &gcols, 0, 0);28 owl_window_get_position(parent, &glines, &gcols, 0, 0); 36 29 37 30 lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; … … 40 33 startcol = (gcols-cols)/2; 41 34 42 owl_window_set_position( pw->border, lines, cols, startline, startcol);35 owl_window_set_position(border, lines, cols, startline, startcol); 43 36 } 44 37 45 void owl_popwin_ resize_content(owl_window *w, void *user_data)38 void owl_popwin_size_content(owl_window *content, void *user_data) 46 39 { 47 40 int lines, cols; 48 owl_ popwin *pw = user_data;49 owl_window_get_position( w, &lines, &cols, 0, 0);50 owl_window_set_position( pw->content, lines-2, cols-2, 1, 1);41 owl_window *parent = owl_window_get_parent(content); 42 owl_window_get_position(parent, &lines, &cols, 0, 0); 43 owl_window_set_position(content, lines-2, cols-2, 1, 1); 51 44 } 52 45 … … 76 69 pw->content = 0; 77 70 pw->active=0; 78 owl_window_set_resize_cb(owl_window_get_screen(), 0, 0, 0);79 71 return(0); 80 72 } -
window.c
r6b93305 rd106110 23 23 void (*redraw_cbdata_destroy)(void *); 24 24 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 *); 28 28 29 29 void (*destroy_cb)(owl_window *, void *); … … 69 69 /** Creation and Destruction **/ 70 70 71 owl_window *owl_window_new(owl_window *parent , int nlines, int ncols, int begin_y, int begin_x)71 owl_window *owl_window_new(owl_window *parent) 72 72 { 73 73 if (!parent) 74 74 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); 76 76 } 77 77 … … 108 108 /* clear all cbs */ 109 109 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); 111 111 owl_window_set_destroy_cb(w, 0, 0, 0); 112 112 … … 140 140 } 141 141 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; 142 void 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); 153 155 } 154 156 … … 439 441 _owl_window_unmap_internal(w); 440 442 } 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); 444 445 if (w->mapped) { 445 446 _owl_window_map_internal(w); … … 451 452 owl_window_set_position(w, nlines, ncols, w->begin_y, w->begin_x); 452 453 } 454 455 void 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 453 463 454 464 /** Stacking order **/
Note: See TracChangeset
for help on using the changeset viewer.