81 lines
2.6 KiB
C
81 lines
2.6 KiB
C
#include <stdio.h>
|
|
|
|
#include <tpointer.h>
|
|
|
|
static void pointer_enter_handler(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
|
|
{
|
|
// not implemented
|
|
printf("pointer_enter\n");
|
|
struct pointer_data *pointer_data = data;
|
|
|
|
wl_pointer_set_cursor(pointer, serial, pointer_data->cursor_surface,
|
|
pointer_data->cursor_image->hotspot_x, pointer_data->cursor_image->hotspot_y);
|
|
printf("pointer_enter - end\n");
|
|
}
|
|
|
|
static void pointer_leave_handler(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface)
|
|
{
|
|
// not implemented
|
|
printf("pointer_leave\n");
|
|
}
|
|
|
|
static void pointer_motion_handler(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_button_handler(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_axis_handler(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_frame_handler(void *data, struct wl_pointer *pointer)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_axis_source_handler(void *data, struct wl_pointer *pointer, uint32_t axis_source)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_axis_discrete_handler(void *data, struct wl_pointer *pointer, uint32_t axis, int32_t discrete)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
static void pointer_axis_stop_handler(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
const struct wl_pointer_listener pointer_listener = {
|
|
.enter = pointer_enter_handler,
|
|
.leave = pointer_leave_handler,
|
|
.motion = pointer_motion_handler,
|
|
.button = pointer_button_handler,
|
|
.axis = pointer_axis_handler,
|
|
.frame = pointer_frame_handler,
|
|
.axis_source = pointer_axis_source_handler,
|
|
.axis_discrete = pointer_axis_discrete_handler,
|
|
.axis_stop = pointer_axis_stop_handler,
|
|
};
|
|
|
|
void pointer_init_cursor(struct pointer_data *pointer_data, struct wl_compositor *compositor, struct wl_shm *shm)
|
|
{
|
|
pointer_data->cursor_theme =
|
|
wl_cursor_theme_load(NULL, 24, shm);
|
|
pointer_data->cursor = wl_cursor_theme_get_cursor(pointer_data->cursor_theme, "left_ptr");
|
|
pointer_data->cursor_image = pointer_data->cursor->images[0];
|
|
pointer_data->cursor_buffer = wl_cursor_image_get_buffer(pointer_data->cursor_image);
|
|
|
|
pointer_data->cursor_surface = wl_compositor_create_surface(compositor);
|
|
wl_surface_attach(pointer_data->cursor_surface, pointer_data->cursor_buffer, 0, 0);
|
|
wl_surface_commit(pointer_data->cursor_surface);
|
|
}
|