mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-08 20:41:59 +03:00
Optimization of DLG_RESIZE message handling.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
66371454c7
commit
1e32a51d2d
@ -157,24 +157,6 @@ edit_event (Gpm_Event *event, void *data)
|
|||||||
return MOU_NORMAL;
|
return MOU_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
edit_adjust_size (Dlg_head *h)
|
|
||||||
{
|
|
||||||
WEdit *edit;
|
|
||||||
WButtonBar *b;
|
|
||||||
|
|
||||||
edit = (WEdit *) find_widget_type (h, edit_callback);
|
|
||||||
b = find_buttonbar (h);
|
|
||||||
|
|
||||||
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
|
|
||||||
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
|
|
||||||
widget_set_size (&edit_menubar->widget, 0, 0, 1, COLS);
|
|
||||||
|
|
||||||
#ifdef RESIZABLE_MENUBAR
|
|
||||||
menubar_arrange (edit_menubar);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static cb_ret_t
|
static cb_ret_t
|
||||||
edit_command_execute (WEdit *edit, unsigned long command)
|
edit_command_execute (WEdit *edit, unsigned long command)
|
||||||
{
|
{
|
||||||
@ -187,11 +169,9 @@ edit_command_execute (WEdit *edit, unsigned long command)
|
|||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
edit_set_buttonbar (WEdit *edit)
|
edit_set_buttonbar (WEdit *edit, WButtonBar *bb)
|
||||||
{
|
{
|
||||||
WButtonBar *bb = find_buttonbar (edit->widget.parent);
|
|
||||||
|
|
||||||
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
|
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
|
||||||
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
|
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
|
||||||
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
||||||
@ -214,14 +194,26 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
|
|||||||
WButtonBar *buttonbar;
|
WButtonBar *buttonbar;
|
||||||
|
|
||||||
edit = (WEdit *) find_widget_type (h, edit_callback);
|
edit = (WEdit *) find_widget_type (h, edit_callback);
|
||||||
|
menubar = find_menubar (h);
|
||||||
|
buttonbar = find_buttonbar (h);
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case DLG_INIT:
|
case DLG_INIT:
|
||||||
edit_set_buttonbar (edit);
|
edit_set_buttonbar (edit, buttonbar);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_RESIZE:
|
case DLG_RESIZE:
|
||||||
edit_adjust_size (h);
|
widget_set_size (&edit->widget, 0, 0, LINES - 1, COLS);
|
||||||
|
widget_set_size (&buttonbar->widget , LINES - 1, 0, 1, COLS);
|
||||||
|
widget_set_size (&menubar->widget, 0, 0, 1, COLS);
|
||||||
|
menubar_arrange (menubar);
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
case DLG_ACTION:
|
||||||
|
if (sender == (Widget *) menubar)
|
||||||
|
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||||
|
if (sender == (Widget *) buttonbar)
|
||||||
|
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_VALIDATE:
|
case DLG_VALIDATE:
|
||||||
@ -229,15 +221,6 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
|
|||||||
h->running = 1;
|
h->running = 1;
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_ACTION:
|
|
||||||
menubar = find_menubar (h);
|
|
||||||
if (sender == (Widget *) menubar)
|
|
||||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
|
||||||
buttonbar = find_buttonbar (h);
|
|
||||||
if (sender == (Widget *) buttonbar)
|
|
||||||
return send_message ((Widget *) edit, WIDGET_COMMAND, parm);
|
|
||||||
return MSG_HANDLED;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return default_dlg_callback (h, sender, msg, parm, data);
|
return default_dlg_callback (h, sender, msg, parm, data);
|
||||||
}
|
}
|
||||||
|
31
src/layout.c
31
src/layout.c
@ -198,9 +198,6 @@ static const char *output_lines_label;
|
|||||||
|
|
||||||
static WButton *bleft_widget, *bright_widget;
|
static WButton *bleft_widget, *bright_widget;
|
||||||
|
|
||||||
/* Declarations for static functions */
|
|
||||||
static void low_level_change_screen_size (void);
|
|
||||||
|
|
||||||
static void _check_split (void)
|
static void _check_split (void)
|
||||||
{
|
{
|
||||||
if (_horizontal_split){
|
if (_horizontal_split){
|
||||||
@ -696,17 +693,7 @@ setup_panels (void)
|
|||||||
update_xterm_title_path ();
|
update_xterm_title_path ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static inline void
|
||||||
sigwinch_handler (int dummy)
|
|
||||||
{
|
|
||||||
(void) dummy;
|
|
||||||
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
|
|
||||||
low_level_change_screen_size ();
|
|
||||||
#endif
|
|
||||||
winch_flag = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
low_level_change_screen_size (void)
|
low_level_change_screen_size (void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
||||||
@ -732,6 +719,16 @@ low_level_change_screen_size (void)
|
|||||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigwinch_handler (int dummy)
|
||||||
|
{
|
||||||
|
(void) dummy;
|
||||||
|
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
|
||||||
|
low_level_change_screen_size ();
|
||||||
|
#endif
|
||||||
|
winch_flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
change_screen_size (void)
|
change_screen_size (void)
|
||||||
{
|
{
|
||||||
@ -758,7 +755,6 @@ change_screen_size (void)
|
|||||||
tty_keypad (TRUE);
|
tty_keypad (TRUE);
|
||||||
tty_nodelay (FALSE);
|
tty_nodelay (FALSE);
|
||||||
#endif
|
#endif
|
||||||
setup_panels ();
|
|
||||||
|
|
||||||
/* Inform all running dialogs */
|
/* Inform all running dialogs */
|
||||||
d = current_dlg;
|
d = current_dlg;
|
||||||
@ -767,10 +763,6 @@ change_screen_size (void)
|
|||||||
d = d->parent;
|
d = d->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RESIZABLE_MENUBAR
|
|
||||||
menubar_arrange (the_menubar);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Now, force the redraw */
|
/* Now, force the redraw */
|
||||||
repaint_screen ();
|
repaint_screen ();
|
||||||
#endif /* TIOCGWINSZ */
|
#endif /* TIOCGWINSZ */
|
||||||
@ -800,7 +792,6 @@ void print_vfs_message (const char *msg, ...)
|
|||||||
char str [128];
|
char str [128];
|
||||||
|
|
||||||
va_start (ap, msg);
|
va_start (ap, msg);
|
||||||
|
|
||||||
g_vsnprintf (str, sizeof (str), msg, ap);
|
g_vsnprintf (str, sizeof (str), msg, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
|
@ -1552,6 +1552,11 @@ midnight_callback (Dlg_head *h, Widget *sender,
|
|||||||
1, LINES - keybar_visible - 1);
|
1, LINES - keybar_visible - 1);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
case DLG_RESIZE:
|
||||||
|
setup_panels ();
|
||||||
|
menubar_arrange (the_menubar);
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_IDLE:
|
case DLG_IDLE:
|
||||||
/* We only need the first idle event to show user menu after start */
|
/* We only need the first idle event to show user menu after start */
|
||||||
set_idle_proc (h, 0);
|
set_idle_proc (h, 0);
|
||||||
|
@ -505,6 +505,27 @@ mcview_handle_key (mcview_t * view, int key)
|
|||||||
return MSG_NOT_HANDLED;
|
return MSG_NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mcview_adjust_size (Dlg_head *h)
|
||||||
|
{
|
||||||
|
mcview_t *view;
|
||||||
|
WButtonBar *b;
|
||||||
|
|
||||||
|
/* Look up the viewer and the buttonbar, we assume only two widgets here */
|
||||||
|
view = (mcview_t *) find_widget_type (h, mcview_callback);
|
||||||
|
b = find_buttonbar (h);
|
||||||
|
|
||||||
|
widget_set_size (&view->widget, 0, 0, LINES - 1, COLS);
|
||||||
|
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
|
||||||
|
|
||||||
|
mcview_compute_areas (view);
|
||||||
|
mcview_update_bytes_per_line (view);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/*** public functions ****************************************************************************/
|
/*** public functions ****************************************************************************/
|
||||||
|
@ -386,25 +386,6 @@ mcview_display_ruler (mcview_t * view)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
|
||||||
mcview_adjust_size (Dlg_head *h)
|
|
||||||
{
|
|
||||||
mcview_t *view;
|
|
||||||
WButtonBar *b;
|
|
||||||
|
|
||||||
/* Look up the viewer and the buttonbar, we assume only two widgets here */
|
|
||||||
view = (mcview_t *) find_widget_type (h, mcview_callback);
|
|
||||||
b = find_buttonbar (h);
|
|
||||||
|
|
||||||
widget_set_size (&view->widget, 0, 0, LINES - 1, COLS);
|
|
||||||
widget_set_size (&b->widget , LINES - 1, 0, 1, COLS);
|
|
||||||
|
|
||||||
mcview_compute_areas (view);
|
|
||||||
mcview_update_bytes_per_line (view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mcview_percent (mcview_t * view, off_t p)
|
mcview_percent (mcview_t * view, off_t p)
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,6 @@ void mcview_update_bytes_per_line (mcview_t *view);
|
|||||||
void mcview_display_toggle_ruler (mcview_t *view);
|
void mcview_display_toggle_ruler (mcview_t *view);
|
||||||
void mcview_display_clean (mcview_t *view);
|
void mcview_display_clean (mcview_t *view);
|
||||||
void mcview_display_ruler (mcview_t *view);
|
void mcview_display_ruler (mcview_t *view);
|
||||||
void mcview_adjust_size (Dlg_head *h);
|
|
||||||
void mcview_percent (mcview_t *view, off_t p);
|
void mcview_percent (mcview_t *view, off_t p);
|
||||||
|
|
||||||
/* growbuf.c: */
|
/* growbuf.c: */
|
||||||
|
Loading…
Reference in New Issue
Block a user