GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
gp_proxy_proto.h File Reference

A proxy backend protocol definitions. More...

#include <core/gp_pixmap.h>
#include <core/gp_pixel.h>
#include <input/gp_event.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  gp_proxy_event
 A proxy input event message. More...
 
struct  gp_proxy_path
 A SHM path and size for a mmap(). More...
 
struct  gp_proxy_rect_
 A rectangle. More...
 
struct  gp_proxy_map
 A mmap() request. More...
 
struct  gp_proxy_pixmap
 A pixmap request. More...
 
struct  gp_proxy_rect
 A rectangle update request. More...
 
struct  gp_proxy_cli_init_
 An initial infromation send to a client (application). More...
 
struct  gp_proxy_cli_init
 An initial infromation send to a client (application). More...
 
struct  gp_proxy_coord
 A coordinate. More...
 
struct  gp_proxy_cursor
 A proxy cursor position. More...
 
union  gp_proxy_msg
 A proxy message. More...
 
struct  gp_proxy_buf
 A proxy message buffer. More...
 

Macros

#define GP_PROXY_BUF_SIZE   128
 A proxy buffer size.
 

Typedefs

typedef struct gp_proxy_coord gp_proxy_coord
 A coordinate.
 
typedef union gp_proxy_msg gp_proxy_msg
 A proxy message.
 
typedef struct gp_proxy_buf gp_proxy_buf
 A proxy message buffer.
 

Enumerations

enum  gp_proxy_msg_types {
  GP_PROXY_NAME , GP_PROXY_EXIT , GP_PROXY_CLI_INIT , GP_PROXY_EVENT ,
  GP_PROXY_MAP , GP_PROXY_UNMAP , GP_PROXY_PIXMAP , GP_PROXY_SHOW ,
  GP_PROXY_HIDE , GP_PROXY_UPDATE , GP_PROXY_CURSOR_POS , GP_PROXY_MAX
}
 A proxy message type, identifies the type of the payload. More...
 

Functions

static void gp_proxy_buf_init (gp_proxy_buf *buf)
 Initialize proxy buffer position and size.
 
const char * gp_proxy_msg_type_name (enum gp_proxy_msg_types type)
 Returns a string name for a proxy message type.
 
int gp_proxy_next (gp_proxy_buf *buf, gp_proxy_msg **msg)
 Parse next message in the buffer.
 
int gp_proxy_buf_recv (int fd, gp_proxy_buf *buf)
 Receives data from from fd and stores them to the proxy buffer.
 
int gp_proxy_send (int fd, enum gp_proxy_msg_types type, void *payload)
 Sends a message to the server/client.
 

Detailed Description

A proxy backend protocol definitions.

Definition in file gp_proxy_proto.h.

Macro Definition Documentation

◆ GP_PROXY_BUF_SIZE

#define GP_PROXY_BUF_SIZE   128

A proxy buffer size.

Must be bigger than maximal message size!

Definition at line 281 of file gp_proxy_proto.h.

Typedef Documentation

◆ gp_proxy_msg

typedef union gp_proxy_msg gp_proxy_msg

A proxy message.

The type of payload is determined by the type field.

Enumeration Type Documentation

◆ gp_proxy_msg_types

A proxy message type, identifies the type of the payload.

A message type is always send in the first 32bits of the proxy message. A message type is followed by a 32bit field with message lenght and optional payload. The size field always includes the header size, so it's always at least set to 8 bytes. Messages are also padded with zeroes so that the size is always multiple of 4 bytes.

Enumerator
GP_PROXY_NAME 

Sets an application name.

This is send to the sever by the application after successfull connection.

The string in the message is not NULL terminated and passed directly after the hader. The lenght of the string plus the size of the header is stored in the size field.

GP_PROXY_EXIT 

Requests an application exit.

When application receives this message a GP_EV_SYS_QUIT event is put into the application event queue.

There is no payload the message size is always 8 bytes long.

GP_PROXY_CLI_INIT 

Backend sends a basic information to the client (application).

The payload lenght is sizeof(struct gp_proxy_cli_init) and among other things stores the pixel type for the application to use for drawing.

This message is send to the application right after it connects to the server and the application waits for this message before it finished its initialization.

See also struct gp_proxy_cli_init.

GP_PROXY_EVENT 

Backend sends a gp_event to the application.

The payload is an input gp_event which is put into the application event queue.

See also struct gp_proxy_event.

GP_PROXY_MAP 

A buffer map request or confirmation.

This message is send both by the sever and the application:

  • Sever asks application to map a shared buffer. Payload is struct gp_proxy_path type.
  • Clients notifies server that buffer has been mapped. The message has no payload.
GP_PROXY_UNMAP 

A buffer unmap request or confirmation.

This message is send both by the sever and the application, there is no payload in both cases:

  • Server asks client to unmap a shared buffer.
  • Client notifies sever that buffer has been unmapped.
GP_PROXY_PIXMAP 

Server asks client to create a pixmap from the shared buffer.

This request is send by the sever after application successfully maped a shared buffer to create a pixmap to draw to. The payload is a gp_pixmap structure.

GP_PROXY_SHOW 

Server requests to show application is on screen.

The application will start rendering and screen updates.

GP_PROXY_HIDE 

Server requests to hide application is from screen.

The application will stop rendering and screen updated.

GP_PROXY_UPDATE 

Application asks server to update a rect on screen.

This is send to a sever by the application when application rendered a rectangle into the shared memory and requests the sever to update it.

The payload is the struct gp_proxy_rect.

GP_PROXY_CURSOR_POS 

Sets a cursor position.

Send by the sever to an application to set the intial cursor position.

GP_PROXY_MAX 

Last message type + 1.

Definition at line 30 of file gp_proxy_proto.h.

Function Documentation

◆ gp_proxy_buf_init()

static void gp_proxy_buf_init ( gp_proxy_buf buf)
inlinestatic

Initialize proxy buffer position and size.

Parameters
bufA proxy buffer.

Definition at line 298 of file gp_proxy_proto.h.

References gp_proxy_buf::pos, and gp_proxy_buf::size.

◆ gp_proxy_buf_recv()

int gp_proxy_buf_recv ( int  fd,
gp_proxy_buf buf 
)

Receives data from from fd and stores them to the proxy buffer.

Parameters
fdFile descriptor connected to the server/client.
bufProxy buffer to store data to.
Returns
Number of bytes stored into the buffer, -1 on failure.

◆ gp_proxy_msg_type_name()

const char * gp_proxy_msg_type_name ( enum gp_proxy_msg_types  type)

Returns a string name for a proxy message type.

Parameters
typeA proxy message type.
Returns
A proxy message type name.

◆ gp_proxy_next()

int gp_proxy_next ( gp_proxy_buf buf,
gp_proxy_msg **  msg 
)

Parse next message in the buffer.

Parses next message in the proxy buffer, the start of the message is stored into the msg pointer. If there was no message parsed the msg pointer is set to NULL.

Parameters
bufProxy buffer filled by the gp_proxy_buf_recv() function.
msgPointer to store the start of the next message to.
Returns
Positive if full message was found in the buffer, zero on no or partial message and negative on error.

◆ gp_proxy_send()

int gp_proxy_send ( int  fd,
enum gp_proxy_msg_types  type,
void *  payload 
)

Sends a message to the server/client.

Parameters
fdFile descriptor connected to the server/client.
typeType of the message.
payloadPointer to message payload accordingly to the message type.
Returns
Zero on success, non-zero on failure.

Referenced by gp_proxy_cli_event(), and gp_proxy_cli_send().