1 /* 2 * Copyright © 2012 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial 14 * portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 */ 25 26 /* 27 * This is a stable interface of wlroots. Future changes will be limited to: 28 * 29 * - New functions 30 * - New struct members 31 * - New enum members 32 * 33 * Note that wlroots does not make an ABI compatibility promise - in the future, 34 * the layout and size of structs used by wlroots may change, requiring code 35 * depending on this header to be recompiled (but not edited). 36 * 37 * Breaking changes are announced by email and follow a 1-year deprecation 38 * schedule. Send an email to ~sircmpwn/wlroots-announce+subscribe@lists.sr.ht 39 * to receive these announcements. 40 */ 41 42 #ifndef WLR_XCURSOR_H 43 #define WLR_XCURSOR_H 44 45 #include <stdint.h> 46 #include <wlr/util/edges.h> 47 48 struct wlr_xcursor_image { 49 uint32_t width; /* actual width */ 50 uint32_t height; /* actual height */ 51 uint32_t hotspot_x; /* hot spot x (must be inside image) */ 52 uint32_t hotspot_y; /* hot spot y (must be inside image) */ 53 uint32_t delay; /* animation delay to next frame (ms) */ 54 uint8_t *buffer; 55 }; 56 57 struct wlr_xcursor { 58 unsigned int image_count; 59 struct wlr_xcursor_image **images; 60 char *name; 61 uint32_t total_delay; /* length of the animation in ms */ 62 }; 63 64 /** 65 * Container for an Xcursor theme. 66 */ 67 struct wlr_xcursor_theme { 68 unsigned int cursor_count; 69 struct wlr_xcursor **cursors; 70 char *name; 71 int size; 72 }; 73 74 /** 75 * Loads the named xcursor theme at the given cursor size (in pixels). This is 76 * useful if you need cursor images for your compositor to use when a 77 * client-side cursors is not available or you wish to override client-side 78 * cursors for a particular UI interaction (such as using a grab cursor when 79 * moving a window around). 80 */ 81 struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size); 82 83 void wlr_xcursor_theme_destroy(struct wlr_xcursor_theme *theme); 84 85 /** 86 * Obtains a wlr_xcursor image for the specified cursor name (e.g. "left_ptr"). 87 */ 88 struct wlr_xcursor *wlr_xcursor_theme_get_cursor( 89 struct wlr_xcursor_theme *theme, const char *name); 90 91 /** 92 * Returns the current frame number for an animated cursor give a monotonic time 93 * reference. 94 */ 95 int wlr_xcursor_frame(struct wlr_xcursor *cursor, uint32_t time); 96 97 /** 98 * Get the name of the resize cursor image for the given edges. 99 */ 100 const char *wlr_xcursor_get_resize_name(enum wlr_edges edges); 101 102 #endif 103