mirror of https://github.com/MidnightCommander/mc
Merge branch '3661_panel_mouse_click'
* 3661_panel_mouse_click: (edit_dialog_command_execute): when switch to another window, do not select it twice. Set WOP_TOP_SELECT options for panel widgets: WPanel, WView and WTree. Ticket #3661: wrong handling of mouse clicks in long listing mode.
This commit is contained in:
commit
aa79525bb8
|
@ -213,6 +213,23 @@ dlg_find_widget_callback (const void *a, const void *b)
|
|||
return (w->callback == f) ? 0 : 1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Put widget on top or bottom of Z-order.
|
||||
*/
|
||||
static void
|
||||
dlg_reorder_widgets (GList * l, gboolean set_top)
|
||||
{
|
||||
WDialog *h = WIDGET (l->data)->owner;
|
||||
|
||||
h->widgets = g_list_remove_link (h->widgets, l);
|
||||
if (set_top)
|
||||
h->widgets = g_list_concat (h->widgets, l);
|
||||
else
|
||||
h->widgets = g_list_concat (l, h->widgets);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Try to select another widget. If forward is set, follow tab order.
|
||||
|
@ -255,6 +272,9 @@ do_select_widget (WDialog * h, GList * w, select_dir_t dir)
|
|||
}
|
||||
while (h->current != w);
|
||||
|
||||
if (widget_get_options (WIDGET (h->current->data), WOP_TOP_SELECT))
|
||||
dlg_reorder_widgets (h->current, TRUE);
|
||||
|
||||
if (widget_overlapped (w0, WIDGET (h->current->data)))
|
||||
{
|
||||
send_message (h->current->data, NULL, MSG_DRAW, 0, NULL);
|
||||
|
@ -610,31 +630,6 @@ dlg_find_widget_by_id (gconstpointer a, gconstpointer b)
|
|||
return w->id == id ? 0 : 1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
dlg_set_top_or_bottom_widget (void *w, gboolean set_top)
|
||||
{
|
||||
Widget *widget = WIDGET (w);
|
||||
WDialog *h = widget->owner;
|
||||
GList *l;
|
||||
|
||||
l = g_list_find (h->widgets, w);
|
||||
if (l == NULL)
|
||||
abort (); /* widget is not in dialog, this should not happen */
|
||||
|
||||
/* unfocus prevoius widget and focus current one before widget reordering */
|
||||
if (set_top && widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
do_select_widget (h, l, SELECT_EXACT);
|
||||
|
||||
/* widget reordering */
|
||||
h->widgets = g_list_remove_link (h->widgets, l);
|
||||
if (set_top)
|
||||
h->widgets = g_list_concat (h->widgets, l);
|
||||
else
|
||||
h->widgets = g_list_concat (l, h->widgets);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1145,10 +1140,7 @@ dlg_select_widget (void *w)
|
|||
Widget *widget = WIDGET (w);
|
||||
WDialog *h = widget->owner;
|
||||
|
||||
if (widget_get_options (widget, WOP_TOP_SELECT))
|
||||
dlg_set_top_or_bottom_widget (w, TRUE);
|
||||
else
|
||||
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
|
||||
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1159,7 +1151,10 @@ dlg_select_widget (void *w)
|
|||
void
|
||||
dlg_set_bottom_widget (void *w)
|
||||
{
|
||||
dlg_set_top_or_bottom_widget (w, FALSE);
|
||||
Widget *widget = WIDGET (w);
|
||||
WDialog *h = widget->owner;
|
||||
|
||||
dlg_reorder_widgets (g_list_find (h->widgets, widget), FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -485,11 +485,9 @@ edit_dialog_command_execute (WDialog * h, long command)
|
|||
break;
|
||||
case CK_WindowNext:
|
||||
dlg_one_down (h);
|
||||
dlg_select_widget (h->current->data);
|
||||
break;
|
||||
case CK_WindowPrev:
|
||||
dlg_one_up (h);
|
||||
dlg_select_widget (h->current->data);
|
||||
break;
|
||||
case CK_Options:
|
||||
edit_options_dialog (h);
|
||||
|
|
|
@ -4292,6 +4292,7 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
|||
w = WIDGET (panel);
|
||||
/* No know sizes of the panel at startup */
|
||||
widget_init (w, 0, 0, 0, 0, panel_callback, panel_mouse_callback);
|
||||
widget_set_options (w, WOP_TOP_SELECT, TRUE);
|
||||
|
||||
if (vpath != NULL)
|
||||
{
|
||||
|
|
|
@ -1280,6 +1280,7 @@ tree_new (int y, int x, int lines, int cols, gboolean is_panel)
|
|||
w = WIDGET (tree);
|
||||
|
||||
widget_init (w, y, x, lines, cols, tree_callback, tree_mouse_callback);
|
||||
widget_set_options (w, WOP_TOP_SELECT, TRUE);
|
||||
tree->is_panel = is_panel;
|
||||
tree->selected_ptr = 0;
|
||||
|
||||
|
|
|
@ -190,9 +190,12 @@ WView *
|
|||
mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
{
|
||||
WView *view;
|
||||
Widget *w;
|
||||
|
||||
view = g_new0 (WView, 1);
|
||||
widget_init (WIDGET (view), y, x, lines, cols, mcview_callback, mcview_mouse_callback);
|
||||
w = WIDGET (view);
|
||||
widget_init (w, y, x, lines, cols, mcview_callback, mcview_mouse_callback);
|
||||
widget_set_options (w, WOP_TOP_SELECT, TRUE);
|
||||
|
||||
view->hex_mode = FALSE;
|
||||
view->hexedit_mode = FALSE;
|
||||
|
|
Loading…
Reference in New Issue