[xutil] Rewrite gettextprop() proto
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
7468bb6794
commit
de3fbffcf1
|
@ -107,7 +107,8 @@ scan()
|
|||
|
||||
/* Get the tree of the children Windows of the current root
|
||||
* Window */
|
||||
wins = xcb_query_tree_children(tree_r);
|
||||
if(!(wins = xcb_query_tree_children(tree_r)))
|
||||
eprint("E: cannot get tree children\n");
|
||||
tree_c_len = xcb_query_tree_children_length(tree_r);
|
||||
attr_wins = p_new(xcb_get_window_attributes_cookie_t, tree_c_len);
|
||||
|
||||
|
|
23
client.c
23
client.c
|
@ -54,17 +54,15 @@ client_loadprops(client_t * c, int screen)
|
|||
{
|
||||
int i, ntags = 0;
|
||||
tag_t *tag;
|
||||
char *prop;
|
||||
char *prop = NULL;
|
||||
bool result = false;
|
||||
|
||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||
ntags++;
|
||||
|
||||
prop = p_new(char, ntags + 3);
|
||||
|
||||
if(xutil_gettextprop(globalconf.connection, c->win,
|
||||
xutil_intern_atom(globalconf.connection, "_AWESOME_PROPERTIES"),
|
||||
prop, ntags + 3))
|
||||
&prop))
|
||||
{
|
||||
for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
||||
if(prop[i] == '1')
|
||||
|
@ -189,17 +187,18 @@ client_get_byname(client_t *list, char *name)
|
|||
void
|
||||
client_updatetitle(client_t *c)
|
||||
{
|
||||
char buf[512];
|
||||
char *name;
|
||||
|
||||
if(!xutil_gettextprop(globalconf.connection, c->win,
|
||||
xutil_intern_atom(globalconf.connection, "_NET_WM_NAME"),
|
||||
buf, ssizeof(buf)))
|
||||
xutil_gettextprop(globalconf.connection, c->win,
|
||||
xutil_intern_atom(globalconf.connection, "WM_NAME"),
|
||||
buf, ssizeof(buf));
|
||||
if(c->name)
|
||||
p_delete(&c->name);
|
||||
c->name = a_strndup(buf, ssizeof(buf));
|
||||
&name))
|
||||
if(!xutil_gettextprop(globalconf.connection, c->win,
|
||||
xutil_intern_atom(globalconf.connection, "WM_NAME"),
|
||||
&name))
|
||||
return;
|
||||
|
||||
p_delete(&c->name);
|
||||
c->name = name;
|
||||
titlebar_draw(c);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
}
|
||||
|
|
|
@ -35,12 +35,11 @@
|
|||
* \param w window
|
||||
* \param atom the atom
|
||||
* \param text buffer to fill
|
||||
* \param textlen buffer lenght
|
||||
* \return true on sucess, falsse on failure
|
||||
*/
|
||||
bool
|
||||
xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
|
||||
char *text, ssize_t textlen)
|
||||
char **text)
|
||||
{
|
||||
xcb_get_property_cookie_t prop_c;
|
||||
xcb_get_property_reply_t *prop_r;
|
||||
|
@ -51,7 +50,7 @@ xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
|
|||
XCB_GET_PROPERTY_TYPE_ANY,
|
||||
0L, 1000000L);
|
||||
|
||||
if(!text || !textlen)
|
||||
if(!text)
|
||||
return false;
|
||||
|
||||
prop_r = xcb_get_property_reply(conn, prop_c, NULL);
|
||||
|
@ -71,17 +70,10 @@ xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
|
|||
if(prop_r->type == STRING ||
|
||||
prop_r->type == xutil_intern_atom(conn, "UTF8_STRING"))
|
||||
{
|
||||
if((ssize_t) prop_r->value_len < textlen - 1)
|
||||
{
|
||||
/* use memcpy() because prop_val may not be \0 terminated */
|
||||
memcpy(text, prop_val, prop_r->value_len);
|
||||
text[prop_r->value_len] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(text, prop_val, textlen - 2);
|
||||
text[textlen - 1] = '\0';
|
||||
}
|
||||
*text = p_new(char, prop_r->value_len + 1);
|
||||
/* use memcpy() because prop_val may not be \0 terminated */
|
||||
memcpy(*text, prop_val, prop_r->value_len);
|
||||
(*text)[prop_r->value_len] = '\0';
|
||||
}
|
||||
|
||||
p_delete(&prop_r);
|
||||
|
@ -111,14 +103,14 @@ xutil_getlockmask(xcb_connection_t *conn, xcb_key_symbols_t *keysyms,
|
|||
kc = modmap[i * modmap_r->keycodes_per_modifier + j];
|
||||
mask = (1 << i);
|
||||
|
||||
if(numlockmask != NULL &&
|
||||
kc == xcb_key_symbols_get_keycode(keysyms, XK_Num_Lock))
|
||||
if(numlockmask != NULL
|
||||
&& kc == xcb_key_symbols_get_keycode(keysyms, XK_Num_Lock))
|
||||
*numlockmask = mask;
|
||||
else if(shiftlockmask != NULL &&
|
||||
kc == xcb_key_symbols_get_keycode(keysyms, XK_Shift_Lock))
|
||||
else if(shiftlockmask != NULL
|
||||
&& kc == xcb_key_symbols_get_keycode(keysyms, XK_Shift_Lock))
|
||||
*shiftlockmask = mask;
|
||||
else if(capslockmask != NULL &&
|
||||
kc == xcb_key_symbols_get_keycode(keysyms, XK_Caps_Lock))
|
||||
else if(capslockmask != NULL
|
||||
&& kc == xcb_key_symbols_get_keycode(keysyms, XK_Caps_Lock))
|
||||
*capslockmask = mask;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
/* XCB doesn't provide keysyms definition */
|
||||
#include <X11/keysym.h>
|
||||
|
||||
bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char *, ssize_t);
|
||||
bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **);
|
||||
void xutil_getlockmask(xcb_connection_t *, xcb_key_symbols_t *,
|
||||
unsigned int *, unsigned int *, unsigned int *);
|
||||
|
||||
|
|
6
rules.c
6
rules.c
|
@ -56,7 +56,7 @@ rule_t *
|
|||
rule_matching_client(client_t *c)
|
||||
{
|
||||
rule_t *r;
|
||||
char *prop = NULL, buf[512];
|
||||
char *prop = NULL, *buf = NULL;
|
||||
regmatch_t tmp;
|
||||
ssize_t len;
|
||||
class_hint_t *ch = NULL;
|
||||
|
@ -87,9 +87,11 @@ rule_matching_client(client_t *c)
|
|||
&& r->xpropval_r
|
||||
&& xutil_gettextprop(globalconf.connection, c->win,
|
||||
xutil_intern_atom(globalconf.connection, r->xprop),
|
||||
buf, ssizeof(buf)))
|
||||
&buf))
|
||||
ret = !regexec(r->xpropval_r, buf, 1, &tmp, 0);
|
||||
|
||||
p_delete(&buf);
|
||||
|
||||
if(ret)
|
||||
{
|
||||
p_delete(&prop);
|
||||
|
|
Loading…
Reference in New Issue