mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-05 17:00:39 +01:00
188 lines
4.3 KiB
C
188 lines
4.3 KiB
C
/*
|
|
* 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 "util-object.h"
|
|
|
|
#include "libeis.h"
|
|
#include "util-list.h"
|
|
#include "util-sources.h"
|
|
#include "util-structs.h"
|
|
|
|
struct eis_backend_interface {
|
|
void (*destroy)(struct eis *eis, void *backend);
|
|
};
|
|
|
|
struct eis {
|
|
struct object object;
|
|
void *userdata;
|
|
struct logger *logger;
|
|
struct sink *sink;
|
|
struct list clients;
|
|
|
|
struct eis_backend_interface backend_interface;
|
|
void *backend;
|
|
struct list event_queue;
|
|
};
|
|
|
|
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;
|
|
struct list link;
|
|
struct source *source;
|
|
uint32_t id;
|
|
enum eis_client_state state;
|
|
char *name;
|
|
|
|
struct list devices;
|
|
|
|
struct {
|
|
enum {
|
|
CLIENT_CAP_POLICY_ALLOW,
|
|
CLIENT_CAP_POLICY_DENY,
|
|
} cap_policy;
|
|
uint32_t cap_allow_mask;
|
|
uint32_t cap_deny_mask;
|
|
} restrictions;
|
|
};
|
|
|
|
enum eis_device_state {
|
|
EIS_DEVICE_STATE_NEW,
|
|
EIS_DEVICE_STATE_ACCEPTED,
|
|
EIS_DEVICE_STATE_REMOVED,
|
|
};
|
|
|
|
struct eis_device {
|
|
struct object object;
|
|
struct list link;
|
|
uint32_t id;
|
|
enum eis_device_state state;
|
|
uint32_t capabilities;
|
|
|
|
struct {
|
|
struct dimensions dim;
|
|
} abs;
|
|
struct {
|
|
struct dimensions dim;
|
|
} touch;
|
|
};
|
|
|
|
struct eis_event {
|
|
struct object object;
|
|
enum eis_event_type type;
|
|
struct list link;
|
|
struct eis_client *client;
|
|
struct eis_device *device;
|
|
};
|
|
|
|
struct eis_event_client {
|
|
struct eis_event base;
|
|
};
|
|
|
|
struct eis_event_pointer {
|
|
struct eis_event base;
|
|
int x, y; /* relative motion */
|
|
uint32_t button;
|
|
bool button_is_press;
|
|
};
|
|
|
|
struct eis_event_keyboard {
|
|
struct eis_event base;
|
|
uint32_t key;
|
|
bool key_is_press;
|
|
};
|
|
|
|
void
|
|
eis_init_object(struct eis *eis, struct object *parent);
|
|
|
|
int
|
|
eis_init(struct eis *eis);
|
|
|
|
struct eis_client *
|
|
eis_client_new(struct eis *eis, int fd);
|
|
|
|
struct eis*
|
|
eis_client_get_context(struct eis_client *client);
|
|
|
|
void
|
|
eis_add_client(struct eis *eis, struct eis_client *client);
|
|
|
|
void
|
|
eis_client_connect_device(struct eis_client *client,
|
|
struct eis_device *device);
|
|
void
|
|
eis_client_disconnect_device(struct eis_client *client,
|
|
struct eis_device *device);
|
|
|
|
struct eis_device *
|
|
eis_device_new(struct eis_client *client,
|
|
uint32_t id,
|
|
uint32_t capabilities);
|
|
|
|
void
|
|
eis_device_set_pointer_range(struct eis_device *device,
|
|
uint32_t w, uint32_t h);
|
|
void
|
|
eis_device_set_touch_range(struct eis_device *device,
|
|
uint32_t w, uint32_t h);
|
|
|
|
int
|
|
eis_device_pointer_rel(struct eis_device *device,
|
|
int x, int y);
|
|
int
|
|
eis_device_pointer_button(struct eis_device *device,
|
|
uint32_t button, bool state);
|
|
|
|
int
|
|
eis_device_keyboard_key(struct eis_device *device,
|
|
uint32_t key, bool state);
|
|
|
|
void
|
|
eis_queue_connect_event(struct eis_client *client);
|
|
|
|
void
|
|
eis_queue_disconnect_event(struct eis_client *client);
|
|
|
|
void
|
|
eis_queue_added_event(struct eis_device *device);
|
|
|
|
void
|
|
eis_queue_removed_event(struct eis_device *device);
|
|
|
|
void
|
|
eis_queue_pointer_rel_event(struct eis_device *device, double x, double y);
|
|
|
|
void
|
|
eis_queue_pointer_button_event(struct eis_device *device, uint32_t button,
|
|
bool is_press);
|
|
|
|
void
|
|
eis_queue_keyboard_key_event(struct eis_device *device, uint32_t key,
|
|
bool is_press);
|