mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
Merge pull request #1503 from emersion/pointer-frame
pointer: add a frame event
This commit is contained in:
commit
018727b1fc
14 changed files with 111 additions and 22 deletions
|
@ -39,6 +39,7 @@ void handle_pointer_motion(struct libinput_event *event,
|
||||||
wlr_event.unaccel_dx = libinput_event_pointer_get_dx_unaccelerated(pevent);
|
wlr_event.unaccel_dx = libinput_event_pointer_get_dx_unaccelerated(pevent);
|
||||||
wlr_event.unaccel_dy = libinput_event_pointer_get_dy_unaccelerated(pevent);
|
wlr_event.unaccel_dy = libinput_event_pointer_get_dy_unaccelerated(pevent);
|
||||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event);
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event);
|
||||||
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_pointer_motion_abs(struct libinput_event *event,
|
void handle_pointer_motion_abs(struct libinput_event *event,
|
||||||
|
@ -58,6 +59,7 @@ void handle_pointer_motion_abs(struct libinput_event *event,
|
||||||
wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1);
|
wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1);
|
||||||
wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1);
|
wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1);
|
||||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
|
||||||
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_pointer_button(struct libinput_event *event,
|
void handle_pointer_button(struct libinput_event *event,
|
||||||
|
@ -84,6 +86,7 @@ void handle_pointer_button(struct libinput_event *event,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.button, &wlr_event);
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.button, &wlr_event);
|
||||||
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_pointer_axis(struct libinput_event *event,
|
void handle_pointer_axis(struct libinput_event *event,
|
||||||
|
@ -114,13 +117,13 @@ void handle_pointer_axis(struct libinput_event *event,
|
||||||
wlr_event.source = WLR_AXIS_SOURCE_WHEEL_TILT;
|
wlr_event.source = WLR_AXIS_SOURCE_WHEEL_TILT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
enum libinput_pointer_axis axies[] = {
|
const enum libinput_pointer_axis axes[] = {
|
||||||
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
||||||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
||||||
};
|
};
|
||||||
for (size_t i = 0; i < sizeof(axies) / sizeof(axies[0]); ++i) {
|
for (size_t i = 0; i < sizeof(axes) / sizeof(axes[0]); ++i) {
|
||||||
if (libinput_event_pointer_has_axis(pevent, axies[i])) {
|
if (libinput_event_pointer_has_axis(pevent, axes[i])) {
|
||||||
switch (axies[i]) {
|
switch (axes[i]) {
|
||||||
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
||||||
wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL;
|
wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL;
|
||||||
break;
|
break;
|
||||||
|
@ -129,10 +132,11 @@ void handle_pointer_axis(struct libinput_event *event,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wlr_event.delta =
|
wlr_event.delta =
|
||||||
libinput_event_pointer_get_axis_value(pevent, axies[i]);
|
libinput_event_pointer_get_axis_value(pevent, axes[i]);
|
||||||
wlr_event.delta_discrete =
|
wlr_event.delta_discrete =
|
||||||
libinput_event_pointer_get_axis_value_discrete(pevent, axies[i]);
|
libinput_event_pointer_get_axis_value_discrete(pevent, axes[i]);
|
||||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event);
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,16 +67,13 @@ static void registry_global(void *data, struct wl_registry *registry,
|
||||||
if (strcmp(iface, wl_compositor_interface.name) == 0) {
|
if (strcmp(iface, wl_compositor_interface.name) == 0) {
|
||||||
wl->compositor = wl_registry_bind(registry, name,
|
wl->compositor = wl_registry_bind(registry, name,
|
||||||
&wl_compositor_interface, 4);
|
&wl_compositor_interface, 4);
|
||||||
|
|
||||||
} else if (strcmp(iface, wl_seat_interface.name) == 0) {
|
} else if (strcmp(iface, wl_seat_interface.name) == 0) {
|
||||||
wl->seat = wl_registry_bind(registry, name,
|
wl->seat = wl_registry_bind(registry, name,
|
||||||
&wl_seat_interface, 2);
|
&wl_seat_interface, 5);
|
||||||
wl_seat_add_listener(wl->seat, &seat_listener, wl);
|
wl_seat_add_listener(wl->seat, &seat_listener, wl);
|
||||||
|
|
||||||
} else if (strcmp(iface, wl_shm_interface.name) == 0) {
|
} else if (strcmp(iface, wl_shm_interface.name) == 0) {
|
||||||
wl->shm = wl_registry_bind(registry, name,
|
wl->shm = wl_registry_bind(registry, name,
|
||||||
&wl_shm_interface, 1);
|
&wl_shm_interface, 1);
|
||||||
|
|
||||||
} else if (strcmp(iface, xdg_wm_base_interface.name) == 0) {
|
} else if (strcmp(iface, xdg_wm_base_interface.name) == 0) {
|
||||||
wl->xdg_wm_base = wl_registry_bind(registry, name,
|
wl->xdg_wm_base = wl_registry_bind(registry, name,
|
||||||
&xdg_wm_base_interface, 1);
|
&xdg_wm_base_interface, 1);
|
||||||
|
|
|
@ -126,7 +126,14 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) {
|
static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) {
|
||||||
// This space is intentionally left blank
|
struct wlr_wl_backend *backend = data;
|
||||||
|
struct wlr_wl_pointer *pointer = backend->current_pointer;
|
||||||
|
if (pointer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_signal_emit_safe(&pointer->wlr_pointer.events.frame,
|
||||||
|
&pointer->wlr_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_handle_axis_source(void *data,
|
static void pointer_handle_axis_source(void *data,
|
||||||
|
@ -142,7 +149,21 @@ static void pointer_handle_axis_source(void *data,
|
||||||
|
|
||||||
static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
|
static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
|
||||||
uint32_t time, uint32_t axis) {
|
uint32_t time, uint32_t axis) {
|
||||||
// This space is intentionally left blank
|
struct wlr_wl_backend *backend = data;
|
||||||
|
struct wlr_wl_pointer *pointer = backend->current_pointer;
|
||||||
|
if (pointer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_event_pointer_axis event = {
|
||||||
|
.device = &pointer->input_device->wlr_input_device,
|
||||||
|
.delta = 0,
|
||||||
|
.delta_discrete = 0,
|
||||||
|
.orientation = axis,
|
||||||
|
.time_msec = time,
|
||||||
|
.source = pointer->axis_source,
|
||||||
|
};
|
||||||
|
wlr_signal_emit_safe(&pointer->wlr_pointer.events.axis, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_handle_axis_discrete(void *data,
|
static void pointer_handle_axis_discrete(void *data,
|
||||||
|
|
|
@ -50,6 +50,7 @@ static void send_axis_event(struct wlr_x11_output *output, int32_t delta,
|
||||||
.delta_discrete = delta,
|
.delta_discrete = delta,
|
||||||
};
|
};
|
||||||
wlr_signal_emit_safe(&output->pointer.events.axis, &ev);
|
wlr_signal_emit_safe(&output->pointer.events.axis, &ev);
|
||||||
|
wlr_signal_emit_safe(&output->pointer.events.frame, &output->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_pointer_position_event(struct wlr_x11_output *output,
|
static void send_pointer_position_event(struct wlr_x11_output *output,
|
||||||
|
@ -61,6 +62,7 @@ static void send_pointer_position_event(struct wlr_x11_output *output,
|
||||||
.y = (double)y / output->wlr_output.height,
|
.y = (double)y / output->wlr_output.height,
|
||||||
};
|
};
|
||||||
wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &ev);
|
wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &ev);
|
||||||
|
wlr_signal_emit_safe(&output->pointer.events.frame, &output->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_x11_xinput_event(struct wlr_x11_backend *x11,
|
void handle_x11_xinput_event(struct wlr_x11_backend *x11,
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct roots_cursor {
|
||||||
struct wl_listener motion_absolute;
|
struct wl_listener motion_absolute;
|
||||||
struct wl_listener button;
|
struct wl_listener button;
|
||||||
struct wl_listener axis;
|
struct wl_listener axis;
|
||||||
|
struct wl_listener frame;
|
||||||
|
|
||||||
struct wl_listener touch_down;
|
struct wl_listener touch_down;
|
||||||
struct wl_listener touch_up;
|
struct wl_listener touch_up;
|
||||||
|
@ -71,6 +72,8 @@ void roots_cursor_handle_button(struct roots_cursor *cursor,
|
||||||
void roots_cursor_handle_axis(struct roots_cursor *cursor,
|
void roots_cursor_handle_axis(struct roots_cursor *cursor,
|
||||||
struct wlr_event_pointer_axis *event);
|
struct wlr_event_pointer_axis *event);
|
||||||
|
|
||||||
|
void roots_cursor_handle_frame(struct roots_cursor *cursor);
|
||||||
|
|
||||||
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
||||||
struct wlr_event_touch_down *event);
|
struct wlr_event_touch_down *event);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct wlr_cursor {
|
||||||
struct wl_signal motion_absolute;
|
struct wl_signal motion_absolute;
|
||||||
struct wl_signal button;
|
struct wl_signal button;
|
||||||
struct wl_signal axis;
|
struct wl_signal axis;
|
||||||
|
struct wl_signal frame;
|
||||||
|
|
||||||
struct wl_signal touch_up;
|
struct wl_signal touch_up;
|
||||||
struct wl_signal touch_down;
|
struct wl_signal touch_down;
|
||||||
|
|
|
@ -23,6 +23,7 @@ struct wlr_pointer {
|
||||||
struct wl_signal motion_absolute;
|
struct wl_signal motion_absolute;
|
||||||
struct wl_signal button;
|
struct wl_signal button;
|
||||||
struct wl_signal axis;
|
struct wl_signal axis;
|
||||||
|
struct wl_signal frame;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct wlr_pointer_grab_interface {
|
||||||
void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time,
|
void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time,
|
||||||
enum wlr_axis_orientation orientation, double value,
|
enum wlr_axis_orientation orientation, double value,
|
||||||
int32_t value_discrete, enum wlr_axis_source source);
|
int32_t value_discrete, enum wlr_axis_source source);
|
||||||
|
void (*frame)(struct wlr_seat_pointer_grab *grab);
|
||||||
void (*cancel)(struct wlr_seat_pointer_grab *grab);
|
void (*cancel)(struct wlr_seat_pointer_grab *grab);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -348,6 +349,13 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
enum wlr_axis_orientation orientation, double value,
|
enum wlr_axis_orientation orientation, double value,
|
||||||
int32_t value_discrete, enum wlr_axis_source source);
|
int32_t value_discrete, enum wlr_axis_source source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a frame event to the surface with pointer focus. Compositors should use
|
||||||
|
* `wlr_seat_pointer_notify_frame()` to send axis events to respect pointer
|
||||||
|
* grabs.
|
||||||
|
*/
|
||||||
|
void wlr_seat_pointer_send_frame(struct wlr_seat *wlr_seat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a grab of the pointer of this seat. The grabber is responsible for
|
* Start a grab of the pointer of this seat. The grabber is responsible for
|
||||||
* handling all pointer events until the grab ends.
|
* handling all pointer events until the grab ends.
|
||||||
|
@ -390,6 +398,13 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
enum wlr_axis_orientation orientation, double value,
|
enum wlr_axis_orientation orientation, double value,
|
||||||
int32_t value_discrete, enum wlr_axis_source source);
|
int32_t value_discrete, enum wlr_axis_source source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the seat of a frame event. Frame events are sent to end a group of
|
||||||
|
* events that logically belong together. Motion, button and axis events should
|
||||||
|
* all be followed by a frame event.
|
||||||
|
*/
|
||||||
|
void wlr_seat_pointer_notify_frame(struct wlr_seat *wlr_seat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the pointer has a grab other than the default grab.
|
* Whether or not the pointer has a grab other than the default grab.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -386,6 +386,10 @@ void roots_cursor_handle_axis(struct roots_cursor *cursor,
|
||||||
event->orientation, event->delta, event->delta_discrete, event->source);
|
event->orientation, event->delta, event->delta_discrete, event->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void roots_cursor_handle_frame(struct roots_cursor *cursor) {
|
||||||
|
wlr_seat_pointer_notify_frame(cursor->seat->seat);
|
||||||
|
}
|
||||||
|
|
||||||
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
||||||
struct wlr_event_touch_down *event) {
|
struct wlr_event_touch_down *event) {
|
||||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||||
|
|
|
@ -77,6 +77,14 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
||||||
roots_cursor_handle_axis(cursor, event);
|
roots_cursor_handle_axis(cursor, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_cursor_frame(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, frame);
|
||||||
|
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||||
|
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||||
|
roots_cursor_handle_frame(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_switch_toggle(struct wl_listener *listener, void *data) {
|
static void handle_switch_toggle(struct wl_listener *listener, void *data) {
|
||||||
struct roots_switch *lid_switch =
|
struct roots_switch *lid_switch =
|
||||||
wl_container_of(listener, lid_switch, toggle);
|
wl_container_of(listener, lid_switch, toggle);
|
||||||
|
@ -443,6 +451,9 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
||||||
wl_signal_add(&wlr_cursor->events.axis, &seat->cursor->axis);
|
wl_signal_add(&wlr_cursor->events.axis, &seat->cursor->axis);
|
||||||
seat->cursor->axis.notify = handle_cursor_axis;
|
seat->cursor->axis.notify = handle_cursor_axis;
|
||||||
|
|
||||||
|
wl_signal_add(&wlr_cursor->events.frame, &seat->cursor->frame);
|
||||||
|
seat->cursor->frame.notify = handle_cursor_frame;
|
||||||
|
|
||||||
wl_signal_add(&wlr_cursor->events.touch_down, &seat->cursor->touch_down);
|
wl_signal_add(&wlr_cursor->events.touch_down, &seat->cursor->touch_down);
|
||||||
seat->cursor->touch_down.notify = handle_touch_down;
|
seat->cursor->touch_down.notify = handle_touch_down;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,10 @@ static void default_pointer_axis(struct wlr_seat_pointer_grab *grab,
|
||||||
value_discrete, source);
|
value_discrete, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void default_pointer_frame(struct wlr_seat_pointer_grab *grab) {
|
||||||
|
wlr_seat_pointer_send_frame(grab->seat);
|
||||||
|
}
|
||||||
|
|
||||||
static void default_pointer_cancel(struct wlr_seat_pointer_grab *grab) {
|
static void default_pointer_cancel(struct wlr_seat_pointer_grab *grab) {
|
||||||
// cannot be cancelled
|
// cannot be cancelled
|
||||||
}
|
}
|
||||||
|
@ -40,6 +44,7 @@ const struct wlr_pointer_grab_interface default_pointer_grab_impl = {
|
||||||
.motion = default_pointer_motion,
|
.motion = default_pointer_motion,
|
||||||
.button = default_pointer_button,
|
.button = default_pointer_button,
|
||||||
.axis = default_pointer_axis,
|
.axis = default_pointer_axis,
|
||||||
|
.frame = default_pointer_frame,
|
||||||
.cancel = default_pointer_cancel,
|
.cancel = default_pointer_cancel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -212,7 +217,6 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
|
|
||||||
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
|
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
|
||||||
wl_fixed_from_double(sy));
|
wl_fixed_from_double(sy));
|
||||||
pointer_send_frame(resource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +235,6 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_pointer_send_button(resource, serial, time, button, state);
|
wl_pointer_send_button(resource, serial, time, button, state);
|
||||||
pointer_send_frame(resource);
|
|
||||||
}
|
}
|
||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +270,21 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
} else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
|
} else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
|
||||||
wl_pointer_send_axis_stop(resource, time, orientation);
|
wl_pointer_send_axis_stop(resource, time, orientation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_seat_pointer_send_frame(struct wlr_seat *wlr_seat) {
|
||||||
|
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
|
||||||
|
if (client == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wl_resource *resource;
|
||||||
|
wl_resource_for_each(resource, &client->pointers) {
|
||||||
|
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
pointer_send_frame(resource);
|
pointer_send_frame(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,6 +354,14 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
source);
|
source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_seat_pointer_notify_frame(struct wlr_seat *wlr_seat) {
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
||||||
|
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
|
||||||
|
if (grab->interface->frame) {
|
||||||
|
grab->interface->frame(grab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) {
|
bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) {
|
||||||
return seat->pointer_state.grab->interface != &default_pointer_grab_impl;
|
return seat->pointer_state.grab->interface != &default_pointer_grab_impl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct wlr_cursor_device {
|
||||||
struct wl_listener motion_absolute;
|
struct wl_listener motion_absolute;
|
||||||
struct wl_listener button;
|
struct wl_listener button;
|
||||||
struct wl_listener axis;
|
struct wl_listener axis;
|
||||||
|
struct wl_listener frame;
|
||||||
|
|
||||||
struct wl_listener touch_down;
|
struct wl_listener touch_down;
|
||||||
struct wl_listener touch_up;
|
struct wl_listener touch_up;
|
||||||
|
@ -81,6 +82,7 @@ struct wlr_cursor *wlr_cursor_create(void) {
|
||||||
wl_signal_init(&cur->events.motion_absolute);
|
wl_signal_init(&cur->events.motion_absolute);
|
||||||
wl_signal_init(&cur->events.button);
|
wl_signal_init(&cur->events.button);
|
||||||
wl_signal_init(&cur->events.axis);
|
wl_signal_init(&cur->events.axis);
|
||||||
|
wl_signal_init(&cur->events.frame);
|
||||||
|
|
||||||
// touch signals
|
// touch signals
|
||||||
wl_signal_init(&cur->events.touch_up);
|
wl_signal_init(&cur->events.touch_up);
|
||||||
|
@ -133,6 +135,7 @@ static void cursor_device_destroy(struct wlr_cursor_device *c_device) {
|
||||||
wl_list_remove(&c_device->motion_absolute.link);
|
wl_list_remove(&c_device->motion_absolute.link);
|
||||||
wl_list_remove(&c_device->button.link);
|
wl_list_remove(&c_device->button.link);
|
||||||
wl_list_remove(&c_device->axis.link);
|
wl_list_remove(&c_device->axis.link);
|
||||||
|
wl_list_remove(&c_device->frame.link);
|
||||||
} else if (dev->type == WLR_INPUT_DEVICE_TOUCH) {
|
} else if (dev->type == WLR_INPUT_DEVICE_TOUCH) {
|
||||||
wl_list_remove(&c_device->touch_down.link);
|
wl_list_remove(&c_device->touch_down.link);
|
||||||
wl_list_remove(&c_device->touch_up.link);
|
wl_list_remove(&c_device->touch_up.link);
|
||||||
|
@ -415,6 +418,11 @@ static void handle_pointer_axis(struct wl_listener *listener, void *data) {
|
||||||
wlr_signal_emit_safe(&device->cursor->events.axis, event);
|
wlr_signal_emit_safe(&device->cursor->events.axis, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_pointer_frame(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_cursor_device *device = wl_container_of(listener, device, frame);
|
||||||
|
wlr_signal_emit_safe(&device->cursor->events.frame, device->cursor);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_touch_up(struct wl_listener *listener, void *data) {
|
static void handle_touch_up(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_event_touch_up *event = data;
|
struct wlr_event_touch_up *event = data;
|
||||||
struct wlr_cursor_device *device;
|
struct wlr_cursor_device *device;
|
||||||
|
@ -538,6 +546,9 @@ static struct wlr_cursor_device *cursor_device_create(
|
||||||
|
|
||||||
wl_signal_add(&device->pointer->events.axis, &c_device->axis);
|
wl_signal_add(&device->pointer->events.axis, &c_device->axis);
|
||||||
c_device->axis.notify = handle_pointer_axis;
|
c_device->axis.notify = handle_pointer_axis;
|
||||||
|
|
||||||
|
wl_signal_add(&device->pointer->events.frame, &c_device->frame);
|
||||||
|
c_device->frame.notify = handle_pointer_frame;
|
||||||
} else if (device->type == WLR_INPUT_DEVICE_TOUCH) {
|
} else if (device->type == WLR_INPUT_DEVICE_TOUCH) {
|
||||||
wl_signal_add(&device->touch->events.motion, &c_device->touch_motion);
|
wl_signal_add(&device->touch->events.motion, &c_device->touch_motion);
|
||||||
c_device->touch_motion.notify = handle_touch_motion;
|
c_device->touch_motion.notify = handle_touch_motion;
|
||||||
|
|
|
@ -11,6 +11,7 @@ void wlr_pointer_init(struct wlr_pointer *pointer,
|
||||||
wl_signal_init(&pointer->events.motion_absolute);
|
wl_signal_init(&pointer->events.motion_absolute);
|
||||||
wl_signal_init(&pointer->events.button);
|
wl_signal_init(&pointer->events.button);
|
||||||
wl_signal_init(&pointer->events.axis);
|
wl_signal_init(&pointer->events.axis);
|
||||||
|
wl_signal_init(&pointer->events.frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_pointer_destroy(struct wlr_pointer *pointer) {
|
void wlr_pointer_destroy(struct wlr_pointer *pointer) {
|
||||||
|
@ -20,10 +21,6 @@ void wlr_pointer_destroy(struct wlr_pointer *pointer) {
|
||||||
if (pointer->impl && pointer->impl->destroy) {
|
if (pointer->impl && pointer->impl->destroy) {
|
||||||
pointer->impl->destroy(pointer);
|
pointer->impl->destroy(pointer);
|
||||||
} else {
|
} else {
|
||||||
wl_list_remove(&pointer->events.motion.listener_list);
|
|
||||||
wl_list_remove(&pointer->events.motion_absolute.listener_list);
|
|
||||||
wl_list_remove(&pointer->events.button.listener_list);
|
|
||||||
wl_list_remove(&pointer->events.axis.listener_list);
|
|
||||||
free(pointer);
|
free(pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,9 +271,5 @@ void wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||||
(uint32_t)(time_msec >> 32), (uint32_t)time_msec,
|
(uint32_t)(time_msec >> 32), (uint32_t)time_msec,
|
||||||
wl_fixed_from_double(dx), wl_fixed_from_double(dy),
|
wl_fixed_from_double(dx), wl_fixed_from_double(dy),
|
||||||
wl_fixed_from_double(dx_unaccel), wl_fixed_from_double(dy_unaccel));
|
wl_fixed_from_double(dx_unaccel), wl_fixed_from_double(dy_unaccel));
|
||||||
uint32_t version = wl_resource_get_version(pointer->resource);
|
|
||||||
if (version >= WL_POINTER_FRAME_SINCE_VERSION) {
|
|
||||||
wl_pointer_send_frame(pointer->pointer_resource);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue