GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_proxy_cli.h File Reference

Proxy sever client (application) helpers. More...

Go to the source code of this file.

Data Structures

struct  gp_proxy_cli
 A proxy client (application). More...
 

Typedefs

typedef struct gp_proxy_cli gp_proxy_cli
 A proxy client (application).
 

Functions

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).
 
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 void gp_proxy_cli_hide (gp_proxy_cli *self)
 Stops an application rendering and unmaps SHM buffer.
 
static void gp_proxy_cli_event (gp_proxy_cli *self, gp_event *ev)
 Sends an input event message to the application.
 
static void gp_proxy_cli_rect_updated (gp_proxy_cli *self, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 Tells client that requested update was finished.
 
int gp_proxy_cli_read (gp_proxy_cli *self)
 A function to fill the proxy client buffer.
 
int gp_proxy_cli_msg (gp_proxy_cli *self, gp_proxy_msg **msg)
 A function to parse messages from the client buffer.
 

Detailed Description

Proxy sever client (application) helpers.

This header implements helpers for server to communicate with the clients (applications).

Definition in file gp_proxy_cli.h.

Function Documentation

◆ gp_proxy_cli_event()

static void gp_proxy_cli_event ( gp_proxy_cli * self,
gp_event * ev )
inlinestatic

Sends an input event message to the application.

Parameters
selfA client (application).
evAn input event.

Definition at line 112 of file gp_proxy_cli.h.

References gp_fd::fd, gp_proxy_cli::fd, GP_PROXY_EVENT, gp_proxy_send(), and GP_WARN.

◆ gp_proxy_cli_hide()

static void gp_proxy_cli_hide ( gp_proxy_cli * self)
inlinestatic

Stops an application rendering and unmaps SHM buffer.

This is an shorthand to:

  • stopping application rendering
  • unampping a SHM buffer
Parameters
selfA client (application).

Definition at line 97 of file gp_proxy_cli.h.

References gp_proxy_cli_send(), GP_PROXY_HIDE, and GP_PROXY_UNMAP.

◆ gp_proxy_cli_msg()

int gp_proxy_cli_msg ( gp_proxy_cli * self,
gp_proxy_msg ** msg )

A function to parse messages from the client buffer.

This function must be called in a loop until there are no more messages to be parsed.

Parameters
selfPointer to a client.
msgA pointer to store the start of the message to. It's set to NULL if there are no more messages.
Returns
Zero on success, non-zero on a failure e.g. invalid sekvence of bytes was found in the buffer.

◆ gp_proxy_cli_read()

int gp_proxy_cli_read ( gp_proxy_cli * self)

A function to fill the proxy client buffer.

Has to be called when there are data ready at client fd. The buffer then has to be parsed by gp_proxy_cli_msg() function.

Parameters
selfPointer to a client.
Returns
Zero on success, non-zero otherwise.

◆ gp_proxy_cli_rect_updated()

static void gp_proxy_cli_rect_updated ( gp_proxy_cli * self,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h )
inlinestatic

Tells client that requested update was finished.

This is called by the proxy backend after it finished copying data from the shared buffer. After client receives this event it can resume drawing to the area for which update was pending.

Parameters
selfA client (application).
xA rect x coordinate.
yA rect y coordinate.
wA rect width.
hA rect height.

Definition at line 131 of file gp_proxy_cli.h.

References gp_proxy_cli_send(), and GP_PROXY_UPDATE.

◆ gp_proxy_cli_send()

static int gp_proxy_cli_send ( gp_proxy_cli * self,
enum gp_proxy_msg_types type,
void * payload )
inlinestatic

Sends a message to a client (application).

Parameters
selfA client.
typeA message type.
payloadAn optional payload. See enum gp_proxy_msg_types.
Returns
Zero on success, non-zero on a failure.

Definition at line 52 of file gp_proxy_cli.h.

References gp_fd::fd, gp_proxy_cli::fd, and gp_proxy_send().

Referenced by gp_proxy_cli_hide(), gp_proxy_cli_rect_updated(), and gp_proxy_cli_show().

◆ gp_proxy_cli_show()

static void gp_proxy_cli_show ( gp_proxy_cli * self,
gp_proxy_shm * shm,
gp_proxy_coord * cur_pos )
inlinestatic

Starts an application rendering into a SHM buffer.

This is a shorthand to:

  • mapping SHM into memory
  • setting up a SHM pixmap
  • setting initial cursor position
  • starting application rendering
Parameters
selfA client (application).
shmA SHM pixmap to start rendering into.
cur_posAn initial cursor position.

Definition at line 73 of file gp_proxy_cli.h.

References gp_proxy_cli_send(), GP_PROXY_CURSOR_POS, GP_PROXY_MAP, GP_PROXY_PIXMAP, GP_PROXY_SHOW, gp_proxy_shm::path, and gp_proxy_shm::pixmap.