Changeset 7b2686d for window.c


Ignore:
Timestamp:
Mar 25, 2011, 3:46:46 AM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Children:
5eb392f
Parents:
b279013
git-author:
David Benjamin <davidben@mit.edu> (02/25/11 21:52:40)
git-committer:
David Benjamin <davidben@mit.edu> (03/25/11 03:46:46)
Message:
Make the owl_window redraw hook a GSource

(Should this be a g_idle_add instead?)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • window.c

    rb31f1c9 r7b2686d  
    524524  owl_window_set_position(w, nlines, ncols, w->begin_y, w->begin_x);
    525525}
     526
     527/** Redrawing main loop hooks **/
     528
     529static bool _owl_window_should_redraw(void) {
     530  return g.resizepending || owl_window_get_screen()->dirty_subtree;
     531}
     532
     533static gboolean _owl_window_redraw_prepare(GSource *source, int *timeout) {
     534  *timeout = -1;
     535  return _owl_window_should_redraw();
     536}
     537
     538static gboolean _owl_window_redraw_check(GSource *source) {
     539  return _owl_window_should_redraw();
     540}
     541
     542static gboolean _owl_window_redraw_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) {
     543  owl_colorpair_mgr *cpmgr;
     544
     545  /* if a resize has been scheduled, deal with it */
     546  owl_global_check_resize(&g);
     547  /* update the terminal if we need to */
     548  owl_window_redraw_scheduled();
     549  /* On colorpair shortage, reset and redraw /everything/. NOTE: if
     550   * the current screen uses too many colorpairs, this draws
     551   * everything twice. But this is unlikely; COLOR_PAIRS is 64 with
     552   * 8+1 colors, and 256^2 with 256+1 colors. (+1 for default.) */
     553  cpmgr = owl_global_get_colorpair_mgr(&g);
     554  if (cpmgr->overflow) {
     555    owl_function_debugmsg("colorpairs: color shortage; reset pairs and redraw. COLOR_PAIRS = %d", COLOR_PAIRS);
     556    owl_fmtext_reset_colorpairs(cpmgr);
     557    owl_function_full_redisplay();
     558    owl_window_redraw_scheduled();
     559  }
     560  return TRUE;
     561}
     562
     563static GSourceFuncs redraw_funcs = {
     564  _owl_window_redraw_prepare,
     565  _owl_window_redraw_check,
     566  _owl_window_redraw_dispatch,
     567  NULL
     568};
     569
     570GSource *owl_window_redraw_source_new(void) {
     571  GSource *source;
     572  source = g_source_new(&redraw_funcs, sizeof(GSource));
     573  /* TODO: priority?? */
     574  return source;
     575}
Note: See TracChangeset for help on using the changeset viewer.