GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
backends
gp_proxy_proto.h
1
//SPDX-License-Identifier: LGPL-2.0-or-later
2
/*
3
4
Copyright (c) 2019-2020 Cyril Hrubis <metan@ucw.cz>
5
6
*/
7
8
#ifndef GP_PROXY_PROTO_H
9
#define GP_PROXY_PROTO_H
10
11
#include <
core/gp_pixmap.h
>
12
#include <
core/gp_pixel.h
>
13
#include <
input/gp_event.h
>
14
#include <stdint.h>
15
16
struct
gp_proxy_event {
17
uint32_t type;
18
uint32_t size;
19
gp_event
ev;
20
};
21
22
struct
gp_proxy_path {
23
size_t
size;
24
char
path[64];
25
};
26
27
struct
gp_proxy_rect_ {
28
uint32_t x;
29
uint32_t y;
30
uint32_t w;
31
uint32_t h;
32
};
33
34
struct
gp_proxy_map {
35
uint32_t type;
36
uint32_t size;
37
struct
gp_proxy_path map;
38
};
39
40
struct
gp_proxy_pixmap {
41
uint32_t type;
42
uint32_t size;
43
gp_pixmap
pix;
44
};
45
46
struct
gp_proxy_rect {
47
uint32_t type;
48
uint32_t size;
49
struct
gp_proxy_rect_ rect;
50
};
51
52
struct
gp_proxy_ptype {
53
uint32_t type;
54
uint32_t size;
55
gp_pixel_type
ptype;
56
};
57
58
struct
gp_proxy_coord {
59
uint32_t x;
60
uint32_t y;
61
};
62
63
struct
gp_proxy_cursor {
64
uint32_t type;
65
uint32_t size;
66
struct
gp_proxy_coord pos;
67
};
68
69
union
gp_proxy_msg {
70
struct
{
71
uint32_t type;
72
uint32_t size;
73
char
payload[];
74
};
75
struct
gp_proxy_event ev;
76
struct
gp_proxy_map map;
77
struct
gp_proxy_pixmap pix;
78
struct
gp_proxy_rect rect;
79
struct
gp_proxy_ptype ptype;
80
struct
gp_proxy_cursor cursor;
81
};
82
83
enum
gp_proxy_msg_types {
84
GP_PROXY_NAME,
85
GP_PROXY_EXIT,
86
/* Payload type is pixel_type */
87
GP_PROXY_PIXEL_TYPE,
88
/* Payload type is gp_event */
89
GP_PROXY_EVENT,
90
/*
91
* - Sever asks client to map a shared buffer.
92
* Payload is gp_proxy_path type.
93
*
94
* - Clients notifies server that buffer has been mapped.
95
* No payload.
96
*/
97
GP_PROXY_MAP,
98
/*
99
* - Server asks client to unmap a shared buffer.
100
* No payload.
101
*
102
* - Client notifies sever that buffer has been unmapped.
103
* No payload.
104
*/
105
GP_PROXY_UNMAP,
106
/* Asks client to create a pixmap from the shared buffer */
107
GP_PROXY_PIXMAP,
108
/* Application is on screen */
109
GP_PROXY_SHOW,
110
/* Application is hidden */
111
GP_PROXY_HIDE,
112
/* Update rect on screen */
113
GP_PROXY_UPDATE,
114
/* Sets a cursor position */
115
GP_PROXY_CURSOR_POS,
116
GP_PROXY_MAX,
117
};
118
119
/* Must be bigger than maximal message size! */
120
#define GP_PROXY_BUF_SIZE 128
121
122
typedef
struct
gp_proxy_buf {
123
size_t
pos;
124
size_t
size;
125
char
buf[GP_PROXY_BUF_SIZE];
126
} gp_proxy_buf;
127
128
static
inline
void
gp_proxy_buf_init(gp_proxy_buf *buf)
129
{
130
buf->pos = 0;
131
buf->size = 0;
132
}
133
134
/*
135
* Parses next message in the proxy buffer, the pointer to a start of the
136
* message is stored into the msg pointer.
137
*
138
* @buf Proxy bufer filled by the gp_proxy_buf_recv() function.
139
* @msg Pointer to the start of the next message.
140
* @return Non-zero if full message was found in the buffer, zero otherwise.
141
*/
142
int
gp_proxy_next(gp_proxy_buf *buf,
union
gp_proxy_msg **msg);
143
144
/*
145
* Receives data from from fd and stores them to the proxy buffer.
146
*
147
* @fd File descriptor connected to the server/client.
148
* @buf Proxy buffer to store data to.
149
* @return Number of bytes stored into the buffer, -1 on failure.
150
*/
151
int
gp_proxy_buf_recv(
int
fd, gp_proxy_buf *buf);
152
153
/*
154
* Sends data to the server/client.
155
*
156
* @fd File descriptor connected to the server/client.
157
* @type Type of the message.
158
* @payload Pointer to message payload accordingly to the message type.
159
* @return Zero on success, non-zero on failure.
160
*/
161
int
gp_proxy_send(
int
fd,
enum
gp_proxy_msg_types type,
void
*payload);
162
163
#endif
/* GP_PROXY_PROTO_H */
gp_event.h
An (input) event layer.
gp_pixel_type
gp_pixel_type
List of all pixel types.
Definition
gp_pixel.gen.h:62
gp_pixel.h
A pixel description.
gp_pixmap.h
A pixel buffer.
gp_event
An input event.
Definition
gp_event.h:153
gp_pixmap
A pixmap buffer.
Definition
gp_pixmap.h:33
Generated by
1.9.8