23#ifndef BACKENDS_GP_BACKEND_H
24#define BACKENDS_GP_BACKEND_H
35#include <backends/gp_types.h>
37enum gp_backend_attrs {
43 GP_BACKEND_FULLSCREEN,
117 int (*set_attr)(
gp_backend *self,
enum gp_backend_attrs attr,
150 int (*clipboard)(
gp_backend *self, gp_clipboard *op);
185 void *clipboard_data;
196#define GP_BACKEND_PRIV(backend) ((void*)(backend)->priv)
278static inline gp_fd *gp_backend_poll_rem_by_fd(
gp_backend *self,
int fd)
341static inline unsigned int gp_backend_timers_in_queue(
gp_backend *self)
350int gp_backend_timer_timeout(
gp_backend *self);
357static inline int gp_backend_set_caption(
gp_backend *backend,
360 if (!backend->set_attr)
363 return backend->set_attr(backend, GP_BACKEND_TITLE, caption);
376int gp_backend_resize(
gp_backend *backend, uint32_t w, uint32_t h);
386static inline int gp_backend_fullscreen(
gp_backend *backend,
int val)
388 if (!backend->set_attr)
391 return backend->set_attr(backend, GP_BACKEND_FULLSCREEN, &val);
449static inline unsigned int gp_backend_events(
gp_backend *self)
int gp_coord
Integer type for coordinates i.e. x, y, ...
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
static void gp_backend_flip(gp_backend *self)
Copies whole backend pixmap to a display.
int gp_backend_resize_ack(gp_backend *self)
Resize acknowledge.
static void gp_backend_update_rect(gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
Copies a rectangle from backend pixmap to a display.
gp_backend_cursors
Cursor types.
@ GP_BACKEND_CURSOR_SHOW
Shows cursor.
@ GP_BACKEND_CURSOR_TEXT_EDIT
Text edit cursor.
@ GP_BACKEND_CURSOR_HIDE
Hides cursor.
@ GP_BACKEND_CURSOR_MAX
Last cursor + 1.
@ GP_BACKEND_CURSOR_HAND
Used typicaly while howering over links.
@ GP_BACKEND_CURSOR_CROSSHAIR
Crosshair.
@ GP_BACKEND_CURSOR_ARROW
Arrow default cursor type.
static void gp_backend_update_rect_xywh(gp_backend *self, gp_coord x, gp_coord y, gp_size w, gp_size h)
Copies a rectangle from backend pixmap to a display.
void gp_backend_update_rect_xyxy(gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
Copies a rectangle from backend pixmap to a display.
void gp_backend_exit(gp_backend *self)
Exits the backend.
void gp_backend_task_queue_set(gp_backend *self, gp_task_queue *task_queue)
Sets the backend task_queue and starts task processing.
void gp_backend_task_ins(gp_backend *self, gp_task *task)
Inserts a task into the task queue.
void gp_backend_task_rem(gp_backend *self, gp_task *task)
Removes a task from the task queue.
void gp_ev_queue_put_back(gp_ev_queue *self, gp_event *ev)
Pushes back an event to the event queue.
gp_event * gp_ev_queue_peek(gp_ev_queue *self)
Peeks at a top event from the queue.
gp_event * gp_ev_queue_get(gp_ev_queue *self)
Remoes and returns pointer to a top event from the queue.
unsigned int gp_ev_queue_events(gp_ev_queue *self)
Returns number of events queued in the queue.
A linked list implementation.
int gp_poll_add(gp_poll *self, gp_fd *fd)
Adds a file descriptor.
gp_fd * gp_poll_rem_by_fd(gp_poll *self, int fd)
Looks up and removes a gp_fd by a fd.
int gp_poll_rem(gp_poll *self, gp_fd *fd)
Removes a file descriptor.
Timers and timer queue implementation.
static unsigned int gp_timer_queue_size(gp_timer *queue)
Returns size of the queue, i.e. number of timers.
gp_poll fds
File descriptors to poll for.
void(* poll)(gp_backend *self)
Non-blocking event loop.
const char * name
Backend name, e.g. "X11".
int(* set_cursor)(gp_backend *self, enum gp_backend_cursors cursor)
Sets cursor shape and/or hides and shows cursor.
gp_timer * timers
Priority queue for timers.
gp_task_queue * task_queue
Task queue.
gp_dlist input_drivers
List of input drivers feeding the ev_queue.
void(* exit)(gp_backend *self)
Exits the backend.
void(* update_rect)(gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
Updates display rectangle.
void(* flip)(gp_backend *self)
Updates display.
gp_pixmap * pixmap
Pointer to pixmap app should draw to.
unsigned int dpi
A backend DPI if unknown it's set to 0.
void(* wait)(gp_backend *self)
Blocking event loop. Blocks until events are ready.
A double linked list pointers.
An epoll file descriptor.