summaryrefslogtreecommitdiff
path: root/gui/input.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-18 04:34:51 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-18 04:34:51 -0300
commitaa9fc0277527a0a0d291dfc2ce9b569baa3fc5e8 (patch)
treefb900d9f6ddbd8d55a51923d83f634def409384a /gui/input.c
parent202e32778a5f4e64bc57da837310be146988c85b (diff)
downloadeeshow-aa9fc0277527a0a0d291dfc2ce9b569baa3fc5e8.tar.gz
eeshow-aa9fc0277527a0a0d291dfc2ce9b569baa3fc5e8.tar.bz2
eeshow-aa9fc0277527a0a0d291dfc2ce9b569baa3fc5e8.zip
eeshow/gui/input.c: add tracing (-v -v -v); rename input_normal to input_idle
Diffstat (limited to 'gui/input.c')
-rw-r--r--gui/input.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/gui/input.c b/gui/input.c
index d900310..eb9309d 100644
--- a/gui/input.c
+++ b/gui/input.c
@@ -18,6 +18,7 @@
#include <gtk/gtk.h>
#include "misc/util.h"
+#include "misc/diag.h"
#include "gui/input.h"
@@ -29,7 +30,7 @@ static struct input {
void *user;
enum state {
- input_normal,
+ input_idle,
input_clicking,
input_ignoring, /* click rejected by moving the cursor */
input_hovering,
@@ -43,6 +44,28 @@ static int curr_x, curr_y; /* last mouse position */
static int clicked_x, clicked_y; /* button down position */
+/* ----- Debugging tools --------------------------------------------------- */
+
+
+static const char *state(void)
+{
+ switch (sp->state) {
+ case input_idle:
+ return "IDLE";
+ case input_clicking:
+ return "CLICKING";
+ case input_ignoring:
+ return "IGNORING";
+ case input_hovering:
+ return "HOVERING";
+ case input_dragging:
+ return "DRAGGING";
+ default:
+ abort();
+ }
+}
+
+
/* ----- Mouse button ------------------------------------------------------ */
@@ -57,8 +80,10 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
if (!sp)
return TRUE;
+ progress(3, "motion %s\n", state());
+
switch (sp->state) {
- case input_normal:
+ case input_idle:
if (sp->ops->hover_begin &&
sp->ops->hover_begin(sp->user, event->x, event->y))
sp->state = input_hovering;
@@ -84,7 +109,7 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
/* Caution: hover_update may switch input layers */
if (sp->ops->hover_update(sp->user, event->x, event->y) &&
sp == old_sp) {
- sp->state = input_normal;
+ sp->state = input_idle;
if (sp->ops->hover_end)
sp->ops->hover_end(sp->user);
}
@@ -111,8 +136,10 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
if (event->button != 1)
return TRUE;
+ progress(3, "press %s\n", state());
+
switch (sp->state) {
- case input_normal:
+ case input_idle:
sp->state = input_clicking;
clicked_x = event->x;
clicked_y = event->y;
@@ -145,20 +172,22 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
if (event->button != 1)
return TRUE;
+ progress(3, "release %s\n", state());
+
switch (sp->state) {
- case input_normal:
+ case input_idle:
/* hover_click changed the input configuration */
break;
case input_clicking:
- sp->state = input_normal;
+ sp->state = input_idle;
if (sp->ops->click)
sp->ops->click(sp->user, clicked_x, clicked_y);
break;
case input_ignoring:
- sp->state = input_normal;
+ sp->state = input_idle;
break;
case input_dragging:
- sp->state = input_normal;
+ sp->state = input_idle;
if (sp->ops->drag_end)
sp->ops->drag_end(sp->user);
break;
@@ -247,7 +276,7 @@ void input_push(const struct input_ops *ops, void *user)
new = alloc_type(struct input);
new->ops = ops;
new->user = user;
- new->state = input_normal;
+ new->state = input_idle;
new->next = sp;
sp = new;
}