mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
Wire up pointer, start on cursor
This commit is contained in:
parent
0699aa62d8
commit
7523de7c61
5 changed files with 80 additions and 8 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <wlr/xcursor.h>
|
||||
#include "rootston/config.h"
|
||||
#include "rootston/view.h"
|
||||
#include "rootston/server.h"
|
||||
|
||||
struct roots_keyboard {
|
||||
struct roots_input *input;
|
||||
|
@ -94,4 +95,6 @@ struct roots_input *input_create(struct roots_server *server,
|
|||
struct roots_config *config);
|
||||
void input_destroy(struct roots_input *input);
|
||||
|
||||
void pointer_add(struct wlr_input_device *device, struct roots_input *input);
|
||||
|
||||
#endif
|
||||
|
|
28
rootston/cursor.c
Normal file
28
rootston/cursor.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||
/*
|
||||
if (input->motion_context.surface) {
|
||||
struct example_xdg_surface_v6 *surface;
|
||||
surface = sample->motion_context.surface;
|
||||
surface->position.lx = sample->cursor->x - sample->motion_context.off_x;
|
||||
surface->position.ly = sample->cursor->y - sample->motion_context.off_y;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
struct wlr_xdg_surface_v6 *surface = example_xdg_surface_at(sample,
|
||||
sample->cursor->x, sample->cursor->y);
|
||||
|
||||
if (surface) {
|
||||
struct example_xdg_surface_v6 *esurface = surface->data;
|
||||
|
||||
double sx = sample->cursor->x - esurface->position.lx;
|
||||
double sy = sample->cursor->y - esurface->position.ly;
|
||||
|
||||
// TODO z-order
|
||||
wlr_seat_pointer_enter(sample->wl_seat, surface->surface, sx, sy);
|
||||
wlr_seat_pointer_send_motion(sample->wl_seat, time, sx, sy);
|
||||
} else {
|
||||
wlr_seat_pointer_clear_focus(sample->wl_seat);
|
||||
}
|
||||
}
|
|
@ -31,16 +31,16 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
|
|||
device->vendor, device->product, device_type(device->type));
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
//keyboard_add(device, state);
|
||||
//keyboard_add(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
//pointer_add(device, state);
|
||||
pointer_add(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
//touch_add(device, state);
|
||||
//touch_add(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
//tablet_tool_add(device, state);
|
||||
//tablet_tool_add(device, input);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -52,16 +52,16 @@ static void input_remove_notify(struct wl_listener *listener, void *data) {
|
|||
struct roots_input *input = wl_container_of(listener, input, input_remove);
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
//keyboard_remove(device, state);
|
||||
//keyboard_remove(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
//pointer_remove(device, state);
|
||||
//pointer_remove(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
//touch_remove(device, state);
|
||||
//touch_remove(device, input);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
//tablet_tool_remove(device, state);
|
||||
//tablet_tool_remove(device, input);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -6,5 +6,6 @@ executable(
|
|||
'input.c',
|
||||
'main.c',
|
||||
'output.c',
|
||||
'pointer.c'
|
||||
], dependencies: wlroots
|
||||
)
|
||||
|
|
40
rootston/pointer.c
Normal file
40
rootston/pointer.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "rootston/input.h"
|
||||
|
||||
static void pointer_motion_notify(struct wl_listener *listener, void *data) {
|
||||
//struct wlr_event_pointer_motion *event = data;
|
||||
struct roots_pointer *pointer = wl_container_of(listener, pointer, motion);
|
||||
}
|
||||
|
||||
static void pointer_motion_absolute_notify(struct wl_listener *listener, void *data) {
|
||||
//struct wlr_event_pointer_motion *event = data;
|
||||
struct roots_pointer *pointer = wl_container_of(listener, pointer, motion_absolute);
|
||||
}
|
||||
|
||||
void pointer_add(struct wlr_input_device *device, struct roots_input *input) {
|
||||
struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1);
|
||||
pointer->device = device;
|
||||
pointer->input = input;
|
||||
wl_list_init(&pointer->motion.link);
|
||||
wl_list_init(&pointer->motion_absolute.link);
|
||||
wl_list_init(&pointer->button.link);
|
||||
wl_list_init(&pointer->axis.link);
|
||||
pointer->motion.notify = pointer_motion_notify;
|
||||
pointer->motion_absolute.notify = pointer_motion_absolute_notify;
|
||||
//pointer->button.notify = pointer_button_notify;
|
||||
//pointer->axis.notify = pointer_axis_notify;
|
||||
wl_signal_add(&device->pointer->events.motion, &pointer->motion);
|
||||
wl_signal_add(&device->pointer->events.motion_absolute, &pointer->motion_absolute);
|
||||
wl_signal_add(&device->pointer->events.button, &pointer->button);
|
||||
wl_signal_add(&device->pointer->events.axis, &pointer->axis);
|
||||
wl_list_insert(&input->pointers, &pointer->link);
|
||||
|
||||
wlr_cursor_attach_input_device(input->cursor, device);
|
||||
// TODO: rootston/cursor.c
|
||||
//example_config_configure_cursor(sample->config, sample->cursor,
|
||||
// sample->compositor);
|
||||
}
|
Loading…
Reference in a new issue