eis: divide the headers up across multiple files

libeis-private.h was getting unwieldly, so let's split this up so
(most) anything eis_foo goes into libeis-foo.h.
This commit is contained in:
Peter Hutterer 2023-02-01 15:38:36 +10:00
parent 8973101313
commit b6a901e690
6 changed files with 439 additions and 281 deletions

92
src/libeis-client.h Normal file
View file

@ -0,0 +1,92 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "libeis.h"
#include "util-object.h"
#include "util-list.h"
enum eis_client_state {
EIS_CLIENT_STATE_NEW, /* just connected */
EIS_CLIENT_STATE_CONNECTING, /* client requested connect */
EIS_CLIENT_STATE_CONNECTED, /* server has sent connect */
EIS_CLIENT_STATE_DISCONNECTED,
};
struct eis_client {
struct object object;
void *user_data;
struct list link;
struct source *source;
uint32_t version;
uint32_t configure_version;
uint32_t id;
enum eis_client_state state;
char *name;
bool is_sender;
struct list seats;
struct list seats_pending;
struct {
uint32_t cap_allow_mask;
} restrictions;
};
struct eis_client *
eis_client_new(struct eis *eis, int fd);
struct eis*
eis_client_get_context(struct eis_client *client);
struct eis_client *
eis_client_get_client(struct eis_client *client);
void
eis_add_client(struct eis *eis, struct eis_client *client);
void
eis_client_add_seat(struct eis_client *client, struct eis_seat *seat);
void
eis_client_remove_seat(struct eis_client *client, struct eis_seat *seat);
void
eis_client_add_device(struct eis_client *client, struct eis_device *device);
void
eis_client_remove_device(struct eis_client *client, struct eis_device *device);
void
eis_client_resume_device(struct eis_client *client,
struct eis_device *device);
void
eis_client_pause_device(struct eis_client *client,
struct eis_device *device);
void
eis_client_keyboard_modifiers(struct eis_client *client, struct eis_device *device,
uint32_t depressed, uint32_t latched, uint32_t locked,
uint32_t group);

157
src/libeis-device.h Normal file
View file

@ -0,0 +1,157 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "libeis.h"
#include "util-object.h"
#include "util-list.h"
enum eis_device_state {
EIS_DEVICE_STATE_NEW,
EIS_DEVICE_STATE_PAUSED,
EIS_DEVICE_STATE_RESUMED,
EIS_DEVICE_STATE_EMULATING,
EIS_DEVICE_STATE_CLOSED_BY_CLIENT,
EIS_DEVICE_STATE_DEAD,
};
struct eis_device {
struct object object; /* parent is ei_seat, and we have a ref to it */
struct list link;
uint32_t id;
char *name;
enum eis_device_state state;
uint32_t capabilities;
void *user_data;
enum eis_device_type type;
uint32_t width, height;
struct list regions;
struct list regions_new; /* not yet added */
struct eis_keymap *keymap;
struct list pending_event_queue; /* incoming events waiting for a frame */
bool send_frame_event;
struct {
bool x_is_stopped, y_is_stopped;
bool x_is_cancelled, y_is_cancelled;
} scroll;
};
struct eis_touch {
struct object object;
struct eis_device *device;
void *user_data;
uint32_t tracking_id;
enum {
TOUCH_IS_NEW,
TOUCH_IS_DOWN,
TOUCH_IS_UP,
} state;
double x, y;
};
struct eis_keymap {
struct object object;
struct eis_device *device;
void *user_data;
enum eis_keymap_type type;
int fd;
size_t size;
bool assigned;
};
struct eis_xkb_modifiers {
uint32_t depressed;
uint32_t locked;
uint32_t latched;
uint32_t group;
};
struct eis *
eis_device_get_context(struct eis_device *device);
void
eis_device_set_client_keymap(struct eis_device *device,
enum eis_keymap_type type,
int keymap_fd, size_t size);
int
eis_device_event_frame(struct eis_device *device, uint64_t time);
int
eis_device_event_pointer_rel(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_abs(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_button(struct eis_device *device,
uint32_t button, bool state);
int
eis_device_event_pointer_scroll(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_scroll_discrete(struct eis_device *device,
int32_t x, int32_t y);
int
eis_device_event_pointer_scroll_stop(struct eis_device *device, bool x, bool y);
int
eis_device_event_pointer_scroll_cancel(struct eis_device *device, bool x, bool y);
int
eis_device_event_keyboard_key(struct eis_device *device,
uint32_t key, bool state);
int
eis_device_event_touch_down(struct eis_device *device, uint32_t touchid,
double x, double y);
int
eis_device_event_touch_motion(struct eis_device *device, uint32_t touchid,
double x, double y);
int
eis_device_event_touch_up(struct eis_device *device, uint32_t touchid);
void
eis_device_event_start_emulating(struct eis_device *device, uint32_t sequence);
void
eis_device_event_stop_emulating(struct eis_device *device);
void
eis_device_closed_by_client(struct eis_device *device);

82
src/libeis-event.h Normal file
View file

@ -0,0 +1,82 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "libeis.h"
#include "util-object.h"
#include "util-list.h"
struct eis_event {
struct object object;
enum eis_event_type type;
struct list link;
struct eis_client *client;
struct eis_seat *seat;
struct eis_device *device;
uint64_t timestamp;
union {
struct {
uint32_t capabilities;
} bind;
struct {
double dx, dy; /* relative motion */
double absx, absy; /* absolute motion */
double sx, sy; /* scroll */
int32_t sdx, sdy; /* discrete scroll */
bool stop_x, stop_y; /* scroll stop */
uint32_t button;
bool button_is_press;
} pointer;
struct {
uint32_t key;
bool key_is_press;
} keyboard;
struct {
uint32_t touchid;
double x, y;
} touch;
struct {
uint32_t sequence;
} start_emulating;
};
};
struct eis_event *
eis_event_new_for_client(struct eis_client *client);
struct eis_event *
eis_event_new_for_seat(struct eis_seat *seat);
struct eis_event *
eis_event_new_for_device(struct eis_device *device);
struct eis *
eis_event_get_context(struct eis_event *event);
struct eis_event*
eis_event_ref(struct eis_event *event);

View file

@ -34,6 +34,12 @@
#include "util-sources.h"
#include "util-structs.h"
#include "libeis-client.h"
#include "libeis-device.h"
#include "libeis-event.h"
#include "libeis-region.h"
#include "libeis-seat.h"
struct eis_backend_interface {
void (*destroy)(struct eis *eis, void *backend);
};
@ -56,171 +62,6 @@ struct eis {
const struct eis_proto_requests *requests;
};
enum eis_client_state {
EIS_CLIENT_STATE_NEW, /* just connected */
EIS_CLIENT_STATE_CONNECTING, /* client requested connect */
EIS_CLIENT_STATE_CONNECTED, /* server has sent connect */
EIS_CLIENT_STATE_DISCONNECTED,
};
struct eis_client {
struct object object;
void *user_data;
struct list link;
struct source *source;
uint32_t version;
uint32_t configure_version;
uint32_t id;
enum eis_client_state state;
char *name;
bool is_sender;
struct list seats;
struct list seats_pending;
struct {
uint32_t cap_allow_mask;
} restrictions;
};
enum eis_seat_state {
EIS_SEAT_STATE_PENDING,
EIS_SEAT_STATE_ADDED,
EIS_SEAT_STATE_BOUND,
EIS_SEAT_STATE_REMOVED_INTERNALLY, /* Removed internally but eis_seat_remove() may be called */
EIS_SEAT_STATE_REMOVED, /* Removed but still waiting for some devices to be removed */
EIS_SEAT_STATE_DEAD, /* Removed from our list */
};
struct eis_seat {
struct object object; /* parent is ei_client */
struct list link;
void *user_data;
uint32_t id;
enum eis_seat_state state;
char *name;
uint32_t capabilities_mask;
struct list devices;
};
enum eis_device_state {
EIS_DEVICE_STATE_NEW,
EIS_DEVICE_STATE_PAUSED,
EIS_DEVICE_STATE_RESUMED,
EIS_DEVICE_STATE_EMULATING,
EIS_DEVICE_STATE_CLOSED_BY_CLIENT,
EIS_DEVICE_STATE_DEAD,
};
struct eis_region {
struct object object;
struct eis_device *device;
void *user_data;
bool added_to_device;
struct list link;
uint32_t x, y;
uint32_t width, height;
double physical_scale;
};
struct eis_device {
struct object object; /* parent is ei_seat, and we have a ref to it */
struct list link;
uint32_t id;
char *name;
enum eis_device_state state;
uint32_t capabilities;
void *user_data;
enum eis_device_type type;
uint32_t width, height;
struct list regions;
struct list regions_new; /* not yet added */
struct eis_keymap *keymap;
struct list pending_event_queue; /* incoming events waiting for a frame */
bool send_frame_event;
struct {
bool x_is_stopped, y_is_stopped;
bool x_is_cancelled, y_is_cancelled;
} scroll;
};
struct eis_touch {
struct object object;
struct eis_device *device;
void *user_data;
uint32_t tracking_id;
enum {
TOUCH_IS_NEW,
TOUCH_IS_DOWN,
TOUCH_IS_UP,
} state;
double x, y;
};
struct eis_event {
struct object object;
enum eis_event_type type;
struct list link;
struct eis_client *client;
struct eis_seat *seat;
struct eis_device *device;
uint64_t timestamp;
union {
struct {
uint32_t capabilities;
} bind;
struct {
double dx, dy; /* relative motion */
double absx, absy; /* absolute motion */
double sx, sy; /* scroll */
int32_t sdx, sdy; /* discrete scroll */
bool stop_x, stop_y; /* scroll stop */
uint32_t button;
bool button_is_press;
} pointer;
struct {
uint32_t key;
bool key_is_press;
} keyboard;
struct {
uint32_t touchid;
double x, y;
} touch;
struct {
uint32_t sequence;
} start_emulating;
};
};
struct eis_keymap {
struct object object;
struct eis_device *device;
void *user_data;
enum eis_keymap_type type;
int fd;
size_t size;
bool assigned;
};
struct eis_xkb_modifiers {
uint32_t depressed;
uint32_t locked;
uint32_t latched;
uint32_t group;
};
void
eis_init_object(struct eis *eis, struct object *parent);
@ -230,122 +71,6 @@ eis_init(struct eis *eis);
struct eis *
eis_get_context(struct eis *eis);
struct eis_client *
eis_client_new(struct eis *eis, int fd);
struct eis*
eis_client_get_context(struct eis_client *client);
struct eis_client *
eis_client_get_client(struct eis_client *client);
void
eis_add_client(struct eis *eis, struct eis_client *client);
void
eis_client_add_seat(struct eis_client *client, struct eis_seat *seat);
void
eis_client_remove_seat(struct eis_client *client, struct eis_seat *seat);
void
eis_client_add_device(struct eis_client *client, struct eis_device *device);
void
eis_client_remove_device(struct eis_client *client, struct eis_device *device);
void
eis_client_resume_device(struct eis_client *client,
struct eis_device *device);
void
eis_client_pause_device(struct eis_client *client,
struct eis_device *device);
void
eis_client_keyboard_modifiers(struct eis_client *client, struct eis_device *device,
uint32_t depressed, uint32_t latched, uint32_t locked,
uint32_t group);
void
eis_seat_bind(struct eis_seat *seat, uint32_t cap);
void
eis_seat_drop(struct eis_seat *seat);
struct eis *
eis_device_get_context(struct eis_device *device);
void
eis_device_set_client_keymap(struct eis_device *device,
enum eis_keymap_type type,
int keymap_fd, size_t size);
int
eis_device_event_frame(struct eis_device *device, uint64_t time);
int
eis_device_event_pointer_rel(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_abs(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_button(struct eis_device *device,
uint32_t button, bool state);
int
eis_device_event_pointer_scroll(struct eis_device *device,
double x, double y);
int
eis_device_event_pointer_scroll_discrete(struct eis_device *device,
int32_t x, int32_t y);
int
eis_device_event_pointer_scroll_stop(struct eis_device *device, bool x, bool y);
int
eis_device_event_pointer_scroll_cancel(struct eis_device *device, bool x, bool y);
int
eis_device_event_keyboard_key(struct eis_device *device,
uint32_t key, bool state);
int
eis_device_event_touch_down(struct eis_device *device, uint32_t touchid,
double x, double y);
int
eis_device_event_touch_motion(struct eis_device *device, uint32_t touchid,
double x, double y);
int
eis_device_event_touch_up(struct eis_device *device, uint32_t touchid);
void
eis_device_event_start_emulating(struct eis_device *device, uint32_t sequence);
void
eis_device_event_stop_emulating(struct eis_device *device);
void
eis_device_closed_by_client(struct eis_device *device);
bool
eis_region_contains(struct eis_region *r, double x, double y);
struct eis_event *
eis_event_new_for_client(struct eis_client *client);
struct eis_event *
eis_event_new_for_seat(struct eis_seat *seat);
struct eis_event *
eis_event_new_for_device(struct eis_device *device);
struct eis *
eis_event_get_context(struct eis_event *event);
struct eis_event*
eis_event_ref(struct eis_event *event);
void
eis_queue_connect_event(struct eis_client *client);

44
src/libeis-region.h Normal file
View file

@ -0,0 +1,44 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "libeis.h"
#include "util-object.h"
#include "util-list.h"
struct eis_region {
struct object object;
struct eis_device *device;
void *user_data;
bool added_to_device;
struct list link;
uint32_t x, y;
uint32_t width, height;
double physical_scale;
};
bool
eis_region_contains(struct eis_region *r, double x, double y);

58
src/libeis-seat.h Normal file
View file

@ -0,0 +1,58 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <stdint.h>
#include "util-object.h"
#include "util-list.h"
enum eis_seat_state {
EIS_SEAT_STATE_PENDING,
EIS_SEAT_STATE_ADDED,
EIS_SEAT_STATE_BOUND,
EIS_SEAT_STATE_REMOVED_INTERNALLY, /* Removed internally but eis_seat_remove() may be called */
EIS_SEAT_STATE_REMOVED, /* Removed but still waiting for some devices to be removed */
EIS_SEAT_STATE_DEAD, /* Removed from our list */
};
struct eis_seat {
struct object object; /* parent is ei_client */
struct list link;
void *user_data;
uint32_t id;
enum eis_seat_state state;
char *name;
uint32_t capabilities_mask;
struct list devices;
};
void
eis_seat_bind(struct eis_seat *seat, uint32_t cap);
void
eis_seat_drop(struct eis_seat *seat);