Ticket #3571: 3571-Fix-WButton-to-use-the-new-mouse-API.patch

File 3571-Fix-WButton-to-use-the-new-mouse-API.patch, 2.1 KB (added by mooffie, 9 years ago)
  • lib/widget/button.c

    From 4826af732849a19c4cdfea999a511a8a7b4156c4 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Thu, 26 Nov 2015 00:30:56 +0200
    Subject: [PATCH] Fix WButton to use the new mouse API.
    
    ---
     lib/widget/button.c | 31 ++++++++++++++++---------------
     1 file changed, 16 insertions(+), 15 deletions(-)
    
    diff --git a/lib/widget/button.c b/lib/widget/button.c
    index cf7de6d..5f4eb5e 100644
    a b button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * 
    174174 
    175175/* --------------------------------------------------------------------------------------------- */ 
    176176 
    177 static int 
    178 button_event (Gpm_Event * event, void *data) 
     177static void 
     178button_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    179179{ 
    180     Widget *w = WIDGET (data); 
     180    (void) event; 
    181181 
    182     if (!mouse_global_in_widget (event, w)) 
    183         return MOU_UNHANDLED; 
    184  
    185     if ((event->type & (GPM_DOWN | GPM_UP)) != 0) 
     182    switch (msg) 
    186183    { 
     184    case MSG_MOUSE_DOWN: 
    187185        dlg_select_widget (w); 
    188         if ((event->type & GPM_UP) != 0) 
    189         { 
    190             send_message (w, NULL, MSG_KEY, ' ', NULL); 
    191             send_message (w->owner, w, MSG_POST_KEY, ' ', NULL); 
    192         } 
    193     } 
     186        break; 
    194187 
    195     return MOU_NORMAL; 
     188    case MSG_MOUSE_CLICK: 
     189        send_message (w, NULL, MSG_KEY, ' ', NULL); 
     190        send_message (w->owner, w, MSG_POST_KEY, ' ', NULL); 
     191        break; 
     192 
     193    default: 
     194        break; 
     195    } 
    196196} 
    197197 
    198198/* --------------------------------------------------------------------------------------------- */ 
    button_new (int y, int x, int action, button_flags_t flags, const char *text, bc 
    211211    b->action = action; 
    212212    b->flags = flags; 
    213213    b->text = parse_hotkey (text); 
    214     widget_init (w, y, x, 1, button_get_len (b), button_callback, button_event); 
     214    widget_init (w, y, x, 1, button_get_len (b), button_callback, NULL); 
     215    set_easy_mouse_callback (w, button_mouse_callback); 
    215216    b->selected = FALSE; 
    216217    b->callback = callback; 
    217218    widget_want_hotkey (w, TRUE);