25#ifndef BACKENDS_GP_BACKEND_H
26#define BACKENDS_GP_BACKEND_H
37#include <backends/gp_types.h>
221 int (*clipboard)(
gp_backend *self, gp_clipboard *op);
256 void *clipboard_data;
267#define GP_BACKEND_PRIV(backend) ((void*)(backend)->priv)
int gp_coord
Integer type for coordinates i.e. x, y, ...
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
int gp_backend_timer_timeout(gp_backend *self)
Returns time to the closest timer timeout.
static void gp_backend_ev_put_back(gp_backend *self, gp_event *ev)
Puts back an event that has been just removed from the queue.
void gp_backend_timer_add(gp_backend *self, gp_timer *timer)
Adds a timer to backend.
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.
gp_backend_fullscreen_req
Fullscreen request type.
@ GP_BACKEND_FULLSCREEN_QUERY
Query fullscreen state.
@ GP_BACKEND_FULLSCREEN_OFF
Request fullscreen to be turned off.
@ GP_BACKEND_FULLSCREEN_ON
Request fullscreen to be turned on.
@ GP_BACKEND_FULLSCREEN_TOGGLE
Toggle fullscreen state.
gp_backend_cursor_req
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(gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
Copies a rectangle from backend pixmap to a display.
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_timer_rem(gp_backend *self, gp_timer *timer)
Removes timer from backend timer queue.
void gp_backend_poll(gp_backend *self)
Polls a backend for events.
void gp_backend_exit(gp_backend *self)
Exits the backend.
gp_backend_ret
A return value from the backend set_attr callback.
@ GP_BACKEND_NOTSUPP
Unsupported attribute.
@ GP_BACKEND_OK
Atrribute set succesfully.
@ GP_BACKEND_CONNERR
Connection error.
@ GP_BACKEND_ON
Attribute is enabled.
@ GP_BACKEND_EINVAL
Invalid value.
@ GP_BACKEND_OFF
Attribute is disabled.
int gp_backend_resize(gp_backend *backend, uint32_t w, uint32_t h)
Request backend resize.
static gp_event * gp_backend_ev_peek(gp_backend *self)
Returns a pointer to a first event in the queue.
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_wait(gp_backend *self)
Waits for a backend events.
gp_event * gp_backend_ev_wait(gp_backend *self)
Returns an event from the queue, wait the backend for events if the queue is empty.
static enum gp_backend_ret gp_backend_cursor_set(gp_backend *self, enum gp_backend_cursor_req cursor)
Sets backend cursor type.
void gp_backend_task_ins(gp_backend *self, gp_task *task)
Inserts a task into the task queue.
static void gp_backend_ev_flush(gp_backend *self)
Removes all events from the event queue.
void gp_backend_task_rem(gp_backend *self, gp_task *task)
Removes a task from the task queue.
static enum gp_backend_ret gp_backend_set_caption(gp_backend *backend, const char *caption)
Sets backend caption, if supported.
static unsigned int gp_backend_timers_queued(gp_backend *self)
Returns number of timers scheduled in backend.
static enum gp_backend_ret gp_backend_fullscreen(gp_backend *backend, enum gp_backend_fullscreen_req req)
Reuqests to change fullscreen mode.
static void gp_backend_poll_add(gp_backend *self, gp_fd *fd)
Add a file descriptor to the backend poll loop.
gp_backend_attr
Backend attributes.
@ GP_BACKEND_ATTR_SIZE
Window change request.
@ GP_BACKEND_ATTR_TITLE
Window title change request.
@ GP_BACKEND_ATTR_CURSOR
Cursor modifications.
@ GP_BACKEND_ATTR_FULLSCREEN
Fullscreen mode change request.
gp_event * gp_backend_ev_poll(gp_backend *self)
Returns an event from the queue, polls the backend for events if the queue is empty.
static void gp_backend_poll_rem(gp_backend *self, gp_fd *fd)
Removes a file descriptor to the backend poll loop.
static unsigned int gp_backend_ev_queued(gp_backend *self)
Returns a number of events in the backend event queue.
static gp_fd * gp_backend_poll_rem_by_fd(gp_backend *self, int fd)
Removes a file descriptor to the backend poll loop.
static gp_event * gp_backend_ev_get(gp_backend *self)
Removes and returns a pointer to a first event in the 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.
void gp_ev_queue_flush(gp_ev_queue *self)
Removes all events from 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".
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.
enum gp_backend_ret(* set_attr)(gp_backend *self, enum gp_backend_attr attr, const void *vals)
Attribute change callback.
A double linked list pointers.
An epoll file descriptor.