-}
-
-static button_t *get_button_at(int16_t x, int16_t y) {
- for (int c = 0; c < buttoncnt; c++)
- if (x >= (buttons[c].x) && x <= (buttons[c].x + buttons[c].width))
- return &buttons[c];
-
- return NULL;
-}
-
-static void handle_button_press(xcb_connection_t *conn, xcb_button_press_event_t *event) {
- printf("button pressed on x = %d, y = %d\n",
- event->event_x, event->event_y);
- /* TODO: set a flag for the button, re-render */
-}
-
-/*
- * Called when the user releases the mouse button. Checks whether the
- * coordinates are over a button and executes the appropriate action.
- *
- */
-static void handle_button_release(xcb_connection_t *conn, xcb_button_release_event_t *event) {
- printf("button released on x = %d, y = %d\n",
- event->event_x, event->event_y);
- /* If the user hits the close button, we exit(0) */
- if (event->event_x >= btn_close.x && event->event_x < btn_close.x + btn_close.width)
- exit(0);
- button_t *button = get_button_at(event->event_x, event->event_y);
- if (!button) {
- return;
- }
-
- if (button->exec_in_terminal) {
- execute_in_terminal(button->action);
- } else {
- start_application(button->action);
- }