mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-25 08:56:37 -05:00
types/wlr_pointer: add base wlr_input_device
wlr_pointer owns its wlr_input_device. It will be initialized when the pointer is initialized, and finished when the pointer is destroyed.
This commit is contained in:
parent
a1978b1299
commit
d5480efc7a
10 changed files with 53 additions and 51 deletions
|
|
@ -33,7 +33,7 @@ static void send_key_event(struct wlr_x11_backend *x11, uint32_t key,
|
|||
static void send_button_event(struct wlr_x11_output *output, uint32_t key,
|
||||
enum wlr_button_state st, xcb_timestamp_t time) {
|
||||
struct wlr_event_pointer_button ev = {
|
||||
.device = &output->pointer_dev,
|
||||
.device = &output->pointer.base,
|
||||
.time_msec = time,
|
||||
.button = key,
|
||||
.state = st,
|
||||
|
|
@ -45,7 +45,7 @@ static void send_button_event(struct wlr_x11_output *output, uint32_t key,
|
|||
static void send_axis_event(struct wlr_x11_output *output, int32_t delta,
|
||||
xcb_timestamp_t time) {
|
||||
struct wlr_event_pointer_axis ev = {
|
||||
.device = &output->pointer_dev,
|
||||
.device = &output->pointer.base,
|
||||
.time_msec = time,
|
||||
.source = WLR_AXIS_SOURCE_WHEEL,
|
||||
.orientation = WLR_AXIS_ORIENTATION_VERTICAL,
|
||||
|
|
@ -60,7 +60,7 @@ static void send_axis_event(struct wlr_x11_output *output, int32_t delta,
|
|||
static void send_pointer_position_event(struct wlr_x11_output *output,
|
||||
int16_t x, int16_t y, xcb_timestamp_t time) {
|
||||
struct wlr_event_pointer_motion_absolute ev = {
|
||||
.device = &output->pointer_dev,
|
||||
.device = &output->pointer.base,
|
||||
.time_msec = time,
|
||||
.x = (double)x / output->wlr_output.width,
|
||||
.y = (double)y / output->wlr_output.height,
|
||||
|
|
@ -339,6 +339,8 @@ bool wlr_input_device_is_x11(struct wlr_input_device *wlr_dev) {
|
|||
switch (wlr_dev->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
return wlr_dev->keyboard->impl == &keyboard_impl;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
return wlr_dev->pointer->impl == &pointer_impl;
|
||||
default:
|
||||
return wlr_dev->impl == &input_device_impl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
|||
|
||||
pixman_region32_fini(&output->exposed);
|
||||
|
||||
wlr_input_device_destroy(&output->pointer_dev);
|
||||
wlr_pointer_destroy(&output->pointer);
|
||||
wlr_input_device_destroy(&output->touch_dev);
|
||||
|
||||
struct wlr_x11_buffer *buffer, *buffer_tmp;
|
||||
|
|
@ -573,11 +573,8 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
|||
|
||||
wlr_output_update_enabled(wlr_output, true);
|
||||
|
||||
wlr_input_device_init(&output->pointer_dev, WLR_INPUT_DEVICE_POINTER,
|
||||
&input_device_impl, "X11 pointer");
|
||||
wlr_pointer_init(&output->pointer, &pointer_impl);
|
||||
output->pointer_dev.pointer = &output->pointer;
|
||||
output->pointer_dev.output_name = strdup(wlr_output->name);
|
||||
wlr_pointer_init(&output->pointer, &pointer_impl, "x11-pointer");
|
||||
output->pointer.base.output_name = strdup(wlr_output->name);
|
||||
|
||||
wlr_input_device_init(&output->touch_dev, WLR_INPUT_DEVICE_TOUCH,
|
||||
&input_device_impl, "X11 touch");
|
||||
|
|
@ -587,7 +584,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
|||
wl_list_init(&output->touchpoints);
|
||||
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_output, wlr_output);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_input, &output->pointer_dev);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_input, &output->pointer.base);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_input, &output->touch_dev);
|
||||
|
||||
// Start the rendering loop by requesting the compositor to render a frame
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue