blob: 33837e4183fe514c21d22d0c07a6be4c4f7fe12b (
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
69
70
71
72
73
74
75
|
#include "backend.h"
#if YASL_HAS_WAYLAND
#include "yasl/native/wayland.h"
#endif
#if YASL_HAS_X11
#include "yasl/native/x11.h"
#endif
#include <errno.h>
void *yasl_display_get_native_handle(struct yasl_display *d)
{
if (!d) return NULL;
if (d->native_handle) return d->native_handle;
return d->ops && d->ops->display_get_native_handle ?
d->ops->display_get_native_handle(d) : NULL;
}
void *yasl_surface_get_native_handle(struct yasl_surface *s)
{
if (!s) return NULL;
if (s->native_handle) return s->native_handle;
return s->display && s->display->ops && s->display->ops->surface_get_native_handle ?
s->display->ops->surface_get_native_handle(s) : NULL;
}
#if YASL_HAS_WAYLAND
struct wl_display *yasl_wayland_display_get_wl_display(struct yasl_display *d)
{
return (d && yasl_display_backend(d) == YASL_BACKEND_WAYLAND) ?
(struct wl_display *)yasl_display_get_native_handle(d) : NULL;
}
struct wl_surface *yasl_wayland_surface_get_wl_surface(struct yasl_surface *s)
{
return (s && s->display && yasl_display_backend(s->display) == YASL_BACKEND_WAYLAND) ?
(struct wl_surface *)yasl_surface_get_native_handle(s) : NULL;
}
#endif
#if YASL_HAS_X11
Display *yasl_x11_display_get_display(struct yasl_display *d)
{
return (d && yasl_display_backend(d) == YASL_BACKEND_X11) ?
(Display *)yasl_display_get_native_handle(d) : NULL;
}
uintptr_t yasl_x11_surface_get_window(struct yasl_surface *s)
{
return (s && s->display && yasl_display_backend(s->display) == YASL_BACKEND_X11) ?
(uintptr_t)yasl_surface_get_native_handle(s) : 0;
}
#endif
struct yasl_surface *yasl_surface_create_native(struct yasl_display *d,
const struct yasl_surface_spec *spec, void *graphics_device)
{
if (!graphics_device) {
errno = EINVAL;
return NULL;
}
return yasl_create_toplevel(d, spec, graphics_device);
}
bool yasl_surface_get_native_frame(struct yasl_surface *s,
const struct yasl_framebuffer *target, struct yasl_native_frame *out)
{
if (!s || !target || !out || !target->generation ||
target->generation != s->frame_generation ||
!s->display->ops->surface_get_native_frame)
return false;
return s->display->ops->surface_get_native_frame(s, target, out);
}
|