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
|
|
|
*
|
2009-04-26 12:34:13 +02:00
|
|
|
* Copyright © 2007-2009 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 <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>
|
2009-08-22 15:04:56 +02:00
|
|
|
#include <xcb/xcb_atom.h>
|
2010-08-08 18:31:07 +02:00
|
|
|
#include <xcb/xproto.h>
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2009-08-22 15:04:56 +02:00
|
|
|
#include "common/array.h"
|
|
|
|
#include "common/atoms.h"
|
|
|
|
|
2009-08-24 10:23:03 +02:00
|
|
|
static inline char *
|
2009-08-22 15:04:56 +02:00
|
|
|
xutil_get_text_property_from_reply(xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
if(reply
|
2010-08-08 18:31:07 +02:00
|
|
|
&& (reply->type == XCB_ATOM_STRING
|
2009-08-22 15:04:56 +02:00
|
|
|
|| reply->type == UTF8_STRING
|
|
|
|
|| reply->type == COMPOUND_TEXT)
|
|
|
|
&& reply->format == 8
|
|
|
|
&& xcb_get_property_value_length(reply))
|
2009-08-24 12:03:29 +02:00
|
|
|
{
|
|
|
|
/* We need to copy it that way since the string may not be
|
|
|
|
* NULL-terminated */
|
|
|
|
int len = xcb_get_property_value_length(reply);
|
|
|
|
char *value = p_new(char, len + 1);
|
|
|
|
memcpy(value, xcb_get_property_value(reply), len);
|
|
|
|
value[len] = '\0';
|
|
|
|
return value;
|
|
|
|
}
|
2009-08-22 15:04:56 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2009-04-28 18:17:16 +02:00
|
|
|
void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_t,
|
|
|
|
xcb_key_symbols_t *,
|
|
|
|
uint16_t *, uint16_t *, uint16_t *, uint16_t *);
|
|
|
|
|
2009-04-15 14:03:17 +02:00
|
|
|
uint16_t xutil_key_mask_fromstr(const char *, size_t);
|
2009-04-25 15:59:22 +02:00
|
|
|
void xutil_key_mask_tostr(uint16_t, const char **, size_t *);
|
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
|
|
|
}
|
|
|
|
|
2008-10-06 11:42:02 +02:00
|
|
|
int xutil_root2screen(xcb_connection_t *, xcb_window_t);
|
|
|
|
|
2007-11-17 20:53:31 +01:00
|
|
|
#endif
|
2012-03-25 17:41:12 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|