GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_clipboard.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2009-2021 Cyril Hrubis <metan@ucw.cz>
4 */
17#ifndef BACKENDS_GP_CLIPBOARD_H
18#define BACKENDS_GP_CLIPBOARD_H
19
20#include <backends/gp_types.h>
21
22enum gp_clipboard_op {
23 GP_CLIPBOARD_SET,
24 GP_CLIPBOARD_REQUEST,
25 GP_CLIPBOARD_GET,
26 GP_CLIPBOARD_CLEAR,
27};
28
29struct gp_clipboard {
30 enum gp_clipboard_op op;
31 union {
32 const char *str;
33 char *ret;
34 };
35 size_t len;
36};
37
48int gp_backend_clipboard(gp_backend *self, gp_clipboard *op);
49
59static inline int gp_backend_clipboard_set(gp_backend *self, const char *str, size_t len)
60{
61 struct gp_clipboard op = {
62 .op = GP_CLIPBOARD_SET,
63 .str = str,
64 .len = len,
65 };
66
67 return gp_backend_clipboard(self, &op);
68}
69
78{
79 struct gp_clipboard op = {.op = GP_CLIPBOARD_REQUEST};
80
81 return gp_backend_clipboard(self, &op);
82}
83
95static inline char *gp_backend_clipboard_get(gp_backend *self)
96{
97 struct gp_clipboard op = {.op = GP_CLIPBOARD_GET};
98
99 gp_backend_clipboard(self, &op);
100
101 return op.ret;
102}
103
112static inline void gp_backend_clipboard_ready(gp_backend *self)
113{
114 gp_ev_queue_push(self->event_queue, GP_EV_SYS, GP_EV_SYS_CLIPBOARD, 0, 0);
115}
116
117#endif /* BACKENDS_GP_CLIPBOARD_H */
static int gp_backend_clipboard_request(gp_backend *self)
Requests clipboard data to be retrieved.
static int gp_backend_clipboard_set(gp_backend *self, const char *str, size_t len)
Sets the clipboard data.
static char * gp_backend_clipboard_get(gp_backend *self)
Returns clipboard data.
int gp_backend_clipboard(gp_backend *self, gp_clipboard *op)
An internal handler that implements clipboard operations.
static void gp_backend_clipboard_ready(gp_backend *self)
Pushes clipboard data ready event into a backend input queue.
void gp_ev_queue_push(gp_ev_queue *self, uint16_t type, uint32_t code, int32_t value, uint64_t time)
Push a generic event into the queue.
@ GP_EV_SYS_CLIPBOARD
Clipboard request is ready.
Definition gp_event.h:94
@ GP_EV_SYS
A system events, window close, resize, etc.
Definition gp_event.h:33
A backend.
Definition gp_backend.h:72