2007-11-17 20:53:31 +01:00
|
|
|
/*
|
2008-03-04 20:39:21 +01:00
|
|
|
* common/xutil.h - X-related useful functions header
|
2007-11-17 20:53:31 +01:00
|
|
|
*
|
2008-03-04 20:39:21 +01:00
|
|
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
2007-11-17 20:53:31 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
#ifndef AWESOME_COMMON_XUTIL_H
|
|
|
|
#define AWESOME_COMMON_XUTIL_H
|
2007-11-17 20:53:31 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
#include <stdbool.h>
|
2007-11-17 20:53:31 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
#include <xcb/xcb.h>
|
2008-03-24 00:48:42 +01:00
|
|
|
#include <xcb/xcb_keysyms.h>
|
2008-03-27 16:51:24 +01:00
|
|
|
#include <xcb/xcb_event.h>
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
/* XCB doesn't provide keysyms definition */
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2008-05-11 00:30:20 +02:00
|
|
|
#include "common/list.h"
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
/* See http://tronche.com/gui/x/xlib/appendix/b/ for values */
|
|
|
|
#define CURSOR_FLEUR 52
|
|
|
|
#define CURSOR_LEFT_PTR 68
|
|
|
|
#define CURSOR_SIZING 120
|
|
|
|
|
|
|
|
#define ANY_KEY 0L /* special Key Code, passed to GrabKey */
|
|
|
|
#define ANY_MODIFIER (1<<15) /* used in GrabButton, GrabKey */
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* ERROR CODES
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
#define Success 0 /* everything's okay */
|
|
|
|
#define BadRequest 1 /* bad request code */
|
|
|
|
#define BadValue 2 /* int parameter out of range */
|
|
|
|
#define BadWindow 3 /* parameter not a Window */
|
|
|
|
#define BadPixmap 4 /* parameter not a Pixmap */
|
|
|
|
#define BadAtom 5 /* parameter not an Atom */
|
|
|
|
#define BadCursor 6 /* parameter not a Cursor */
|
|
|
|
#define BadFont 7 /* parameter not a Font */
|
|
|
|
#define BadMatch 8 /* parameter mismatch */
|
|
|
|
#define BadDrawable 9 /* parameter not a Pixmap or Window */
|
|
|
|
#define BadAccess 10 /* depending on context:
|
|
|
|
- key/button already grabbed
|
|
|
|
- attempt to free an illegal
|
|
|
|
cmap entry
|
|
|
|
- attempt to store into a read-only
|
|
|
|
color map entry.
|
|
|
|
- attempt to modify the access control
|
|
|
|
list from other than the local host.
|
|
|
|
*/
|
|
|
|
#define BadAlloc 11 /* insufficient resources */
|
|
|
|
#define BadColor 12 /* no such colormap */
|
|
|
|
#define BadGC 13 /* parameter not a GC */
|
|
|
|
#define BadIDChoice 14 /* choice not in range or already used */
|
|
|
|
#define BadName 15 /* font or color name doesn't exist */
|
|
|
|
#define BadLength 16 /* Request length incorrect */
|
|
|
|
#define BadImplementation 17 /* server is defective */
|
|
|
|
|
|
|
|
#define FirstExtensionError 128
|
|
|
|
#define LastExtensionError 255
|
|
|
|
/* End of macros not defined in XCB */
|
|
|
|
|
|
|
|
/* Common function defined in Xlib but not in XCB */
|
2008-03-26 19:58:30 +01:00
|
|
|
bool xutil_get_transient_for_hint(xcb_connection_t *, xcb_window_t, xcb_window_t *);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-05-11 00:30:20 +02:00
|
|
|
typedef struct
|
2008-03-21 16:50:17 +01:00
|
|
|
{
|
|
|
|
char *res_name;
|
|
|
|
char *res_class;
|
|
|
|
} class_hint_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t pixel;
|
|
|
|
uint16_t red;
|
|
|
|
uint16_t green;
|
|
|
|
uint16_t blue;
|
|
|
|
} xcolor_t;
|
|
|
|
|
2008-03-26 19:58:30 +01:00
|
|
|
class_hint_t *xutil_get_class_hint(xcb_connection_t *, xcb_window_t);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-05-11 00:30:20 +02:00
|
|
|
/** Cache entry */
|
|
|
|
typedef struct xutil_atom_cache_t xutil_atom_cache_t;
|
|
|
|
struct xutil_atom_cache_t
|
|
|
|
{
|
|
|
|
/** Atom X identifier */
|
|
|
|
xcb_atom_t atom;
|
|
|
|
/** Atom name */
|
|
|
|
char *name;
|
|
|
|
/** Next and previous atom cache entries */
|
|
|
|
xutil_atom_cache_t *prev, *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** InternAtom request data structure which may hold the cookie if the
|
|
|
|
* atom is not already present in the cache */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* Cache hit */
|
|
|
|
bool cache_hit;
|
|
|
|
/* Atom string name */
|
|
|
|
char *name;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
/* Cookie of the InternAtom request */
|
|
|
|
xcb_intern_atom_cookie_t cookie;
|
|
|
|
/* Cache entry */
|
|
|
|
xutil_atom_cache_t *cache;
|
|
|
|
};
|
|
|
|
} xutil_intern_atom_request_t;
|
|
|
|
|
|
|
|
/* InternATom request which relies on a cache stored as a ordered
|
|
|
|
* linked-list */
|
|
|
|
xutil_intern_atom_request_t xutil_intern_atom(xcb_connection_t *, xutil_atom_cache_t **,
|
|
|
|
const char *);
|
|
|
|
|
|
|
|
/** Treat reply from InternAtom request */
|
|
|
|
xcb_atom_t xutil_intern_atom_reply(xcb_connection_t *, xutil_atom_cache_t **,
|
|
|
|
xutil_intern_atom_request_t);
|
|
|
|
|
|
|
|
/** Delete a entry in the cache */
|
|
|
|
void xutil_atom_cache_delete(xutil_atom_cache_t **);
|
|
|
|
|
|
|
|
/** Cache list utils functions */
|
|
|
|
DO_SLIST(xutil_atom_cache_t, atom_cache, xutil_atom_cache_delete)
|
|
|
|
|
|
|
|
bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xutil_atom_cache_t **,
|
|
|
|
xcb_atom_t, char **);
|
|
|
|
|
|
|
|
void xutil_getlockmask(xcb_connection_t *, xcb_key_symbols_t *,
|
|
|
|
unsigned int *, unsigned int *, unsigned int *);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-03-27 16:51:24 +01:00
|
|
|
/** Set the same handler for all errors */
|
|
|
|
void xutil_set_error_handler_catch_all(xcb_event_handlers_t *,
|
|
|
|
xcb_generic_error_handler_t, void *);
|
|
|
|
|
2008-05-11 00:30:20 +02:00
|
|
|
typedef struct
|
2008-03-27 16:51:24 +01:00
|
|
|
{
|
|
|
|
uint8_t request_code;
|
|
|
|
char *request_label;
|
|
|
|
char *error_label;
|
|
|
|
} xutil_error_t;
|
|
|
|
|
|
|
|
xutil_error_t *xutil_get_error(const xcb_generic_error_t *);
|
|
|
|
void xutil_delete_error(xutil_error_t *);
|
2008-05-20 15:39:47 +02:00
|
|
|
xcb_keysym_t xutil_keymask_fromstr(const char *);
|
|
|
|
unsigned int xutil_button_fromint(int);
|
2008-03-27 16:51:24 +01:00
|
|
|
|
2007-11-17 20:53:31 +01:00
|
|
|
#endif
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|