rename gettextprop to xgettextprop and move it to util.c
This commit is contained in:
parent
57785860b7
commit
28df49c3cb
35
awesome.c
35
awesome.c
|
@ -45,40 +45,7 @@ DC dc;
|
|||
/* static */
|
||||
|
||||
static int (*xerrorxlib) (Display *, XErrorEvent *);
|
||||
static Bool readin = True;
|
||||
static Bool running = True;
|
||||
|
||||
|
||||
Bool
|
||||
gettextprop(Display *disp, Window w, Atom atom, char *text, unsigned int size)
|
||||
{
|
||||
char **list = NULL;
|
||||
int n;
|
||||
|
||||
XTextProperty name;
|
||||
|
||||
if(!text || size == 0)
|
||||
return False;
|
||||
|
||||
text[0] = '\0';
|
||||
XGetTextProperty(disp, w, &name, atom);
|
||||
|
||||
if(!name.nitems)
|
||||
return False;
|
||||
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(text, (char *) name.value, size - 1);
|
||||
else if(XmbTextPropertyToTextList(disp, &name, &list, &n) >= Success && n > 0 && *list)
|
||||
{
|
||||
strncpy(text, *list, size - 1);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
|
||||
text[size - 1] = '\0';
|
||||
XFree(name.value);
|
||||
|
||||
return True;
|
||||
}
|
||||
static Bool readin = True, running = True;
|
||||
|
||||
static void
|
||||
cleanup(Display *disp, awesome_config *awesomeconf)
|
||||
|
|
6
client.c
6
client.c
|
@ -194,8 +194,8 @@ attach(Client * c)
|
|||
inline void
|
||||
updatetitle(Client * c)
|
||||
{
|
||||
if(!gettextprop(c->display, c->win, XInternAtom(c->display, "_NET_WM_NAME", False), c->name, sizeof c->name))
|
||||
gettextprop(c->display, c->win, XInternAtom(c->display, "WM_NAME", False), c->name, sizeof c->name);
|
||||
if(!xgettextprop(c->display, c->win, XInternAtom(c->display, "_NET_WM_NAME", False), c->name, sizeof c->name))
|
||||
xgettextprop(c->display, c->win, XInternAtom(c->display, "WM_NAME", False), c->name, sizeof c->name);
|
||||
}
|
||||
|
||||
/** Ban client
|
||||
|
@ -328,7 +328,7 @@ loadprops(Client * c, int ntags)
|
|||
|
||||
prop = p_new(char, ntags + 2);
|
||||
|
||||
if(gettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
|
||||
if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
|
||||
{
|
||||
for(i = 0; i < ntags && prop[i]; i++)
|
||||
if((c->tags[i] = prop[i] == '1'))
|
||||
|
|
2
layout.c
2
layout.c
|
@ -96,7 +96,7 @@ loadawesomeprops(Display *disp, awesome_config * awesomeconf)
|
|||
|
||||
prop = p_new(char, awesomeconf->ntags + 1);
|
||||
|
||||
if(gettextprop(disp, DefaultRootWindow(disp), AWESOMEPROPS_ATOM(disp), prop, awesomeconf->ntags + 1))
|
||||
if(xgettextprop(disp, DefaultRootWindow(disp), AWESOMEPROPS_ATOM(disp), prop, awesomeconf->ntags + 1))
|
||||
for(i = 0; i < awesomeconf->ntags && prop[i]; i++)
|
||||
awesomeconf->selected_tags[i] = prop[i] == '1';
|
||||
|
||||
|
|
35
util.c
35
util.c
|
@ -25,6 +25,9 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
|
@ -66,3 +69,35 @@ spawn(Display * disp,
|
|||
}
|
||||
wait(0);
|
||||
}
|
||||
|
||||
Bool
|
||||
xgettextprop(Display *disp, Window w, Atom atom, char *text, unsigned int size)
|
||||
{
|
||||
char **list = NULL;
|
||||
int n;
|
||||
|
||||
XTextProperty name;
|
||||
|
||||
if(!text || size == 0)
|
||||
return False;
|
||||
|
||||
text[0] = '\0';
|
||||
XGetTextProperty(disp, w, &name, atom);
|
||||
|
||||
if(!name.nitems)
|
||||
return False;
|
||||
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(text, (char *) name.value, size - 1);
|
||||
|
||||
else if(XmbTextPropertyToTextList(disp, &name, &list, &n) >= Success && n > 0 && *list)
|
||||
{
|
||||
strncpy(text, *list, size - 1);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
|
||||
text[size - 1] = '\0';
|
||||
XFree(name.value);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
|
6
util.h
6
util.h
|
@ -83,9 +83,6 @@ xrealloc(void **ptr, ssize_t newsize)
|
|||
}
|
||||
}
|
||||
|
||||
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||
void spawn(Display *, awesome_config *, const char *);
|
||||
|
||||
static inline void *xmemdup(const void *src, ssize_t size)
|
||||
{
|
||||
return memcpy(xmalloc(size), src, size);
|
||||
|
@ -121,5 +118,8 @@ static inline char *a_strdup(const char *s)
|
|||
return len ? p_dup(s, len + 1) : NULL;
|
||||
}
|
||||
|
||||
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||
void spawn(Display *, awesome_config *, const char *);
|
||||
Bool xgettextprop(Display *, Window, Atom, char *, unsigned int);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue