mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
Fix pointer example for wayland backend
This commit is contained in:
parent
4ca872c914
commit
a9547af358
3 changed files with 22 additions and 1 deletions
|
@ -54,6 +54,13 @@ static void handle_pointer_motion(struct pointer_state *pstate,
|
||||||
state->cur_y += d_y;
|
state->cur_y += d_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_pointer_motion_absolute(struct pointer_state *pstate,
|
||||||
|
double x, double y) {
|
||||||
|
struct sample_state *state = pstate->compositor->data;
|
||||||
|
state->cur_x = x;
|
||||||
|
state->cur_y = y;
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_pointer_button(struct pointer_state *pstate,
|
static void handle_pointer_button(struct pointer_state *pstate,
|
||||||
uint32_t button, enum wlr_button_state state) {
|
uint32_t button, enum wlr_button_state state) {
|
||||||
struct sample_state *sample = pstate->compositor->data;
|
struct sample_state *sample = pstate->compositor->data;
|
||||||
|
@ -109,6 +116,7 @@ int main(int argc, char *argv[]) {
|
||||||
compositor.output_add_cb = handle_output_add;
|
compositor.output_add_cb = handle_output_add;
|
||||||
compositor.output_frame_cb = handle_output_frame;
|
compositor.output_frame_cb = handle_output_frame;
|
||||||
compositor.pointer_motion_cb = handle_pointer_motion;
|
compositor.pointer_motion_cb = handle_pointer_motion;
|
||||||
|
compositor.pointer_motion_absolute_cb = handle_pointer_motion_absolute;
|
||||||
compositor.pointer_button_cb = handle_pointer_button;
|
compositor.pointer_button_cb = handle_pointer_button;
|
||||||
compositor.pointer_axis_cb = handle_pointer_axis;
|
compositor.pointer_axis_cb = handle_pointer_axis;
|
||||||
compositor_init(&compositor);
|
compositor_init(&compositor);
|
||||||
|
|
|
@ -105,6 +105,15 @@ static void pointer_motion_notify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pointer_motion_absolute_notify(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_event_pointer_motion_absolute *event = data;
|
||||||
|
struct pointer_state *pstate = wl_container_of(listener, pstate, motion_absolute);
|
||||||
|
if (pstate->compositor->pointer_motion_absolute_cb) {
|
||||||
|
pstate->compositor->pointer_motion_absolute_cb(pstate,
|
||||||
|
event->x_mm, event->y_mm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void pointer_button_notify(struct wl_listener *listener, void *data) {
|
static void pointer_button_notify(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_event_pointer_button *event = data;
|
struct wlr_event_pointer_button *event = data;
|
||||||
struct pointer_state *pstate = wl_container_of(listener, pstate, button);
|
struct pointer_state *pstate = wl_container_of(listener, pstate, button);
|
||||||
|
@ -132,9 +141,11 @@ static void pointer_add(struct wlr_input_device *device, struct compositor_state
|
||||||
wl_list_init(&pstate->button.link);
|
wl_list_init(&pstate->button.link);
|
||||||
wl_list_init(&pstate->axis.link);
|
wl_list_init(&pstate->axis.link);
|
||||||
pstate->motion.notify = pointer_motion_notify;
|
pstate->motion.notify = pointer_motion_notify;
|
||||||
|
pstate->motion_absolute.notify = pointer_motion_absolute_notify;
|
||||||
pstate->button.notify = pointer_button_notify;
|
pstate->button.notify = pointer_button_notify;
|
||||||
pstate->axis.notify = pointer_axis_notify;
|
pstate->axis.notify = pointer_axis_notify;
|
||||||
wl_signal_add(&device->pointer->events.motion, &pstate->motion);
|
wl_signal_add(&device->pointer->events.motion, &pstate->motion);
|
||||||
|
wl_signal_add(&device->pointer->events.motion_absolute, &pstate->motion_absolute);
|
||||||
wl_signal_add(&device->pointer->events.button, &pstate->button);
|
wl_signal_add(&device->pointer->events.button, &pstate->button);
|
||||||
wl_signal_add(&device->pointer->events.axis, &pstate->axis);
|
wl_signal_add(&device->pointer->events.axis, &pstate->axis);
|
||||||
wl_list_insert(&state->pointers, &pstate->link);
|
wl_list_insert(&state->pointers, &pstate->link);
|
||||||
|
@ -308,7 +319,7 @@ static void pointer_remove(struct wlr_input_device *device, struct compositor_st
|
||||||
}
|
}
|
||||||
wl_list_remove(&pstate->link);
|
wl_list_remove(&pstate->link);
|
||||||
wl_list_remove(&pstate->motion.link);
|
wl_list_remove(&pstate->motion.link);
|
||||||
//wl_list_remove(&pstate->motion_absolute.link);
|
wl_list_remove(&pstate->motion_absolute.link);
|
||||||
wl_list_remove(&pstate->button.link);
|
wl_list_remove(&pstate->button.link);
|
||||||
wl_list_remove(&pstate->axis.link);
|
wl_list_remove(&pstate->axis.link);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ struct compositor_state {
|
||||||
enum wlr_key_state key_state);
|
enum wlr_key_state key_state);
|
||||||
void (*pointer_motion_cb)(struct pointer_state *s,
|
void (*pointer_motion_cb)(struct pointer_state *s,
|
||||||
double d_x, double d_y);
|
double d_x, double d_y);
|
||||||
|
void (*pointer_motion_absolute_cb)(struct pointer_state *s,
|
||||||
|
double x, double y);
|
||||||
void (*pointer_button_cb)(struct pointer_state *s,
|
void (*pointer_button_cb)(struct pointer_state *s,
|
||||||
uint32_t button, enum wlr_button_state state);
|
uint32_t button, enum wlr_button_state state);
|
||||||
void (*pointer_axis_cb)(struct pointer_state *s,
|
void (*pointer_axis_cb)(struct pointer_state *s,
|
||||||
|
|
Loading…
Reference in a new issue