mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-30 00:15:58 +01:00
storage commit #2
This commit is contained in:
parent
4947295c8f
commit
77bac448cc
5 changed files with 138 additions and 188 deletions
|
@ -8,7 +8,60 @@
|
||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
struct wlr_tablet_pad *create_libinput_tablet_pad(
|
static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
|
||||||
|
struct libinput_device *device, unsigned int index) {
|
||||||
|
struct libinput_tablet_pad_mode_group *li_group =
|
||||||
|
libinput_device_tablet_pad_get_mode_group(device, index);
|
||||||
|
struct wlr_tablet_pad_group_v2 *group =
|
||||||
|
calloc(1, sizeof(struct wlr_tablet_pad_group_v2));
|
||||||
|
if (!group) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pad->ring_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
||||||
|
++group->ring_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group->rings = calloc(sizeof(int), group->ring_count);
|
||||||
|
size_t ring = 0;
|
||||||
|
for (size_t i = 0; i < pad->ring_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
||||||
|
group->rings[ring++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pad->strip_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
||||||
|
++group->strip_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group->strips = calloc(sizeof(int), group->strip_count);
|
||||||
|
size_t strip = 0;
|
||||||
|
for (size_t i = 0; i < pad->strip_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
||||||
|
group->strips[strip++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pad->button_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
||||||
|
++group->button_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group->buttons = calloc(sizeof(int), group->button_count);
|
||||||
|
size_t button = 0;
|
||||||
|
for (size_t i = 0; i < pad->button_count; ++i) {
|
||||||
|
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
||||||
|
group->buttons[button++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group->mode_count = libinput_tablet_pad_mode_group_get_num_modes(li_group);
|
||||||
|
wl_list_insert(&pad->groups, &group->link);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_tablet_pad *libinput_tablet_pad_create(
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
assert(libinput_dev);
|
assert(libinput_dev);
|
||||||
struct wlr_tablet_pad *wlr_tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
struct wlr_tablet_pad *wlr_tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
||||||
|
@ -16,6 +69,22 @@ struct wlr_tablet_pad *create_libinput_tablet_pad(
|
||||||
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad");
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_tablet_pad->button_count =
|
||||||
|
libinput_device_tablet_pad_get_num_buttons(libinput_dev);
|
||||||
|
wlr_tablet_pad->ring_count =
|
||||||
|
libinput_device_tablet_pad_get_num_rings(libinput_dev);
|
||||||
|
wlr_tablet_pad->strip_count =
|
||||||
|
libinput_device_tablet_pad_get_num_strips(libinput_dev);
|
||||||
|
|
||||||
|
//struct udev_device *udev = libinput_device_get_udev_device(libinput_dev);
|
||||||
|
//add_tablet_path(&pad->paths, udev_device_get_syspath(udev));
|
||||||
|
|
||||||
|
int groups = libinput_device_tablet_pad_get_num_mode_groups(libinput_dev);
|
||||||
|
for (int i = 0; i < groups; ++i) {
|
||||||
|
add_pad_group_from_libinput(wlr_tablet_pad, libinput_dev, i);
|
||||||
|
}
|
||||||
|
|
||||||
wlr_tablet_pad_init(wlr_tablet_pad, NULL);
|
wlr_tablet_pad_init(wlr_tablet_pad, NULL);
|
||||||
return wlr_tablet_pad;
|
return wlr_tablet_pad;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#ifndef _POSIX_C_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
#endif
|
||||||
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -9,6 +13,18 @@
|
||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
|
//TODO: Move out
|
||||||
|
static void add_tablet_path(struct wl_list *list, const char *path) {
|
||||||
|
struct wlr_tablet_path *tablet_path = calloc(1, sizeof(struct wlr_tablet_path));
|
||||||
|
|
||||||
|
if (!tablet_path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tablet_path->path = strdup(path);
|
||||||
|
wl_list_insert(list, &tablet_path->link);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_libinput_tablet_tool {
|
struct wlr_libinput_tablet_tool {
|
||||||
struct wlr_tablet_tool_tool wlr_tool;
|
struct wlr_tablet_tool_tool wlr_tool;
|
||||||
|
|
||||||
|
@ -59,7 +75,7 @@ void wlr_libinput_tablet_tool_destroy(struct wlr_input_device *wlr_dev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
|
struct wlr_tablet_tool *libinput_tablet_tool_create(
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
assert(libinput_dev);
|
assert(libinput_dev);
|
||||||
struct wlr_tablet_tool *wlr_tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool));
|
struct wlr_tablet_tool *wlr_tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool));
|
||||||
|
@ -67,6 +83,12 @@ struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
|
||||||
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool");
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct udev_device *udev = libinput_device_get_udev_device(libinput_dev);
|
||||||
|
add_tablet_path(&wlr_tablet_tool->paths, udev_device_get_syspath(udev));
|
||||||
|
wlr_tablet_tool->name = strdup(libinput_device_get_name(libinput_dev));
|
||||||
|
|
||||||
|
|
||||||
wlr_tablet_tool_init(wlr_tablet_tool, NULL);
|
wlr_tablet_tool_init(wlr_tablet_tool, NULL);
|
||||||
return wlr_tablet_tool;
|
return wlr_tablet_tool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,31 @@ struct wlr_tablet_pad {
|
||||||
struct wl_signal strip;
|
struct wl_signal strip;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
size_t button_count;
|
||||||
|
size_t ring_count;
|
||||||
|
size_t strip_count;
|
||||||
|
|
||||||
|
struct wl_list groups; // wlr_tablet_pad_group::link
|
||||||
|
struct wl_list paths; // wlr_tablet_path::link
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_tablet_pad_group_v2 {
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
size_t button_count;
|
||||||
|
unsigned int *buttons;
|
||||||
|
|
||||||
|
size_t strip_count;
|
||||||
|
unsigned int *strips;
|
||||||
|
|
||||||
|
size_t ring_count;
|
||||||
|
unsigned int *rings;
|
||||||
|
|
||||||
|
unsigned int mode_count;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_event_tablet_pad_button {
|
struct wlr_event_tablet_pad_button {
|
||||||
uint32_t time_msec;
|
uint32_t time_msec;
|
||||||
uint32_t button;
|
uint32_t button;
|
||||||
|
|
|
@ -42,6 +42,11 @@ struct wlr_tablet_tool_tool {
|
||||||
|
|
||||||
struct wlr_tablet_tool_impl;
|
struct wlr_tablet_tool_impl;
|
||||||
|
|
||||||
|
struct wlr_tablet_path {
|
||||||
|
struct wl_list link;
|
||||||
|
char *path;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_tablet_tool {
|
struct wlr_tablet_tool {
|
||||||
struct wlr_tablet_tool_impl *impl;
|
struct wlr_tablet_tool_impl *impl;
|
||||||
|
|
||||||
|
@ -52,6 +57,9 @@ struct wlr_tablet_tool {
|
||||||
struct wl_signal button;
|
struct wl_signal button;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
const char *name;
|
||||||
|
struct wl_list paths; // wlr_table_path::link
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
struct wlr_tablet_manager_v2 {
|
struct wlr_tablet_manager_v2 {
|
||||||
struct wl_global *wl_global;
|
struct wl_global *wl_global;
|
||||||
struct wl_list tablets; // wlr_tablet_v2::link
|
|
||||||
struct wl_list pads; // wlr_tablet_pad_v2::link
|
|
||||||
struct wl_list clients; // wlr_tablet_manager_client_v2::link
|
struct wl_list clients; // wlr_tablet_manager_client_v2::link
|
||||||
|
|
||||||
struct wl_listener display_destroy;
|
struct wl_listener display_destroy;
|
||||||
|
@ -36,69 +34,44 @@ struct wlr_tablet_manager_client_v2 {
|
||||||
|
|
||||||
struct wlr_tablet_seat_v2 {
|
struct wlr_tablet_seat_v2 {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
struct wl_client *wl_client;
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
struct wlr_tablet_manager_client_v2 *client;
|
struct wlr_tablet_manager_client_v2 *client;
|
||||||
struct wlr_seat_client *seat;
|
struct wlr_seat_client *seat;
|
||||||
|
|
||||||
struct wl_listener seat_destroy;
|
struct wl_listener seat_destroy;
|
||||||
|
struct wl_listener client_destroy;
|
||||||
|
|
||||||
struct wl_list tools;
|
struct wl_list tools;
|
||||||
struct wl_list tablets;
|
struct wl_list tablets;
|
||||||
struct wl_list pads; //wlr_tablet_pad_client_v2::link
|
struct wl_list pads; //wlr_tablet_pad_client_v2::link
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_tablet_v2 {
|
struct wlr_tablet_client_v2 {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list resources;
|
struct wl_client *client;
|
||||||
|
struct wl_resource *resource;
|
||||||
|
|
||||||
char *name;
|
struct wl_listener device_destroy;
|
||||||
struct wl_list paths; // wlr_tablet_path::link
|
struct wl_listener client_destroy;
|
||||||
// USB vendor/product id
|
|
||||||
unsigned int vid;
|
|
||||||
unsigned int pid;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_tablet_pad_v2 {
|
|
||||||
struct wl_list link;
|
|
||||||
struct wl_list resources;
|
|
||||||
|
|
||||||
struct wlr_tablet_v2 *tablet;
|
|
||||||
|
|
||||||
struct wl_list groups; // wlr_tablet_pad_group::link
|
|
||||||
struct wl_list paths; // wlr_tablet_path::link
|
|
||||||
size_t button_count;
|
|
||||||
size_t ring_count;
|
|
||||||
size_t strip_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_tablet_tool_v2 {
|
|
||||||
struct wl_list link;
|
|
||||||
|
|
||||||
enum zwp_tablet_tool_v2_type type;
|
|
||||||
uint64_t hardware_serial;
|
|
||||||
uint64_t hardware_wacom;
|
|
||||||
|
|
||||||
// Capabilities
|
|
||||||
bool tilt;
|
|
||||||
bool pressure;
|
|
||||||
bool distance;
|
|
||||||
bool rotation;
|
|
||||||
bool slider;
|
|
||||||
bool wheel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_tablet_tool_client_v2 {
|
struct wlr_tablet_tool_client_v2 {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
struct wl_client *client;
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
struct wlr_surface *cursor;
|
struct wlr_surface *cursor;
|
||||||
struct wl_listener cursor_destroy;
|
struct wl_listener cursor_destroy;
|
||||||
|
|
||||||
|
struct wl_listener tool_destroy;
|
||||||
|
struct wl_listener client_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_tablet_pad_client_v2 {
|
struct wlr_tablet_pad_client_v2 {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wlr_tablet_pad_v2 *pad;
|
struct wl_client *client;
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
size_t button_count;
|
size_t button_count;
|
||||||
|
@ -108,155 +81,11 @@ struct wlr_tablet_pad_client_v2 {
|
||||||
|
|
||||||
size_t strip_cout;
|
size_t strip_cout;
|
||||||
struct wl_resource **strips;
|
struct wl_resource **strips;
|
||||||
|
|
||||||
|
struct wl_listener device_destroy;
|
||||||
|
struct wl_listener client_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_tablet_pad_group_v2 {
|
|
||||||
struct wl_list link;
|
|
||||||
struct wl_list resources;
|
|
||||||
|
|
||||||
struct wlr_tablet_pad_v2 *pad;
|
|
||||||
|
|
||||||
size_t button_count;
|
|
||||||
unsigned int *buttons;
|
|
||||||
size_t strip_count;
|
|
||||||
unsigned int *strips;
|
|
||||||
size_t ring_count;
|
|
||||||
unsigned int *rings;
|
|
||||||
|
|
||||||
unsigned int mode_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_tablet_path {
|
|
||||||
struct wl_list link;
|
|
||||||
char *path;
|
|
||||||
};
|
|
||||||
|
|
||||||
void add_tablet_path(struct wl_list *list, const char *path) {
|
|
||||||
struct wlr_tablet_path *tablet_path = calloc(1, sizeof(struct wlr_tablet_path));
|
|
||||||
|
|
||||||
if (!tablet_path) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tablet_path->path = strdup(path);
|
|
||||||
wl_list_insert(list, &tablet_path->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wlr_tablet_destroy(struct wlr_tablet_v2 *tablet) {
|
|
||||||
wl_list_remove(&tablet->link);
|
|
||||||
free(tablet->name);
|
|
||||||
|
|
||||||
struct wlr_tablet_path *tmp;
|
|
||||||
struct wlr_tablet_path *pos;
|
|
||||||
wl_list_for_each_safe(pos, tmp, &tablet->paths, link) {
|
|
||||||
free(pos->path);
|
|
||||||
wl_list_remove(&pos->link);
|
|
||||||
free(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(tablet);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void add_pad_group_from_libinput(struct wlr_tablet_pad_v2 *pad,
|
|
||||||
struct libinput_device *device, unsigned int index) {
|
|
||||||
struct libinput_tablet_pad_mode_group *li_group =
|
|
||||||
libinput_device_tablet_pad_get_mode_group(device, index);
|
|
||||||
struct wlr_tablet_pad_group_v2 *group =
|
|
||||||
calloc(1, sizeof(struct wlr_tablet_pad_group_v2));
|
|
||||||
if (!group) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < pad->ring_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
|
||||||
++group->ring_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
group->rings = calloc(sizeof(int), group->ring_count);
|
|
||||||
size_t ring = 0;
|
|
||||||
for (size_t i = 0; i < pad->ring_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
|
||||||
group->rings[ring++] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < pad->strip_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
|
||||||
++group->strip_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
group->strips = calloc(sizeof(int), group->strip_count);
|
|
||||||
size_t strip = 0;
|
|
||||||
for (size_t i = 0; i < pad->strip_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
|
||||||
group->strips[strip++] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < pad->button_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
|
||||||
++group->button_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
group->buttons = calloc(sizeof(int), group->button_count);
|
|
||||||
size_t button = 0;
|
|
||||||
for (size_t i = 0; i < pad->button_count; ++i) {
|
|
||||||
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
|
||||||
group->buttons[button++] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group->mode_count = libinput_tablet_pad_mode_group_get_num_modes(li_group);
|
|
||||||
wl_list_insert(&pad->groups, &group->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_tablet_pad_v2 *tablet_pad_from_libinput(struct wlr_tablet_manager_v2 *manager,
|
|
||||||
struct libinput_device *device) {
|
|
||||||
struct wlr_tablet_pad_v2 *pad = calloc(1, sizeof(struct wlr_tablet_pad_v2));
|
|
||||||
if (!pad) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pad->button_count = libinput_device_tablet_pad_get_num_buttons(device);
|
|
||||||
pad->ring_count = libinput_device_tablet_pad_get_num_rings(device);
|
|
||||||
pad->strip_count = libinput_device_tablet_pad_get_num_strips(device);
|
|
||||||
|
|
||||||
struct udev_device *udev = libinput_device_get_udev_device(device);
|
|
||||||
add_tablet_path(&pad->paths, udev_device_get_syspath(udev));
|
|
||||||
|
|
||||||
int groups = libinput_device_tablet_pad_get_num_mode_groups(device);
|
|
||||||
for (int i = 0; i < groups; ++i) {
|
|
||||||
add_pad_group_from_libinput(pad, device, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_insert(&manager->pads, &pad->link);
|
|
||||||
return pad;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_tablet_v2 *tablet_from_libinput(struct wlr_tablet_manager_v2 *manager,
|
|
||||||
struct libinput_device *device) {
|
|
||||||
struct wlr_tablet_v2 *tablet = calloc(1, sizeof(struct wlr_tablet_v2));
|
|
||||||
if (!tablet) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_init(&tablet->resources);
|
|
||||||
|
|
||||||
tablet->vid = libinput_device_get_id_vendor(device);
|
|
||||||
tablet->pid = libinput_device_get_id_product(device);
|
|
||||||
tablet->name = strdup(libinput_device_get_name(device));
|
|
||||||
if (!tablet->name) {
|
|
||||||
free(tablet);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct udev_device *udev = libinput_device_get_udev_device(device);
|
|
||||||
add_tablet_path(&tablet->paths, udev_device_get_syspath(udev));
|
|
||||||
|
|
||||||
wl_list_insert(&manager->tablets, &tablet->link);
|
|
||||||
return tablet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);
|
void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);
|
||||||
static struct wlr_tablet_manager_client_v2 *tablet_manager_client_from_resource(struct wl_resource *resource);
|
static struct wlr_tablet_manager_client_v2 *tablet_manager_client_from_resource(struct wl_resource *resource);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue