1ecce36beSmrg/* 2ecce36beSmrg * Copyright (C) 2008 Julien Danjou <julien@danjou.info> 3ecce36beSmrg * 4ecce36beSmrg * Permission is hereby granted, free of charge, to any person 5ecce36beSmrg * obtaining a copy of this software and associated documentation 6ecce36beSmrg * files (the "Software"), to deal in the Software without 7ecce36beSmrg * restriction, including without limitation the rights to use, copy, 8ecce36beSmrg * modify, merge, publish, distribute, sublicense, and/or sell copies 9ecce36beSmrg * of the Software, and to permit persons to whom the Software is 10ecce36beSmrg * furnished to do so, subject to the following conditions: 11ecce36beSmrg * 12ecce36beSmrg * The above copyright notice and this permission notice shall be 13ecce36beSmrg * included in all copies or substantial portions of the Software. 14ecce36beSmrg * 15ecce36beSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16ecce36beSmrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17ecce36beSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18ecce36beSmrg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 19ecce36beSmrg * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20ecce36beSmrg * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21ecce36beSmrg * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22ecce36beSmrg * 23ecce36beSmrg * Except as contained in this notice, the names of the authors or 24ecce36beSmrg * their institutions shall not be used in advertising or otherwise to 25ecce36beSmrg * promote the sale, use or other dealings in this Software without 26ecce36beSmrg * prior written authorization from the authors. 27ecce36beSmrg */ 28ecce36beSmrg 29ecce36beSmrg/** 30ecce36beSmrg * @defgroup xcb__property_t XCB Property Functions 31ecce36beSmrg * 32ecce36beSmrg * These functions ease the handling of X propertiess received. 33ecce36beSmrg * 34ecce36beSmrg * @{ 35ecce36beSmrg */ 36ecce36beSmrg 37ecce36beSmrg#ifndef __XCB_PROPERTY_H__ 38ecce36beSmrg#define __XCB_PROPERTY_H__ 39ecce36beSmrg 40ecce36beSmrg#include "xcb_event.h" 41ecce36beSmrg 42ecce36beSmrg#ifdef __cplusplus 43ecce36beSmrgextern "C" { 44ecce36beSmrg#endif 45ecce36beSmrg 46ecce36beSmrgtypedef struct xcb_property_handlers xcb_property_handlers_t; 47ecce36beSmrgtypedef int (*xcb_generic_property_handler_t)(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property); 48ecce36beSmrg 49ecce36beSmrgtypedef struct { 50ecce36beSmrg uint32_t long_len; 51ecce36beSmrg xcb_generic_property_handler_t handler; 52ecce36beSmrg void *data; 53ecce36beSmrg} xcb_property_handler_t; 54ecce36beSmrg 55ecce36beSmrgtypedef struct xcb_property_handler_node xcb_property_handler_node_t; 56ecce36beSmrgstruct xcb_property_handler_node { 57ecce36beSmrg xcb_property_handler_node_t *next; 58ecce36beSmrg xcb_atom_t name; 59ecce36beSmrg xcb_property_handler_t h; 60ecce36beSmrg}; 61ecce36beSmrg 62ecce36beSmrgstruct xcb_property_handlers { 63ecce36beSmrg xcb_property_handler_node_t *head; 64ecce36beSmrg xcb_property_handler_t def; 65ecce36beSmrg xcb_event_handlers_t *evenths; 66ecce36beSmrg}; 67ecce36beSmrg 68ecce36beSmrg/** 69ecce36beSmrg * @brief Get any property from a window, from any format. 70ecce36beSmrg * @param c The connection to the X server. 71ecce36beSmrg * @param del Boolean value that determines whether the property is deleted. 72ecce36beSmrg * @param window The window to get property from. 73ecce36beSmrg * @param name The property atom name. 74ecce36beSmrg * @param long_len The maximum length of the property. 75ecce36beSmrg * @return A cookie. 76ecce36beSmrg */ 77ecce36beSmrgxcb_get_property_cookie_t xcb_get_any_property(xcb_connection_t *c, 78ecce36beSmrg uint8_t del, 79ecce36beSmrg xcb_window_t window, 80ecce36beSmrg xcb_atom_t name, 81ecce36beSmrg uint32_t long_len); 82ecce36beSmrg 83ecce36beSmrg/** 84ecce36beSmrg * @see xcb_get_any_property 85ecce36beSmrg */ 86ecce36beSmrgxcb_get_property_cookie_t xcb_get_any_property_unchecked(xcb_connection_t *c, 87ecce36beSmrg uint8_t del, 88ecce36beSmrg xcb_window_t window, 89ecce36beSmrg xcb_atom_t name, 90ecce36beSmrg uint32_t long_len); 91ecce36beSmrg/** 92ecce36beSmrg * @brief Initialize a property handlers structure. 93ecce36beSmrg * @param prophs The property handlers data structure pointer. 94ecce36beSmrg * @param evenths The event handlers. 95ecce36beSmrg */ 96ecce36beSmrgvoid xcb_property_handlers_init(xcb_property_handlers_t *prophs, xcb_event_handlers_t *evenths); 97ecce36beSmrg 98ecce36beSmrg/** 99ecce36beSmrg * @brief Wipe a property handler structure. 100ecce36beSmrg * @param prophs The property handlers data structure pointer. 101ecce36beSmrg */ 102ecce36beSmrgvoid xcb_property_handlers_wipe(xcb_property_handlers_t *prophs); 103ecce36beSmrg 104ecce36beSmrg/** 105ecce36beSmrg * @brief Get a event handlers from a property handlers data structure. 106ecce36beSmrg * @param prophs The property handlers. 107ecce36beSmrg * @return The event handlers data structure which was set if any, NULL 108ecce36beSmrg * otherwise. 109ecce36beSmrg */ 110ecce36beSmrgxcb_event_handlers_t *xcb_property_get_event_handlers(xcb_property_handlers_t *prophs); 111ecce36beSmrg 112ecce36beSmrg/** 113ecce36beSmrg * @brief Set a property handler for an event. 114ecce36beSmrg * @param prophs The property handlers. 115ecce36beSmrg * @param name The property atom name. 116ecce36beSmrg * @param long_len The maximum length of the property value that will be 117ecce36beSmrg * handled. 118ecce36beSmrg * @param handler The handler callback function. 119ecce36beSmrg * @param data Optional data that will be passed as argument of the handler 120ecce36beSmrg * callback function. Can be NULL safely if you do not need it. 121ecce36beSmrg * @return Return 1 on success, 0 otherwise. 122ecce36beSmrg */ 123ecce36beSmrguint8_t xcb_property_set_handler(xcb_property_handlers_t *prophs, 124ecce36beSmrg xcb_atom_t name, 125ecce36beSmrg uint32_t long_len, 126ecce36beSmrg xcb_generic_property_handler_t handler, 127ecce36beSmrg void *data); 128ecce36beSmrg 129ecce36beSmrg/** 130ecce36beSmrg * @brief Set the default property handler. 131ecce36beSmrg * If a property does not have its own handler function, this one will be 132ecce36beSmrg * used. 133ecce36beSmrg * @param prophs The property handlers. 134ecce36beSmrg * @param name The property atom name. 135ecce36beSmrg * @param long_len The maximum length of the property value that will be 136ecce36beSmrg * handled. 137ecce36beSmrg * @param handler The handler callback function. 138ecce36beSmrg * @param data Optional data that will be passed as argument of the handler 139ecce36beSmrg * callback function. Can be NULL safely if you do not need it. 140ecce36beSmrg * @return Return 1 on success, 0 otherwise. 141ecce36beSmrg */ 142ecce36beSmrguint8_t xcb_property_set_default_handler(xcb_property_handlers_t *prophs, uint32_t long_len, xcb_generic_property_handler_t handler, void *data); 143ecce36beSmrg 144ecce36beSmrg/** 145ecce36beSmrg * @brief Notify that a property has changed and call handler function callback as needed. 146ecce36beSmrg * @param prophs The property handlers. 147ecce36beSmrg * @param state The property state. 148ecce36beSmrg * @param window The window. 149ecce36beSmrg * @param atom The property atom name. 150ecce36beSmrg */ 151ecce36beSmrgint xcb_property_changed(xcb_property_handlers_t *prophs, uint8_t state, xcb_window_t window, xcb_atom_t atom); 152ecce36beSmrg 153ecce36beSmrg#ifdef __cplusplus 154ecce36beSmrg} 155ecce36beSmrg#endif 156ecce36beSmrg 157ecce36beSmrg/** 158ecce36beSmrg * @} 159ecce36beSmrg */ 160ecce36beSmrg 161ecce36beSmrg#endif /* __XCB_PROPERTY_H__ */ 162