/* * Copyright © 2012 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial * portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "config.h" #include "xcursor.h" #include "wayland-cursor.h" #include "wayland-client.h" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <fcntl.h> #include <errno.h> #include "os-compatibility.h" #define ARRAY_LENGTH(a) … struct shm_pool { … }; static struct shm_pool * shm_pool_create(struct wl_shm *shm, int size) { … } static int shm_pool_resize(struct shm_pool *pool, int size) { … } static int shm_pool_allocate(struct shm_pool *pool, int size) { … } static void shm_pool_destroy(struct shm_pool *pool) { … } struct wl_cursor_theme { … }; struct cursor_image { … }; struct cursor { … }; /** Get an shm buffer for a cursor image * * \param image The cursor image * \return An shm buffer for the cursor image. The user should not destroy * the returned buffer. */ WL_EXPORT struct wl_buffer * wl_cursor_image_get_buffer(struct wl_cursor_image *image) { … } static void wl_cursor_image_destroy(struct wl_cursor_image *image) { … } static void wl_cursor_destroy(struct wl_cursor *cursor) { … } #include "cursor-data.h" static struct wl_cursor * wl_cursor_create_from_data(struct cursor_metadata *metadata, struct wl_cursor_theme *theme) { … } static void load_fallback_theme(struct wl_cursor_theme *theme) { … } static struct wl_cursor * wl_cursor_create_from_xcursor_images(struct xcursor_images *images, struct wl_cursor_theme *theme) { … } static void load_callback(struct xcursor_images *images, void *data) { … } /** Load a cursor theme to memory shared with the compositor * * \param name The name of the cursor theme to load. If %NULL, the default * theme will be loaded. * \param size Desired size of the cursor images. * \param shm The compositor's shm interface. * * \return An object representing the theme that should be destroyed with * wl_cursor_theme_destroy() or %NULL on error. If no theme with the given * name exists, a default theme will be loaded. */ WL_EXPORT struct wl_cursor_theme * wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm) { … } /** Destroys a cursor theme object * * \param theme The cursor theme to be destroyed */ WL_EXPORT void wl_cursor_theme_destroy(struct wl_cursor_theme *theme) { … } /** Get the cursor for a given name from a cursor theme * * \param theme The cursor theme * \param name Name of the desired cursor * \return The theme's cursor of the given name or %NULL if there is no * such cursor */ WL_EXPORT struct wl_cursor * wl_cursor_theme_get_cursor(struct wl_cursor_theme *theme, const char *name) { … } /** Find the frame for a given elapsed time in a cursor animation * as well as the time left until next cursor change. * * \param cursor The cursor * \param time Elapsed time in ms since the beginning of the animation * \param duration pointer to uint32_t to store time left for this image or * zero if the cursor won't change. * * \return The index of the image that should be displayed for the * given time in the cursor animation. */ WL_EXPORT int wl_cursor_frame_and_duration(struct wl_cursor *cursor, uint32_t time, uint32_t *duration) { … } /** Find the frame for a given elapsed time in a cursor animation * * \param cursor The cursor * \param time Elapsed time in ms since the beginning of the animation * * \return The index of the image that should be displayed for the * given time in the cursor animation. */ WL_EXPORT int wl_cursor_frame(struct wl_cursor *cursor, uint32_t time) { … }