From cecab625acd09c9e648e75ab048c2e17fe0e312f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 29 Dec 2018 14:40:45 +0100 Subject: [PATCH] particle: implement a default on_mouse handler Which changes the cursor to a hand when there's a non-NULL on-click handler. --- particle.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/particle.c b/particle.c index e00827e..987fe1e 100644 --- a/particle.c +++ b/particle.c @@ -2,6 +2,12 @@ #include #include +#include + +#define LOG_MODULE "particle" +#define LOG_ENABLE_DBG 1 +#include "log.h" +#include "bar.h" void particle_default_destroy(struct particle *particle) @@ -45,3 +51,18 @@ exposable_default_destroy(struct exposable *exposable) free(exposable->on_click); free(exposable); } + +void +exposable_default_on_mouse(struct exposable *exposable, struct bar *bar, + enum mouse_event event, int x, int y) +{ + LOG_DBG("on_mouse: exposable=%p, event=%s, x=%d, y=%d", exposable, + event == ON_MOUSE_MOTION ? "motion" : "click", x, y); + + assert(exposable->particle != NULL); + + if (exposable->on_click == NULL) + bar->set_cursor(bar, "left_ptr"); + else + bar->set_cursor(bar, "hand2"); +}