Ticket #3722: mc-3722-prevent-execute-last-element-on-empty-area-v2.patch

File mc-3722-prevent-execute-last-element-on-empty-area-v2.patch, 1.9 KB (added by and, 3 years ago)
  • src/filemanager/panel.c

    From 2ccc6c56eebbfb66f3274087d608986a0cc31a2b Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Wed, 7 Dec 2016 12:16:17 +0000
    Subject: [PATCH] Prevent execute last item on empty area
    
    As pointed out by egmont (#3722) prevent execute of last item when
    clicking on empty area by accident.
    
    V2: handle brief mode
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/panel.c | 24 ++++++++++++++++++++----
     1 file changed, 20 insertions(+), 4 deletions(-)
    
    diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
    index a1b474b..e586915 100644
    a b panel_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    39063906    case MSG_MOUSE_CLICK: 
    39073907        if ((event->count & GPM_DOUBLE) != 0) 
    39083908        { 
    3909             int y, lines; 
     3909            int top_file = panel->top_file; 
     3910            int left_border_pos = 0; 
    39103911 
    3911             y = event->y - 2; 
    3912             lines = panel_lines (panel); 
     3912            /* compute top_file/left_border_pos for brief mode */ 
     3913            if (panel->list_type == list_brief && panel->list_cols > 1) 
     3914            { 
     3915                int width, cur_col; 
     3916 
     3917                width = (w->cols - 2) / panel->list_cols; 
     3918                cur_col = event->x / width; 
     3919                top_file = cur_col * panel_lines (panel) + panel->top_file; 
     3920                left_border_pos = cur_col * width; 
     3921            } 
    39133922 
    3914             if (y >= 0 && y < lines) 
     3923                /* ignore left border */ 
     3924            if (event->x > left_border_pos && 
     3925                /* ignore right border */ 
     3926                event->x < w->cols - 1 && 
     3927                /* ignore top border */ 
     3928                event->y > 1 && 
     3929                /* ignore bottom empty area */ 
     3930                event->y < panel->dir.len - top_file + 2) 
    39153931                do_enter (panel); 
    39163932        } 
    39173933        break;