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 * |
174 | 174 | |
175 | 175 | /* --------------------------------------------------------------------------------------------- */ |
176 | 176 | |
177 | | static int |
178 | | button_event (Gpm_Event * event, void *data) |
| 177 | static void |
| 178 | button_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) |
179 | 179 | { |
180 | | Widget *w = WIDGET (data); |
| 180 | (void) event; |
181 | 181 | |
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) |
186 | 183 | { |
| 184 | case MSG_MOUSE_DOWN: |
187 | 185 | 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; |
194 | 187 | |
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 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
button_new (int y, int x, int action, button_flags_t flags, const char *text, bc |
211 | 211 | b->action = action; |
212 | 212 | b->flags = flags; |
213 | 213 | 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); |
215 | 216 | b->selected = FALSE; |
216 | 217 | b->callback = callback; |
217 | 218 | widget_want_hotkey (w, TRUE); |