diff --git a/lib/widget/button.c b/lib/widget/button.c index 4740f9373..50d31bd5b 100644 --- a/lib/widget/button.c +++ b/lib/widget/button.c @@ -241,8 +241,7 @@ button_set_text (WButton * b, const char *text) release_hotkey (b->text); b->text = parse_hotkey (text); w->cols = button_get_len (b); - if (w->owner != NULL) - send_message (w, NULL, MSG_DRAW, 0, NULL); + widget_redraw (w); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/buttonbar.h b/lib/widget/buttonbar.h index d6694a11a..e5781630b 100644 --- a/lib/widget/buttonbar.h +++ b/lib/widget/buttonbar.h @@ -47,13 +47,6 @@ WButtonBar *find_buttonbar (const WDialog * h); /*** inline functions ****************************************************************************/ -static inline void -buttonbar_redraw (WButtonBar * bb) -{ - if (bb != NULL) - send_message (bb, NULL, MSG_DRAW, 0, NULL); -} - static inline void buttonbar_set_visible (WButtonBar * bb, gboolean visible) { diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 86f16af6b..8187cf59f 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -1382,8 +1382,7 @@ dlg_replace_widget (Widget * old_w, Widget * new_w) if (should_focus) dlg_select_widget (new_w); - if (new_w->owner->state == DLG_ACTIVE) - send_message (new_w, NULL, MSG_DRAW, 0, NULL); + widget_redraw (new_w); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/gauge.c b/lib/widget/gauge.c index 317aed689..b6876ed9d 100644 --- a/lib/widget/gauge.c +++ b/lib/widget/gauge.c @@ -164,7 +164,7 @@ gauge_set_value (WGauge * g, int max, int current) max = 1; /* I do not like division by zero :) */ g->current = current; g->max = max; - gauge_callback (WIDGET (g), NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (g)); } /* --------------------------------------------------------------------------------------------- */ @@ -175,7 +175,7 @@ gauge_show (WGauge * g, gboolean shown) if (g->shown != shown) { g->shown = shown; - gauge_callback (WIDGET (g), NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (g)); } } diff --git a/lib/widget/groupbox.c b/lib/widget/groupbox.c index 7fef8f91f..0ff62d119 100644 --- a/lib/widget/groupbox.c +++ b/lib/widget/groupbox.c @@ -119,8 +119,6 @@ groupbox_new (int y, int x, int height, int width, const char *title) void groupbox_set_title (WGroupbox * g, const char *title) { - Widget *w = WIDGET (g); - g_free (g->title); g->title = NULL; @@ -134,8 +132,7 @@ groupbox_set_title (WGroupbox * g, const char *title) g_free (t); } - if (w->owner != NULL) - send_message (w, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (g)); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/hline.c b/lib/widget/hline.c index b094e01c3..54c83413a 100644 --- a/lib/widget/hline.c +++ b/lib/widget/hline.c @@ -150,8 +150,7 @@ hline_set_text (WHLine * l, const char *text) else l->text = g_strdup (text); - if (WIDGET (l)->owner != NULL) - send_message (l, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (l)); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/input.c b/lib/widget/input.c index a880b8146..a2825f2f0 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -1265,6 +1265,7 @@ input_set_point (WInput * in, int pos) void input_update (WInput * in, gboolean clear_first) { + Widget *w = WIDGET (in); int has_history = 0; int i; int buf_len; @@ -1292,13 +1293,13 @@ input_update (WInput * in, gboolean clear_first) in->mark = min (in->mark, buf_len); /* don't draw widget not put into dialog */ - if (WIDGET (in)->owner == NULL) + if (w->owner == NULL || w->owner->state != DLG_ACTIVE) return; if (has_history != 0) draw_history_button (in); - if ((WIDGET (in)->options & W_DISABLED) != 0) + if ((w->options & W_DISABLED) != 0) tty_setcolor (DISABLED_COLOR); else if (in->first) tty_setcolor (in->color[WINPUTC_UNCHANGED]); diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index 3dd3d0231..23f4c11ab 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -1058,7 +1058,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d listbox_select_entry (LISTBOX (h->current->data), i); end = new_end; input_handle_char (input, parm); - send_message (h->current->data, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (h->current->data)); break; } } @@ -1161,7 +1161,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d if (need_redraw == 2) { insert_text (input, last_text, low); - send_message (h->current->data, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (h->current->data)); } else if (need_redraw == 1) { diff --git a/lib/widget/label.c b/lib/widget/label.c index ec31c3226..965fbcfaf 100644 --- a/lib/widget/label.c +++ b/lib/widget/label.c @@ -182,11 +182,10 @@ label_set_text (WLabel * label, const char *text) } } - if (w->owner != NULL) - send_message (w, NULL, MSG_DRAW, 0, NULL); - if (newcols < w->cols) w->cols = newcols; + + widget_redraw (w); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index 549202bb1..ccb90580c 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -268,6 +268,20 @@ widget_erase (Widget * w) /* --------------------------------------------------------------------------------------------- */ +void +widget_redraw (Widget * w) +{ + if (w != NULL) + { + WDialog *h = w->owner; + + if (h != NULL && h->state == DLG_ACTIVE) + w->callback (w, NULL, MSG_DRAW, 0, NULL); + } +} + +/* --------------------------------------------------------------------------------------------- */ + /* get mouse pointer location within widget */ Gpm_Event mouse_get_local (const Gpm_Event * global, const Widget * w) diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h index 4aa873466..77c516b96 100644 --- a/lib/widget/widget-common.h +++ b/lib/widget/widget-common.h @@ -142,6 +142,7 @@ void widget_set_options (Widget * w, widget_options_t options, gboolean enable); void widget_set_size (Widget * widget, int y, int x, int lines, int cols); /* select color for widget in dependance of state */ void widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey); +void widget_redraw (Widget * w); void widget_erase (Widget * w); /* get mouse pointer location within widget */ diff --git a/src/editor/edit.c b/src/editor/edit.c index b33b4ae42..db70eea15 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -1878,7 +1878,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry) edit_cursor_move (edit, curs - edit->curs1); edit->force |= REDRAW_PAGE; - send_message (edit, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (edit)); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index 890547388..4a221aa34 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -3333,7 +3333,7 @@ edit_select_codepage_cmd (WEdit * edit) edit_set_codeset (edit); edit->force = REDRAW_PAGE; - send_message (edit, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (edit)); } #endif diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index f71e4c271..6061403d4 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -1173,7 +1173,7 @@ edit_update_screen (WEdit * e) edit_render_keypress (e); } - buttonbar_redraw (find_buttonbar (h)); + widget_redraw (WIDGET (find_buttonbar (h))); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/find.c b/src/filemanager/find.c index f114f1338..08e91a53c 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -922,7 +922,7 @@ find_add_match (const char *dir, const char *file) /* Don't scroll */ if (matches == 0) listbox_select_first (find_list); - send_message (find_list, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (find_list)); matches++; found_num_update (); diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index fca176510..23e95f1ec 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -233,7 +233,7 @@ update_split (const WDialog * h) check_options[0].widget->state = _panels_layout.horizontal_equal ? 1 : 0; else check_options[0].widget->state = _panels_layout.vertical_equal ? 1 : 0; - send_message (check_options[0].widget, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (check_options[0].widget)); tty_setcolor (check_options[0].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL); diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index a63d6f60d..f97a18e85 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -1097,10 +1097,10 @@ static void update_dirty_panels (void) { if (get_current_type () == view_listing && current_panel->dirty) - send_message (current_panel, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (current_panel)); if (get_other_type () == view_listing && other_panel->dirty) - send_message (other_panel, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (other_panel)); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 86fd21fdf..482a59551 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -2497,7 +2497,7 @@ do_search (WPanel * panel, int c_code) unselect_item (panel); panel->selected = sel; select_item (panel); - send_message (panel, NULL, MSG_DRAW, 0, NULL); + widget_redraw (WIDGET (panel)); } else if (c_code != KEY_BACKSPACE) { @@ -3462,7 +3462,7 @@ panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d bb = find_buttonbar (w->owner); midnight_set_buttonbar (bb); - buttonbar_redraw (bb); + widget_redraw (WIDGET (bb)); return MSG_HANDLED; case MSG_UNFOCUS: @@ -3718,7 +3718,7 @@ panel_event (Gpm_Event * event, void *data) finish: if (panel->dirty) - send_message (w, NULL, MSG_DRAW, 0, NULL); + widget_redraw (w); return MOU_NORMAL; } diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index bba6a12cc..ca2bb11af 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -1236,7 +1236,7 @@ tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da buttonbar_clear_label (b, 7, WIDGET (tree)); #endif buttonbar_set_label (b, 8, Q_ ("ButtonBar|Rmdir"), tree_map, w); - buttonbar_redraw (b); + widget_redraw (WIDGET (b)); /* FIXME: Should find a better way of only displaying the currently selected item */ diff --git a/src/viewer/display.c b/src/viewer/display.c index 41606c52f..9c1611abf 100644 --- a/src/viewer/display.c +++ b/src/viewer/display.c @@ -189,7 +189,7 @@ mcview_update (mcview_t * view) { view->dpy_bbar_dirty = FALSE; mcview_set_buttonbar (view); - buttonbar_redraw (find_buttonbar (WIDGET (view)->owner)); + widget_redraw (WIDGET (find_buttonbar (WIDGET (view)->owner))); } if (view->dirty > dirt_limit)