1 // Copyright © 2017-2021 Rémi Thebault
2 /// bindings to wayland-client-core.h
3 module wayland.native.cursor;
4 
5 // Wayland client-core copyright:
6 /*
7  * Copyright © 2012 Intel Corporation
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the
18  * next paragraph) shall be included in all copies or substantial
19  * portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  */
30 
31 import wayland.native.client : wl_proxy;
32 
33 extern(C)
34 {
35     struct wl_cursor_theme;
36 
37     struct wl_cursor_image {
38         uint width;		/* actual width */
39         uint height;	/* actual height */
40         uint hotspot_x;	/* hot spot x (must be inside image) */
41         uint hotspot_y;	/* hot spot y (must be inside image) */
42         uint delay;		/* animation delay to next frame (ms) */
43     };
44 
45     struct wl_cursor {
46         uint image_count;
47         wl_cursor_image** images;
48         char* name;
49     };
50 }
51 
52 version(WlDynamic)
53 {
54     extern(C) nothrow
55     {
56         alias da_wl_cursor_theme_load = wl_cursor_theme* function (const(char)* name, int size, wl_proxy* shm);
57 
58         alias da_wl_cursor_theme_destroy = void function (wl_cursor_theme* theme);
59 
60         alias da_wl_cursor_theme_get_cursor = wl_cursor* function (wl_cursor_theme* theme, const(char)* name);
61 
62         alias da_wl_cursor_image_get_buffer = wl_proxy* function (wl_cursor_image* image);
63 
64         alias da_wl_cursor_frame = int function (wl_cursor* cursor, uint time);
65 
66         alias da_wl_cursor_frame_and_duration = int function (wl_cursor* cursor, uint time, uint* duration);
67     }
68 
69     __gshared
70     {
71         da_wl_cursor_theme_load wl_cursor_theme_load;
72 
73         da_wl_cursor_theme_destroy wl_cursor_theme_destroy;
74 
75         da_wl_cursor_theme_get_cursor wl_cursor_theme_get_cursor;
76 
77         da_wl_cursor_image_get_buffer wl_cursor_image_get_buffer;
78 
79         da_wl_cursor_frame wl_cursor_frame;
80 
81         da_wl_cursor_frame_and_duration wl_cursor_frame_and_duration;
82     }
83 }
84 
85 version(WlStatic)
86 {
87     extern(C) nothrow
88     {
89         wl_cursor_theme* wl_cursor_theme_load(const(char)* name, int size, wl_proxy* shm);
90 
91         void wl_cursor_theme_destroy(wl_cursor_theme* theme);
92 
93         wl_cursor* wl_cursor_theme_get_cursor(wl_cursor_theme* theme, const(char)* name);
94 
95         wl_proxy* wl_cursor_image_get_buffer(wl_cursor_image* image);
96 
97         int wl_cursor_frame(wl_cursor* cursor, uint time);
98 
99         int wl_cursor_frame_and_duration(wl_cursor* cursor, uint time, uint* duration);
100     }
101 }