Ticket #3571: 3571-Rename-mouse.was_drag-to-mouse.last_msg.patch

File 3571-Rename-mouse.was_drag-to-mouse.last_msg.patch, 2.8 KB (added by mooffie, 9 years ago)
  • lib/widget/mouse.c

    From 85daceb02c77c3854befce98220e8b2c36503a63 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Wed, 23 Mar 2016 18:17:05 +0200
    Subject: [PATCH] Rename mouse.was_drag to mouse.last_msg.
    
    ---
     lib/widget/mouse.c         | 7 ++++---
     lib/widget/widget-common.c | 4 ++--
     lib/widget/widget-common.h | 7 +++++--
     3 files changed, 11 insertions(+), 7 deletions(-)
    
    diff --git a/lib/widget/mouse.c b/lib/widget/mouse.c
    index 86c23b8..4e834e4 100644
    a b mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) 
    132132            msg = MSG_MOUSE_UP; 
    133133 
    134134            if (in_widget) 
    135                 *click = !w->mouse.was_drag; 
     135                /* If the mouse hasn't been dragged since the MSG_MOUSE_DOWN, we trigger a click. */ 
     136                *click = (w->mouse.last_msg == MSG_MOUSE_DOWN); 
    136137 
    137138            /* 
    138139             * When using xterm, event->buttons reports the buttons' state 
    mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) 
    158159    } 
    159160 
    160161    if (msg != 0) 
    161         /* Rememer the current state for next event. */ 
    162         w->mouse.was_drag = ((event->type & GPM_DRAG) != 0); 
     162        /* Record the current event type for the benefit of the next event. */ 
     163        w->mouse.last_msg = msg; 
    163164 
    164165    init_mouse_event (&local, msg, event, w); 
    165166 
  • lib/widget/widget-common.c

    diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c
    index a29181a..9c09719 100644
    a b widget_init (Widget * w, int y, int x, int lines, int cols, 
    149149    w->mouse_callback = mouse_callback; 
    150150    w->set_options = widget_default_set_options_callback; 
    151151    w->owner = NULL; 
    152     w->mouse.capture = FALSE; 
    153152    w->mouse.forced_capture = FALSE; 
     153    w->mouse.capture = FALSE; 
     154    w->mouse.last_msg = 0; 
    154155    w->mouse.last_buttons_down = 0; 
    155     w->mouse.was_drag = FALSE; 
    156156 
    157157    /* Almost all widgets want to put the cursor in a suitable place */ 
    158158    w->options = W_WANT_CURSOR; 
  • lib/widget/widget-common.h

    diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h
    index be524d1..be5f41f 100644
    a b struct Widget 
    112112    /* Mouse-related fields. */ 
    113113    struct 
    114114    { 
     115        /* Public members: */ 
     116        gboolean forced_capture;        /* Overrides the 'capture' member. Set explicitly by the programmer. */ 
     117 
     118        /* Implementation details: */ 
    115119        gboolean capture;       /* Whether the widget "owns" the mouse. */ 
    116         gboolean forced_capture;        /* Overrides the above. Set explicitly by the programmer. */ 
     120        mouse_msg_t last_msg;   /* The previous event type processed. */ 
    117121        int last_buttons_down; 
    118         gboolean was_drag; 
    119122    } mouse; 
    120123}; 
    121124