prepared merging layout.c and tag.c into screen.c
This commit is contained in:
parent
78d1a22d4e
commit
96d7fe16ea
4 changed files with 37 additions and 44 deletions
34
client.c
34
client.c
|
@ -185,15 +185,8 @@ Bool
|
||||||
loadprops(Client *c) {
|
loadprops(Client *c) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Bool result = False;
|
Bool result = False;
|
||||||
XTextProperty name;
|
|
||||||
|
|
||||||
/* check if window has set a property */
|
if(gettextprop(c->win, dwmprops, prop, sizeof prop)) {
|
||||||
name.nitems = 0;
|
|
||||||
XGetTextProperty(dpy, c->win, &name, dwmprops);
|
|
||||||
if(name.nitems && name.encoding == XA_STRING) {
|
|
||||||
strncpy(prop, (char *)name.value, sizeof prop - 1);
|
|
||||||
prop[sizeof prop - 1] = '\0';
|
|
||||||
XFree(name.value);
|
|
||||||
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
|
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
|
||||||
if((c->tags[i] = prop[i] == '1'))
|
if((c->tags[i] = prop[i] == '1'))
|
||||||
result = True;
|
result = True;
|
||||||
|
@ -424,27 +417,6 @@ updatesizehints(Client *c) {
|
||||||
|
|
||||||
void
|
void
|
||||||
updatetitle(Client *c) {
|
updatetitle(Client *c) {
|
||||||
char **list = NULL;
|
if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
|
||||||
int n;
|
gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
|
||||||
XTextProperty name;
|
|
||||||
|
|
||||||
name.nitems = 0;
|
|
||||||
c->name[0] = 0;
|
|
||||||
XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
|
|
||||||
if(!name.nitems)
|
|
||||||
XGetWMName(dpy, c->win, &name);
|
|
||||||
if(!name.nitems)
|
|
||||||
return;
|
|
||||||
if(name.encoding == XA_STRING)
|
|
||||||
strncpy(c->name, (char *)name.value, sizeof c->name - 1);
|
|
||||||
else {
|
|
||||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
|
||||||
&& n > 0 && *list)
|
|
||||||
{
|
|
||||||
strncpy(c->name, *list, sizeof c->name - 1);
|
|
||||||
XFreeStringList(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c->name[sizeof c->name - 1] = '\0';
|
|
||||||
XFree(name.value);
|
|
||||||
}
|
}
|
||||||
|
|
4
dwm.h
4
dwm.h
|
@ -39,7 +39,7 @@ enum { BarTop, BarBot, BarOff }; /* bar position */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||||
enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
|
||||||
|
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
|
@ -131,6 +131,8 @@ void togglebar(const char *arg); /* shows/hides the bar */
|
||||||
void togglemax(const char *arg); /* toggles maximization of floating client */
|
void togglemax(const char *arg); /* toggles maximization of floating client */
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
|
Bool gettextprop(Window w, Atom atom,
|
||||||
|
char *text, unsigned int size); /* return text property, UTF-8 compliant */
|
||||||
void updatebarpos(void); /* updates the bar position */
|
void updatebarpos(void); /* updates the bar position */
|
||||||
void quit(const char *arg); /* quit dwm nicely */
|
void quit(const char *arg); /* quit dwm nicely */
|
||||||
int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||||
|
|
15
layout.c
15
layout.c
|
@ -98,7 +98,6 @@ void
|
||||||
initlayouts(void) {
|
initlayouts(void) {
|
||||||
unsigned int i, w;
|
unsigned int i, w;
|
||||||
|
|
||||||
/* TODO deserialize ltidx if present */
|
|
||||||
nlayouts = sizeof layouts / sizeof layouts[0];
|
nlayouts = sizeof layouts / sizeof layouts[0];
|
||||||
for(blw = i = 0; i < nlayouts; i++) {
|
for(blw = i = 0; i < nlayouts; i++) {
|
||||||
w = textw(layouts[i].symbol);
|
w = textw(layouts[i].symbol);
|
||||||
|
@ -110,21 +109,13 @@ initlayouts(void) {
|
||||||
void
|
void
|
||||||
loaddwmprops(void) {
|
loaddwmprops(void) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
XTextProperty name;
|
|
||||||
|
|
||||||
/* check if window has set a property */
|
if(gettextprop(root, dwmprops, prop, sizeof prop)) {
|
||||||
name.nitems = 0;
|
|
||||||
XGetTextProperty(dpy, root, &name, dwmprops);
|
|
||||||
if(name.nitems && name.encoding == XA_STRING) {
|
|
||||||
strncpy(prop, (char *)name.value, sizeof prop - 1);
|
|
||||||
prop[sizeof prop - 1] = '\0';
|
|
||||||
XFree(name.value);
|
|
||||||
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
|
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
|
||||||
seltags[i] = prop[i] == '1';
|
seltags[i] = prop[i] == '1';
|
||||||
if(i < sizeof prop - 1 && prop[i] != '\0') {
|
if(i < sizeof prop - 1 && prop[i] != '\0') {
|
||||||
i = prop[i];
|
if(prop[i] < nlayouts)
|
||||||
if(i < nlayouts)
|
ltidx = prop[i];
|
||||||
ltidx = i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
28
main.c
28
main.c
|
@ -143,6 +143,7 @@ setup(void) {
|
||||||
dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False);
|
dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False);
|
||||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||||
|
wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
|
||||||
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
|
@ -220,6 +221,33 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
|
Bool
|
||||||
|
gettextprop(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(dpy, w, &name, atom);
|
||||||
|
if(!name.nitems)
|
||||||
|
return False;
|
||||||
|
if(name.encoding == XA_STRING)
|
||||||
|
strncpy(text, (char *)name.value, size - 1);
|
||||||
|
else {
|
||||||
|
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||||
|
&& n > 0 && *list)
|
||||||
|
{
|
||||||
|
strncpy(text, *list, size - 1);
|
||||||
|
XFreeStringList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text[size - 1] = '\0';
|
||||||
|
XFree(name.value);
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
quit(const char *arg) {
|
quit(const char *arg) {
|
||||||
readin = running = False;
|
readin = running = False;
|
||||||
|
|
Loading…
Reference in a new issue