summaryrefslogtreecommitdiff
path: root/src/common/backend.h
blob: c1d878be579ae6e5b39962d0f96bef6a87e83c44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef YASL_BACKEND_H
#define YASL_BACKEND_H

#include "yasl/yasl.h"

struct yasl_backend_ops;

struct yasl_display {
    const struct yasl_backend_ops *ops;
};

struct yasl_surface {
    struct yasl_display *display;
};

struct yasl_backend_ops {
    enum yasl_backend type;
    struct yasl_display *(*display_open)(struct yasl_loop *loop, const struct yasl_display_spec *spec);
    void (*display_close)(struct yasl_display *d);
    uint32_t (*display_caps)(const struct yasl_display *d);
    void (*display_dispatch)(struct yasl_display *d);
    int (*display_dispatch_timeout)(struct yasl_display *d, int timeout_ms);
    void (*display_flush)(struct yasl_display *d);
    int (*display_modifiers)(const struct yasl_display *d);
    void (*display_copy)(struct yasl_display *d, enum yasl_selection sel, const char *text);
    void (*display_paste)(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *target);
    bool (*display_drag_start)(struct yasl_display *d, struct yasl_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud);
    void (*display_drag_cancel)(struct yasl_display *d);
    struct yasl_surface *(*surface_create_toplevel)(struct yasl_display *d, const struct yasl_surface_spec *spec);
    struct yasl_surface *(*surface_create_popup)(struct yasl_surface *parent, const struct yasl_popup_spec *spec);
    bool (*surface_popup_reposition)(struct yasl_surface *popup, const struct yasl_popup_spec *spec);
    void (*surface_destroy)(struct yasl_surface *s);
    struct yasl_display *(*surface_display)(const struct yasl_surface *s);
    void (*surface_set_callbacks)(struct yasl_surface *s, const struct yasl_surface_cbs *cbs, void *ud);
    void (*surface_set_title)(struct yasl_surface *s, const char *title);
    void (*surface_schedule_redraw)(struct yasl_surface *s);
    bool (*surface_present)(struct yasl_surface *s, const struct yasl_framebuffer *fb, const struct yasl_damage_list *damage);
    bool (*surface_input_poll)(struct yasl_surface *s, struct yasl_input_event *ev);
    struct yasl_vector2i (*surface_size)(const struct yasl_surface *s);
    uint32_t (*surface_scale_120)(const struct yasl_surface *s);
    uint32_t (*surface_state)(const struct yasl_surface *s);
    struct yasl_timing (*surface_timing)(const struct yasl_surface *s);
    uint64_t (*surface_frame_time_ns)(struct yasl_surface *s, uint64_t now);
    void (*surface_set_cursor)(struct yasl_surface *s, enum yasl_cursor cursor);
    void (*surface_set_background_color)(struct yasl_surface *s, uint32_t bg);
    const char *(*surface_ime_preedit)(const struct yasl_surface *s);
    bool (*surface_ime_preedit_cursor)(const struct yasl_surface *s, int *begin, int *end);
    void (*surface_set_ime_caret)(struct yasl_surface *s, struct yasl_rect2i caret);
    bool (*surface_start_interactive_move)(struct yasl_surface *s);
    bool (*surface_start_interactive_resize)(struct yasl_surface *s, enum yasl_resize_edge edge);
    bool (*surface_show_window_menu)(struct yasl_surface *s, struct yasl_vector2i pos);
    bool (*surface_drag_carry)(struct yasl_surface *s, struct yasl_vector2i offset);
    bool (*surface_place_under_pointer)(struct yasl_surface *s, struct yasl_vector2i at);
    void *(*display_get_native_handle)(struct yasl_display *d);
    void *(*surface_get_native_handle)(struct yasl_surface *s);
};

#if YASL_HAS_WAYLAND
extern const struct yasl_backend_ops yasl_wayland_backend;
#endif
#if YASL_HAS_X11
extern const struct yasl_backend_ops yasl_x11_backend;
#endif
#if YASL_HAS_COCOA
extern const struct yasl_backend_ops yasl_cocoa_backend;
#endif

#endif