Ticket #3571: 3571---experimental---Fix-menu-handling.patch

File 3571---experimental---Fix-menu-handling.patch, 4.0 KB (added by mooffie, 8 years ago)
  • lib/widget/dialog.c

    From 04294b2bff23656eb3b7468095b90c4401419810 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Tue, 8 Mar 2016 22:45:17 +0200
    Subject: [PATCH] !!experimental!! Fix menu handling.
    
    ---
     lib/widget/dialog.c        | 36 +++++++++++++++++++++---------------
     src/filemanager/midnight.c | 28 +---------------------------
     2 files changed, 22 insertions(+), 42 deletions(-)
    
    diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c
    index ddf78f7..4601bcb 100644
    a b dlg_mouse_translator (Gpm_Event * event, Widget * w) 
    376376/* --------------------------------------------------------------------------------------------- */ 
    377377 
    378378static cb_ret_t 
     379try_mouse_event (Widget * w, Gpm_Event * event) 
     380{ 
     381    if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL) 
     382        return dlg_mouse_translator (event, w); 
     383    return MSG_NOT_HANDLED; 
     384} 
     385 
     386static cb_ret_t 
    379387dlg_mouse_event (WDialog * h, Gpm_Event * event) 
    380388{ 
    381389    Widget *wh = WIDGET (h); 
    382  
    383     GList *p, *first; 
     390    GList *p; 
     391    cb_ret_t ret; 
    384392 
    385393    /* close the dialog by mouse left click out of dialog area */ 
    386394    if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) 
    dlg_mouse_event (WDialog * h, Gpm_Event * event) 
    400408            return mou; 
    401409    } 
    402410 
    403     first = h->current; 
    404     p = first; 
     411    /* First, send the event to the focused widget. */ 
     412    /* FIXME: This is just for the case where it's the menu. We can instead make 
     413       the menu make itself the topmost, on activation, and then remove this code. */ 
     414    if ((ret = try_mouse_event (WIDGET (h->current->data), event)) != MSG_NOT_HANDLED) 
     415        return ret; 
    405416 
     417    /* Send the event to widgets in stacking order: from the topmost to the bottomost. */ 
     418    p = g_list_last (h->widgets); 
    406419    do 
    407420    { 
    408421        Widget *w = WIDGET (p->data); 
    409422 
    410         p = dlg_widget_prev (h, p); 
     423        if ((ret = try_mouse_event (w, event)) != MSG_NOT_HANDLED) 
     424            return ret; 
    411425 
    412         if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL) 
    413         { 
    414             /* put global cursor position to the widget */ 
    415             cb_ret_t ret; 
    416  
    417             ret = dlg_mouse_translator (event, w); 
    418             if (ret != MSG_NOT_HANDLED) 
    419                 return ret; 
    420         } 
     426        p = g_list_previous (p); 
    421427    } 
    422     while (p != first); 
     428    while (p != NULL); 
    423429 
    424430    return MSG_NOT_HANDLED; 
    425431} 
  • src/filemanager/midnight.c

    diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c
    index 73dfff5..e0a284d 100644
    a b midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void 
    15901590} 
    15911591 
    15921592/* --------------------------------------------------------------------------------------------- */ 
    1593  
    1594 /** 
    1595  * Handle mouse events of file manager screen. 
    1596  * 
    1597  * @param w Widget object (the file manager) 
    1598  * @param msg mouse event message 
    1599  * @param event mouse event data 
    1600  */ 
    1601 static cb_ret_t 
    1602 midnight_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    1603 { 
    1604     (void) w; 
    1605     (void) msg; 
    1606  
    1607     if (msg == MSG_MOUSE_DOWN && event->y == 0) 
    1608     { 
    1609         /* menubar */ 
    1610         if (!the_menubar->is_active) 
    1611             dlg_select_widget (WIDGET (the_menubar)); 
    1612     } 
    1613  
    1614     /* allow handle menu events */ 
    1615     return MSG_NOT_HANDLED; 
    1616 } 
    1617  
    1618 /* --------------------------------------------------------------------------------------------- */ 
    16191593/*** public functions ****************************************************************************/ 
    16201594/* --------------------------------------------------------------------------------------------- */ 
    16211595 
    do_nc (void) 
    17981772#endif 
    17991773 
    18001774    midnight_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, dialog_colors, midnight_callback, 
    1801                                midnight_mouse_callback, "[main]", NULL, DLG_NONE); 
     1775                               NULL, "[main]", NULL, DLG_NONE); 
    18021776 
    18031777    /* Check if we were invoked as an editor or file viewer */ 
    18041778    if (mc_global.mc_run_mode != MC_RUN_FULL)