From 7c74fd90f0cef99e158a0e8dc453cb8c2c51927e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 28 Jun 2016 15:39:03 +0300 Subject: [PATCH 1/3] Ticket #3661: wrong handling of mouse clicks in long listing mode. This occurs if the left panel is in long listing mode and the right panel is in full listing mode: When the left panel is active and you click on the right side of the panel, the click event is directed to the (inactive) right panel instead of the (active) left panel. This occurs if the right panel is in long listing mode: When the left panel is active and you click on the left panel, the click event is always directed to the (inactive) right panel. It's impossible to click anything on the left panel, if the right panel is in long listing mode. Thanks Seray Rosh for intial patch. Initial commit: refactoring of widget selection. Signed-off-by: Andrew Borodin --- lib/widget/dialog.c | 55 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 346aadf25..066dc6b05 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -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); } /* --------------------------------------------------------------------------------------------- */ From cd90f2f98c10b2119ddae82263a2bcce9d0cf090 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 28 Jun 2016 15:52:00 +0300 Subject: [PATCH 2/3] Set WOP_TOP_SELECT options for panel widgets: WPanel, WView and WTree. Signed-off-by: Andrew Borodin --- src/filemanager/panel.c | 1 + src/filemanager/tree.c | 1 + src/viewer/mcviewer.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 19f8327d3..908ae3777 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -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) { diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index e724c1d23..b2dcea4f8 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -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; diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c index 0ab9bc5dc..8786a454c 100644 --- a/src/viewer/mcviewer.c +++ b/src/viewer/mcviewer.c @@ -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; From 0f7d5cfcd1765f9f9ea4d6fa6de7eec352448e04 Mon Sep 17 00:00:00 2001 From: Seray Rosh Date: Tue, 28 Jun 2016 15:54:09 +0300 Subject: [PATCH 3/3] (edit_dialog_command_execute): when switch to another window, do not select it twice. Signed-off-by: Andrew Borodin --- src/editor/editwidget.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index e27220ce1..03c3701b1 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -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);