static void handle_pointer_unlocked(struct window *window, struct input *input, void *data) { struct resizor *resizor = data; resizor->pointer_locked = false; input_set_pointer_image(input, CURSOR_LEFT_PTR); }
static void handle_pointer_locked(struct window *window, struct input *input, void *data) { struct resizor *resizor = data; resizor->pointer_locked = true; input_set_pointer_image(input, CURSOR_BLANK); }
static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { struct image *image = data; if (button == BTN_LEFT) { image->button_pressed = state == WL_POINTER_BUTTON_STATE_PRESSED; if (state == WL_POINTER_BUTTON_STATE_PRESSED) input_set_pointer_image(input, CURSOR_DRAGGING); else input_set_pointer_image(input, CURSOR_LEFT_PTR); } }
static void cursor_timeout_func(struct task *task, uint32_t events) { struct clickdot *clickdot = container_of(task, struct clickdot, cursor_timeout_task); uint64_t exp; if (read(clickdot->cursor_timeout_fd, &exp, sizeof (uint64_t)) != sizeof(uint64_t)) abort(); input_set_pointer_image(clickdot->cursor_timeout_input, CURSOR_LEFT_PTR); }
static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { struct resizor *resizor = data; struct rectangle allocation; struct wl_surface *surface; struct wl_callback *callback; if (button == BTN_RIGHT && state == WL_POINTER_BUTTON_STATE_PRESSED) { show_menu(resizor, input, time); } else if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) { window_get_allocation(resizor->window, &allocation); resizor->width.current = allocation.width; resizor->width.previous = allocation.width; resizor->width.target = allocation.width; resizor->height.current = allocation.height; resizor->height.previous = allocation.height; resizor->height.target = allocation.height; window_lock_pointer(resizor->window, input); window_set_pointer_locked_handler(resizor->window, handle_pointer_locked, handle_pointer_unlocked); resizor->locked_input = input; if (resizor->locked_frame_callback_registered) return; surface = window_get_wl_surface(resizor->window); callback = wl_surface_frame(surface); wl_callback_add_listener(callback, &locked_pointer_frame_listener, resizor); resizor->locked_frame_callback_registered = true; } else if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_RELEASED) { input_set_pointer_image(input, CURSOR_LEFT_PTR); window_unlock_pointer(resizor->window); } }