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-06-17 16:55:24 +02:00
|
|
|
#include <xcb/xcb_aux.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-06-27 12:08:19 +02:00
|
|
|
#include "array.h"
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-08-11 13:27:28 +02:00
|
|
|
#define XUTIL_MASK_CLEAN(mask) (mask & ~(globalconf.numlockmask | XCB_MOD_MASK_LOCK))
|
2008-06-26 22:38:46 +02:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
/* See http://tronche.com/gui/x/xlib/appendix/b/ for values */
|
2008-08-11 13:27:28 +02:00
|
|
|
#define XUTIL_CURSOR_FLEUR 52
|
|
|
|
#define XUTIL_CURSOR_LEFT_PTR 68
|
|
|
|
#define XUTIL_CURSOR_SIZING 120
|
|
|
|
#define XUTIL_CURSOR_BOTTOM_LEFT_CORNER 12
|
|
|
|
#define XUTIL_CURSOR_BOTTOM_RIGHT_CORNER 14
|
|
|
|
#define XUTIL_CURSOR_TOP_LEFT_CORNER 134
|
|
|
|
#define XUTIL_CURSOR_TOP_RIGHT_CORNER 136
|
|
|
|
#define XUTIL_CURSOR_DOUBLE_ARROW_HORIZ 108
|
|
|
|
#define XUTIL_CURSOR_DOUBLE_ARROW_VERT 116
|
|
|
|
|
|
|
|
/* Special Key Code, passed to GrabKey */
|
|
|
|
#define XUTIL_ANY_KEY 0L
|
|
|
|
|
|
|
|
/* Used in Grabbutton_t, GrabKey */
|
|
|
|
#define XUTIL_ANY_MODIFIER (1<<15)
|
|
|
|
|
|
|
|
/* X error codes */
|
|
|
|
|
|
|
|
/* Everything's okay */
|
|
|
|
#define XUTIL_SUCCESS 0
|
|
|
|
/* Bad request code */
|
|
|
|
#define XUTIL_BAD_REQUEST 1
|
|
|
|
/* Int parameter out of range */
|
|
|
|
#define XUTIL_BAD_VALUE 2
|
|
|
|
/* Parameter not a Window */
|
|
|
|
#define XUTIL_BAD_WINDOW 3
|
|
|
|
/* Parameter not a Pixmap */
|
|
|
|
#define XUTIL_BAD_PIXMAP 4
|
|
|
|
/* Parameter not an Atom */
|
|
|
|
#define XUTIL_BAD_ATOM 5
|
|
|
|
/* Parameter not a Cursor */
|
|
|
|
#define XUTIL_BAD_CURSOR 6
|
|
|
|
/* Parameter not a Font */
|
|
|
|
#define XUTIL_BAD_FONT 7
|
|
|
|
/* Parameter mismatch */
|
|
|
|
#define XUTIL_BAD_MATCH 8
|
|
|
|
/* Parameter not a Pixmap or Window */
|
|
|
|
#define XUTIL_BAD_DRAWABLE 9
|
|
|
|
/* 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 XUTIL_BAD_ACCESS 10
|
|
|
|
/* Insufficient resources */
|
|
|
|
#define XUTIL_BAD_ALLOC 11
|
|
|
|
/* No such colormap */
|
|
|
|
#define XUTIL_BAD_COLOR 12
|
|
|
|
/* Parameter not a GC */
|
|
|
|
#define XUTIL_BAD_GC 13
|
|
|
|
/* Choice not in range or already used */
|
|
|
|
#define XUTIL_BAD_ID_CHOICE 14
|
|
|
|
/* Font or color name doesn't exist */
|
|
|
|
#define XUTIL_BAD_NAME 15
|
|
|
|
/* Request length incorrect */
|
|
|
|
#define XUTIL_BAD_LENGTH 16
|
|
|
|
/* Server is defective */
|
|
|
|
#define XUTIL_BAD_IMPLEMENTATION 17
|
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;
|
2008-07-01 21:56:53 +02:00
|
|
|
} xutil_class_hint_t;
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-08-11 13:27:28 +02:00
|
|
|
bool xutil_class_hint_get(xcb_connection_t *, xcb_window_t, xutil_class_hint_t *);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-08-11 13:27:28 +02:00
|
|
|
bool xutil_text_prop_get(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **, ssize_t *);
|
2008-05-11 00:30:20 +02:00
|
|
|
|
2008-08-13 01:37:12 +02:00
|
|
|
void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_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 */
|
2008-08-11 13:27:28 +02:00
|
|
|
void xutil_error_handler_catch_all_set(xcb_event_handlers_t *,
|
2008-03-27 16:51:24 +01:00
|
|
|
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;
|
|
|
|
|
2008-08-11 13:27:28 +02:00
|
|
|
xutil_error_t *xutil_error_get(const xcb_generic_error_t *);
|
|
|
|
void xutil_error_delete(xutil_error_t *);
|
|
|
|
xcb_keysym_t xutil_key_mask_fromstr(const char *);
|
2008-05-20 15:39:47 +02:00
|
|
|
unsigned int xutil_button_fromint(int);
|
2008-06-08 10:08:44 +02:00
|
|
|
xcb_cursor_t xutil_cursor_new(xcb_connection_t *, unsigned int);
|
2008-03-27 16:51:24 +01:00
|
|
|
|
2008-06-17 16:55:24 +02:00
|
|
|
/* Get the informations about the screen.
|
|
|
|
* \param c X connection.
|
|
|
|
* \param screen Screen number.
|
|
|
|
* \return Screen informations (must not be freed!).
|
|
|
|
*/
|
|
|
|
static inline xcb_screen_t *
|
|
|
|
xutil_screen_get(xcb_connection_t *c, int screen)
|
|
|
|
{
|
2008-07-31 17:29:05 +02:00
|
|
|
xcb_screen_t *s;
|
|
|
|
|
2008-06-17 16:55:24 +02:00
|
|
|
if(xcb_connection_has_error(c))
|
2008-06-19 09:45:08 +02:00
|
|
|
fatal("X connection invalid");
|
2008-06-17 16:55:24 +02:00
|
|
|
|
2008-07-31 17:29:05 +02:00
|
|
|
s = xcb_aux_get_screen(c, screen);
|
|
|
|
|
|
|
|
assert(s);
|
|
|
|
|
|
|
|
return s;
|
2008-06-17 16:55:24 +02: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
|