File: xcb_cursor.h

package info (click to toggle)
xcb-util-cursor 0.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,704 kB
  • ctags: 230
  • sloc: sh: 11,097; ansic: 1,015; makefile: 39
file content (123 lines) | stat: -rw-r--r-- 4,321 bytes parent folder | download | duplicates (3)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef XCB_CURSOR_H
#define XCB_CURSOR_H

/* Copyright © 2013 Michael Stapelberg
 *
 * 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 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 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.
 *
 * Except as contained in this notice, the names of the authors or their
 * institutions shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization from the authors.
 */

#include <xcb/xcb.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @defgroup xcb__cursor_context_t XCB Cursor Functions
 *
 * These functions are the equivalent of libXcursor, but re-implemented for
 * XCB. They respect the user’s configured cursor theme when loading cursors,
 * specified by the X resources setting "Xcursor.theme".
 *
 * Here is how you would use these functions to change the X11 root window
 * cursor to "watch":
 * @code
 * int screennr;
 * xcb_connection_t *conn = xcb_connect(NULL, &screennr);
 * if (conn == NULL || xcb_connection_has_error(conn))
 *     err(EXIT_FAILURE, "Could not connect to X11");
 *
 * xcb_screen_t *screen = xcb_aux_get_screen(conn, screennr);
 * xcb_cursor_context_t *ctx;
 * if (xcb_cursor_context_new(conn, screen, &ctx) < 0)
 *     err(EXIT_FAILURE, "Could not initialize xcb-cursor");
 *
 * xcb_cursor_t cid = xcb_cursor_load_cursor(ctx, "watch");
 *
 * xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
 * xcb_change_window_attributes(conn, screen->root, XCB_CW_CURSOR, (uint32_t[]){ cid });
 * xcb_flush(conn);
 *
 * xcb_cursor_context_free(ctx);
 * xcb_disconnect(conn);
 * @endcode
 *
 * @{
 */

/**
 * @struct xcb_cursor_context_t
 * Describes a context for using this library.
 *
 * Create a context with @ref xcb_cursor_context_new (), then load one or more
 * cursors with @ref xcb_cursor_load_cursor () and destroy the context with @ref
 * xcb_cursor_context_free ().
 */
typedef struct xcb_cursor_context_t xcb_cursor_context_t;

/**
 * Create a new @ref xcb_cursor_context_t.
 *
 * @param conn A working XCB connection, which will be used until you destroy
 * the context with @ref xcb_cursor_context_free ().
 * @param screen The xcb_screen_t to use (e.g. for getting the RESOURCE_MANAGER
 * contents, for creating cursors on, for using the size as fallback when
 * calculating the best cursor size).
 * @param ctx A pointer to an xcb_cursor_context_t* which will be modified to
 * refer to the newly created context.
 * @return 0 on success, a negative error code otherwise.
 *
 * @ingroup xcb_cursor_context_t
 */
int xcb_cursor_context_new(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_context_t **ctx);

/**
 * Loads the specified cursor, either from the cursor theme or by falling back
 * to the X11 "cursor" font.
 *
 * @param ctx A cursor context, created with @ref xcb_cursor_context_new ()
 * @param name The name of the cursor to load, e.g. "watch".
 * @returns The ID of the created cursor. When you are done using it, use
 * xcb_free_cursor. Calling @ref xcb_cursor_context_free () will NOT free the
 * created cursor.
 *
 */
xcb_cursor_t xcb_cursor_load_cursor(xcb_cursor_context_t *ctx, const char *name);

/**
 * Frees the @ref xcb_cursor_context_t.
 *
 * @param ctx The context to free.
 *
 */
void xcb_cursor_context_free(xcb_cursor_context_t *ctx);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif