From db8db1268c4a69ee57466f7c28ffe0c99b521faf Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 24 Oct 2003 23:57:18 +0000 Subject: [PATCH] * dialog.c: Remove duplication between two chains of dialogs. * dialog.h (struct Dlg_head): Add "fullscreen" field, remove "refresh_pushed", rename "previous_dialog" to "parent". --- src/ChangeLog | 4 +++ src/dialog.c | 78 +++++++-------------------------------------------- src/dialog.h | 6 ++-- 3 files changed, 17 insertions(+), 71 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 50c3f6f0c..9dafa5fa6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2003-10-24 Pavel Roskin + * dialog.c: Remove duplication between two chains of dialogs. + * dialog.h (struct Dlg_head): Add "fullscreen" field, remove + "refresh_pushed", rename "previous_dialog" to "parent". + * tree.h: Fix unneeded dependency on dialog.h. * layout.h: Likewise. diff --git a/src/dialog.c b/src/dialog.c index 7d699f56b..9ba218558 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -268,67 +268,25 @@ enum { REFRESH_COVERS_ALL /* If the refresh fn convers all the screen */ }; -typedef void (*refresh_fn) (void *); - -/* The refresh stack */ -struct Refresh { - void (*refresh_fn)(void *); - void *parameter; - int flags; - struct Refresh *next; -}; - -static struct Refresh *refresh_list; - static void -push_refresh (refresh_fn new_refresh, void *parameter, int flags) +do_complete_refresh (Dlg_head *dlg) { - struct Refresh *new; + if (!dlg->fullscreen && dlg->parent) + do_complete_refresh (dlg->parent); - new = g_new (struct Refresh, 1); - new->next = (struct Refresh *) refresh_list; - new->refresh_fn = new_refresh; - new->parameter = parameter; - new->flags = flags; - refresh_list = new; -} - -static void -pop_refresh (void) -{ - struct Refresh *old; - - if (!refresh_list) - fprintf (stderr, _("\n\n\nrefresh stack underflow!\n\n\n")); - else { - old = refresh_list; - refresh_list = refresh_list->next; - g_free (old); - } -} - -static void -do_complete_refresh (struct Refresh *refresh_list) -{ - if (!refresh_list) - return; - - if (refresh_list->flags != REFRESH_COVERS_ALL) - do_complete_refresh (refresh_list->next); - - (*(refresh_list->refresh_fn)) (refresh_list->parameter); + dlg_redraw (dlg); } void do_refresh (void) { - if (we_are_background || !refresh_list) + if (we_are_background || !current_dlg) return; if (fast_refresh) - (*(refresh_list->refresh_fn)) (refresh_list->parameter); + dlg_redraw (current_dlg); else { - do_complete_refresh (refresh_list); + do_complete_refresh (current_dlg); } } @@ -551,12 +509,6 @@ void dlg_redraw (Dlg_head *h) update_cursor (h); } -static void -dlg_refresh (void *parameter) -{ - dlg_redraw ((Dlg_head *) parameter); -} - void dlg_stop (Dlg_head *h) { h->running = 0; @@ -753,21 +705,14 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event) /* Init the process */ void init_dlg (Dlg_head *h) { - int refresh_mode; - /* Initialize dialog manager and widgets */ (*h->callback) (h, DLG_INIT, 0); dlg_broadcast_msg (h, WIDGET_INIT, 0); if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES) - refresh_mode = REFRESH_COVERS_ALL; - else - refresh_mode = REFRESH_COVERS_PART; + h->fullscreen = 1; - push_refresh (dlg_refresh, h, refresh_mode); - h->refresh_pushed = 1; - - h->previous_dialog = current_dlg; + h->parent = current_dlg; current_dlg = h; /* Initialize the mouse status */ @@ -790,7 +735,7 @@ void dlg_run_done (Dlg_head *h) if (h->current) (*h->callback) (h, DLG_END, 0); - current_dlg = (Dlg_head *) h->previous_dialog; + current_dlg = h->parent; } void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event) @@ -863,9 +808,6 @@ destroy_dlg (Dlg_head *h) int i; Widget *c; - if (h->refresh_pushed) - pop_refresh (); - dlg_broadcast_msg (h, WIDGET_DESTROY, 0); c = h->current; for (i = 0; i < h->count; i++) { diff --git a/src/dialog.h b/src/dialog.h index 6edae36ad..0d24774e8 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -97,15 +97,15 @@ typedef struct Dlg_head { int cols, lines; /* Width and height of the window */ /* Internal flags */ - int running; + int running:1; /* The dialog is currently active */ + int fullscreen:1; /* Parents dialogs don't need refresh */ int mouse_status; /* For the autorepeat status of the mouse */ - int refresh_pushed; /* Did the dialog actually run? */ /* Internal variables */ int count; /* Number of widgets */ struct Widget *current; /* Curently active widget */ dlg_cb_fn callback; - void *previous_dialog; /* Pointer to the previously running Dlg_head */ + struct Dlg_head *parent; /* Parent dialog */ } Dlg_head;