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) |
132 | 132 | msg = MSG_MOUSE_UP; |
133 | 133 | |
134 | 134 | 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); |
136 | 137 | |
137 | 138 | /* |
138 | 139 | * When using xterm, event->buttons reports the buttons' state |
… |
… |
mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) |
158 | 159 | } |
159 | 160 | |
160 | 161 | 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; |
163 | 164 | |
164 | 165 | init_mouse_event (&local, msg, event, w); |
165 | 166 | |
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, |
149 | 149 | w->mouse_callback = mouse_callback; |
150 | 150 | w->set_options = widget_default_set_options_callback; |
151 | 151 | w->owner = NULL; |
152 | | w->mouse.capture = FALSE; |
153 | 152 | w->mouse.forced_capture = FALSE; |
| 153 | w->mouse.capture = FALSE; |
| 154 | w->mouse.last_msg = 0; |
154 | 155 | w->mouse.last_buttons_down = 0; |
155 | | w->mouse.was_drag = FALSE; |
156 | 156 | |
157 | 157 | /* Almost all widgets want to put the cursor in a suitable place */ |
158 | 158 | w->options = W_WANT_CURSOR; |
diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h
index be524d1..be5f41f 100644
a
|
b
|
struct Widget |
112 | 112 | /* Mouse-related fields. */ |
113 | 113 | struct |
114 | 114 | { |
| 115 | /* Public members: */ |
| 116 | gboolean forced_capture; /* Overrides the 'capture' member. Set explicitly by the programmer. */ |
| 117 | |
| 118 | /* Implementation details: */ |
115 | 119 | 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. */ |
117 | 121 | int last_buttons_down; |
118 | | gboolean was_drag; |
119 | 122 | } mouse; |
120 | 123 | }; |
121 | 124 | |