diff options
Diffstat (limited to 'src/connect.c')
| -rw-r--r-- | src/connect.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/connect.c b/src/connect.c index b3e4e92..12038a4 100644 --- a/src/connect.c +++ b/src/connect.c @@ -77,25 +77,21 @@ static inline bool in_capsule(int px, int py, int x, int y, int w, int h) || in_rect(px, py, x + radius, y, w - 2 * radius, h); } -static void button_action(State *state, xcb_button_release_event_t *button) +static void button_action(State *state, const char *event, int x, int y) { - log_debug("Button release event [x=%d, y=%d]", button->event_x, button->event_y); + log_debug("Checking %s event [x=%d, y=%d]", event, x, y); for (GList *it = state->draw->layouts; it != NULL; it = it->next) { Layout *layout = it->data; // Skip - if (layout->x + layout->width < button->event_x) continue; - if (layout->x > button->event_x) break; - - bool check = in_capsule(button->event_x, button->event_y, - layout->x, layout->y, - layout->width, layout->height); + if (layout->x + layout->width < x) continue; + if (layout->x > x) break; log_debug("Button layout [x=%d, y=%d, w=%d, h=%d]", layout->x, layout->y, layout->width, layout->height); - if (check) { + if (in_capsule(x, y, layout->x, layout->y, layout->width, layout->height)) { log_debug("Triggering action for button"); if (layout->btn->action != NULL) { layout->btn->action(layout->btn); @@ -104,7 +100,7 @@ static void button_action(State *state, xcb_button_release_event_t *button) } } - log_debug("Ignoring button release"); + log_debug("Ignoring %s", event); } typedef struct { @@ -181,7 +177,7 @@ static gboolean source_dispatch(GSource *source, GSourceFunc callback, gpointer case XCB_BUTTON_INDEX_2: // left click case XCB_BUTTON_INDEX_1: // right click case XCB_BUTTON_INDEX_3: // middle click - button_action(xsource->con->state, button); + button_action(xsource->con->state, "button release", button->event_x, button->event_y); break; default: @@ -191,6 +187,14 @@ static gboolean source_dispatch(GSource *source, GSourceFunc callback, gpointer break; } + // TODO: Implement correctly hovering + case XCB_MOTION_NOTIFY: { + xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *)xsource->event; + log_debug("Processing event 'MotionNotify' [type=%d]", XCB_MOTION_NOTIFY); + button_action(xsource->con->state, "motion notify", motion->event_x, motion->event_y); + break; + } + case XCB_PROPERTY_NOTIFY: { xcb_property_notify_event_t *property = (xcb_property_notify_event_t *)xsource->event; log_debug("Processing event 'PropertyNotify' [type=%d]", XCB_PROPERTY_NOTIFY); |
