Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:41

0001 #ifndef XCB_CURSOR_H
0002 #define XCB_CURSOR_H
0003 
0004 /* Copyright © 2013 Michael Stapelberg
0005  *
0006  * Permission is hereby granted, free of charge, to any person obtaining a
0007  * copy of this software and associated documentation files (the "Software"),
0008  * to deal in the Software without restriction, including without limitation
0009  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0010  * and/or sell copies of the Software, and to permit persons to whom the
0011  * Software is furnished to do so, subject to the following conditions:
0012  *
0013  * The above copyright notice and this permission notice shall be included in
0014  * all copies or substantial portions of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0019  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0020  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0021  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0022  *
0023  * Except as contained in this notice, the names of the authors or their
0024  * institutions shall not be used in advertising or otherwise to promote the
0025  * sale, use or other dealings in this Software without prior written
0026  * authorization from the authors.
0027  */
0028 
0029 #include <xcb/xcb.h>
0030 
0031 #ifdef __cplusplus
0032 extern "C" {
0033 #endif
0034 
0035 /**
0036  * @defgroup xcb__cursor_context_t XCB Cursor Functions
0037  *
0038  * These functions are the equivalent of libXcursor, but re-implemented for
0039  * XCB. They respect the user’s configured cursor theme when loading cursors,
0040  * specified by the X resources setting "Xcursor.theme".
0041  *
0042  * Here is how you would use these functions to change the X11 root window
0043  * cursor to "watch":
0044  * @code
0045  * int screennr;
0046  * xcb_connection_t *conn = xcb_connect(NULL, &screennr);
0047  * if (conn == NULL || xcb_connection_has_error(conn))
0048  *     err(EXIT_FAILURE, "Could not connect to X11");
0049  *
0050  * xcb_screen_t *screen = xcb_aux_get_screen(conn, screennr);
0051  * xcb_cursor_context_t *ctx;
0052  * if (xcb_cursor_context_new(conn, screen, &ctx) < 0)
0053  *     err(EXIT_FAILURE, "Could not initialize xcb-cursor");
0054  *
0055  * xcb_cursor_t cid = xcb_cursor_load_cursor(ctx, "watch");
0056  *
0057  * xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
0058  * xcb_change_window_attributes(conn, screen->root, XCB_CW_CURSOR, (uint32_t[]){ cid });
0059  * xcb_free_cursor(conn, cid);
0060  * xcb_flush(conn);
0061  *
0062  * xcb_cursor_context_free(ctx);
0063  * xcb_disconnect(conn);
0064  * @endcode
0065  *
0066  * @{
0067  */
0068 
0069 /**
0070  * @struct xcb_cursor_context_t
0071  * Describes a context for using this library.
0072  *
0073  * Create a context with @ref xcb_cursor_context_new (), then load one or more
0074  * cursors with @ref xcb_cursor_load_cursor () and destroy the context with @ref
0075  * xcb_cursor_context_free ().
0076  */
0077 typedef struct xcb_cursor_context_t xcb_cursor_context_t;
0078 
0079 /**
0080  * Create a new @ref xcb_cursor_context_t.
0081  *
0082  * @param conn A working XCB connection, which will be used until you destroy
0083  * the context with @ref xcb_cursor_context_free ().
0084  * @param screen The xcb_screen_t to use (e.g. for getting the RESOURCE_MANAGER
0085  * contents, for creating cursors on, for using the size as fallback when
0086  * calculating the best cursor size).
0087  * @param ctx A pointer to an xcb_cursor_context_t* which will be modified to
0088  * refer to the newly created context.
0089  * @return 0 on success, a negative error code otherwise.
0090  *
0091  * @ingroup xcb_cursor_context_t
0092  */
0093 int xcb_cursor_context_new(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_context_t **ctx);
0094 
0095 /**
0096  * Loads the specified cursor, either from the cursor theme or by falling back
0097  * to the X11 "cursor" font.
0098  *
0099  * @param ctx A cursor context, created with @ref xcb_cursor_context_new ()
0100  * @param name The name of the cursor to load, e.g. "watch".
0101  * @returns The ID of the created cursor. When you are done using it, use
0102  * xcb_free_cursor. Calling @ref xcb_cursor_context_free () will NOT free the
0103  * created cursor.
0104  *
0105  */
0106 xcb_cursor_t xcb_cursor_load_cursor(xcb_cursor_context_t *ctx, const char *name);
0107 
0108 /**
0109  * Frees the @ref xcb_cursor_context_t.
0110  *
0111  * @param ctx The context to free.
0112  *
0113  */
0114 void xcb_cursor_context_free(xcb_cursor_context_t *ctx);
0115 
0116 /**
0117  * @}
0118  */
0119 
0120 #ifdef __cplusplus
0121 }
0122 #endif
0123 
0124 #endif