GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_proxy_cli.h
Go to the documentation of this file.
1//SPDX-License-Identifier: LGPL-2.0-or-later
2/*
3
4 Copyright (c) 2019-2024 Cyril Hrubis <metan@ucw.cz>
5
6 */
7
16#ifndef GP_PROXY_CLI_H
17#define GP_PROXY_CLI_H
18
19#include <utils/gp_list.h>
20#include <utils/gp_poll.h>
22
23struct gp_event;
24
28typedef struct gp_proxy_cli {
33
35 char *name;
36
37 gp_dlist_head head;
38
42
52static inline int gp_proxy_cli_send(gp_proxy_cli *self,
53 enum gp_proxy_msg_types type,
54 void *payload)
55{
56 return gp_proxy_send(self->fd.fd, type, payload);
57}
58
73static inline void gp_proxy_cli_show(gp_proxy_cli *self, gp_proxy_shm *shm, gp_proxy_coord *cur_pos)
74{
75 if (!self)
76 return;
77
78 /* Map SHM and create pixmap */
81 /* Set the current cursor position */
83 /* And finally show the app */
85}
86
97static inline void gp_proxy_cli_hide(gp_proxy_cli *self)
98{
99 if (!self)
100 return;
101
102 gp_proxy_cli_send(self, GP_PROXY_HIDE, NULL);
104}
105
112static inline void gp_proxy_cli_event(gp_proxy_cli *self, gp_event *ev)
113{
114 if (gp_proxy_send(self->fd.fd, GP_PROXY_EVENT, ev))
115 GP_WARN("Dropping event");
116}
117
128
142
143/*
144 * Adds a new client to the clients list pointed by root pointer.
145 *
146 * @root Root of double linked list of connected clients.
147 * @cli_fd Client file descriptor.
148 * @return A pointer to a newly allocated client.
149 */
150gp_proxy_cli *gp_proxy_cli_add(gp_dlist *clients, int cli_fd);
151
152/*
153 * Removes client from a list of clients.
154 *
155 * @root Root of double linked list of connected clients.
156 * @self A client to be removed.
157 */
158void gp_proxy_cli_rem(gp_dlist *clients, gp_proxy_cli *self);
159
160#endif /* GP_PROXY_CLI_H */
#define GP_WARN(...)
A debug WARN printf-like macro.
Definition gp_debug.h:104
A linked list implementation.
A simple epoll wrapper.
static void gp_proxy_cli_event(gp_proxy_cli *self, gp_event *ev)
Sends an input event message to the application.
int gp_proxy_cli_read(gp_proxy_cli *self)
A function to fill the proxy client buffer.
static void gp_proxy_cli_show(gp_proxy_cli *self, gp_proxy_shm *shm, gp_proxy_coord *cur_pos)
Starts an application rendering into a SHM buffer.
static int gp_proxy_cli_send(gp_proxy_cli *self, enum gp_proxy_msg_types type, void *payload)
Sends a message to a client (application).
int gp_proxy_cli_msg(gp_proxy_cli *self, gp_proxy_msg **msg)
A function to parse messages from the client buffer.
static void gp_proxy_cli_hide(gp_proxy_cli *self)
Stops an application rendering and unmaps SHM buffer.
A proxy backend protocol definitions.
gp_proxy_msg_types
A proxy message type, identifies the type of the payload.
@ GP_PROXY_SHOW
Server requests to show application is on screen.
@ GP_PROXY_HIDE
Server requests to hide application is from screen.
@ GP_PROXY_MAP
A buffer map request or confirmation.
@ GP_PROXY_CURSOR_POS
Sets a cursor position.
@ GP_PROXY_UNMAP
A buffer unmap request or confirmation.
@ GP_PROXY_EVENT
Backend sends a gp_event to the application.
@ GP_PROXY_PIXMAP
int gp_proxy_send(int fd, enum gp_proxy_msg_types type, void *payload)
Sends a message to the server/client.
A double linked list header.
Definition gp_list.h:34
A double linked list pointers.
Definition gp_list.h:56
An input event.
Definition gp_event.h:153
An epoll file descriptor.
Definition gp_poll.h:70
int fd
A file descriptor.
Definition gp_poll.h:92
A proxy message buffer.
A proxy client (application).
char * name
An application name as set by GP_PROXY_NAME message.
gp_fd fd
A sever connection file descriptor.
gp_proxy_buf buf
Connection buffer.
A coordinate.
A SHM pixmap.
gp_pixmap pixmap
A pixmap with the SHM segment as a pixels.
struct gp_proxy_path path
A path to the SHM segment.
A proxy message.