hmm I doubt the usefulness of storing this information...
This commit is contained in:
parent
50be6c8b67
commit
0c60620410
38
client.c
38
client.c
|
@ -7,7 +7,7 @@
|
|||
|
||||
/* static */
|
||||
|
||||
static char config[128];
|
||||
static char prop[128];
|
||||
|
||||
static void
|
||||
attachstack(Client *c) {
|
||||
|
@ -182,23 +182,23 @@ killclient(const char *arg) {
|
|||
}
|
||||
|
||||
Bool
|
||||
loadconfig(Client *c) {
|
||||
loadprops(Client *c) {
|
||||
unsigned int i;
|
||||
Bool result = False;
|
||||
XTextProperty name;
|
||||
|
||||
/* check if window has set a property */
|
||||
name.nitems = 0;
|
||||
XGetTextProperty(dpy, c->win, &name, dwmconfig);
|
||||
XGetTextProperty(dpy, c->win, &name, dwmprops);
|
||||
if(name.nitems && name.encoding == XA_STRING) {
|
||||
strncpy(config, (char *)name.value, sizeof config - 1);
|
||||
config[sizeof config - 1] = '\0';
|
||||
strncpy(prop, (char *)name.value, sizeof prop - 1);
|
||||
prop[sizeof prop - 1] = '\0';
|
||||
XFree(name.value);
|
||||
for(i = 0; i < ntags && i < sizeof config - 1 && config[i] != '\0'; i++)
|
||||
if((c->tags[i] = config[i] == '1'))
|
||||
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
|
||||
if((c->tags[i] = prop[i] == '1'))
|
||||
result = True;
|
||||
if(i < sizeof config - 1 && config[i] != '\0')
|
||||
c->isfloating = config[i] == '1';
|
||||
if(i < sizeof prop - 1 && prop[i] != '\0')
|
||||
c->isfloating = prop[i] == '1';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -249,11 +249,11 @@ manage(Window w, XWindowAttributes *wa) {
|
|||
if(t)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = t->tags[i];
|
||||
if(!loadconfig(c))
|
||||
if(!loadprops(c))
|
||||
applyrules(c);
|
||||
if(!c->isfloating)
|
||||
c->isfloating = (rettrans == Success) || c->isfixed;
|
||||
saveconfig(c);
|
||||
saveprops(c);
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
|
||||
|
@ -325,16 +325,16 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
|||
}
|
||||
|
||||
void
|
||||
saveconfig(Client *c) {
|
||||
saveprops(Client *c) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags && i < sizeof config - 1; i++)
|
||||
config[i] = c->tags[i] ? '1' : '0';
|
||||
if(i < sizeof config - 1)
|
||||
config[i++] = c->isfloating ? '1' : '0';
|
||||
config[i] = '\0';
|
||||
XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *)config, i);
|
||||
for(i = 0; i < ntags && i < sizeof prop - 1; i++)
|
||||
prop[i] = c->tags[i] ? '1' : '0';
|
||||
if(i < sizeof prop - 1)
|
||||
prop[i++] = c->isfloating ? '1' : '0';
|
||||
prop[i] = '\0';
|
||||
XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *)prop, i);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,8 +20,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
|
|||
# flags
|
||||
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = -s ${LIBS}
|
||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = -g ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
|
|
8
dwm.h
8
dwm.h
|
@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* windowarea geometry */
|
|||
extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */
|
||||
extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
|
||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
|
||||
extern Atom dwmprops, wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool selscreen, *seltags; /* seltags is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
|
@ -96,11 +96,11 @@ void configure(Client *c); /* send synthetic configure event */
|
|||
void detach(Client *c); /* detaches c from global client list */
|
||||
void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
|
||||
void killclient(const char *arg); /* kill sel nicely */
|
||||
Bool loadconfig(Client *c); /* loads client properties */
|
||||
Bool loadprops(Client *c); /* loads client properties */
|
||||
void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
void resize(Client *c, int x, int y,
|
||||
int w, int h, Bool sizehints); /* resize with given coordinates c*/
|
||||
void saveconfig(Client *c); /* saves client properties */
|
||||
void saveprops(Client *c); /* saves client properties */
|
||||
void unban(Client *c); /* unbans c */
|
||||
void unmanage(Client *c, long state); /* unmanage c */
|
||||
void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
|
@ -122,8 +122,10 @@ const char *getsymbol(void); /* returns symbol of enabled layout */
|
|||
Bool isfloating(void); /* returns True if floating layout is enabled */
|
||||
Bool isarrange(void (*func)()); /* returns True if func is the layout function in use */
|
||||
void initlayouts(void); /* initialize layout array */
|
||||
void loaddwmprops(void); /* loads dwm properties */
|
||||
Client *nexttiled(Client *c); /* returns tiled successor of c */
|
||||
void restack(void); /* restores z layers of all clients */
|
||||
void savedwmprops(void); /* saves dwm properties */
|
||||
void setlayout(const char *arg); /* sets layout, NULL means next layout */
|
||||
void togglebar(const char *arg); /* shows/hides the bar */
|
||||
void togglemax(const char *arg); /* toggles maximization of floating client */
|
||||
|
|
40
layout.c
40
layout.c
|
@ -1,6 +1,9 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static */
|
||||
|
||||
|
@ -10,6 +13,7 @@ typedef struct {
|
|||
} Layout;
|
||||
|
||||
unsigned int blw = 0;
|
||||
static char prop[128];
|
||||
static unsigned int ltidx = 0; /* default */
|
||||
|
||||
static void
|
||||
|
@ -103,6 +107,28 @@ initlayouts(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
loaddwmprops(void) {
|
||||
unsigned int i;
|
||||
XTextProperty name;
|
||||
|
||||
/* check if window has set a property */
|
||||
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++)
|
||||
seltags[i] = prop[i] == '1';
|
||||
if(i < sizeof prop - 1 && prop[i] != '\0') {
|
||||
i = prop[i] - '0';
|
||||
if(i < nlayouts)
|
||||
ltidx = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
nexttiled(Client *c) {
|
||||
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
|
||||
|
@ -138,6 +164,19 @@ restack(void) {
|
|||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
savedwmprops(void) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags && i < sizeof prop - 1; i++)
|
||||
prop[i] = seltags[i] ? '1' : '0';
|
||||
if(i < sizeof prop - 1)
|
||||
prop[i++] = (char)ltidx;
|
||||
prop[i] = '\0';
|
||||
XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *)prop, i);
|
||||
}
|
||||
|
||||
void
|
||||
setlayout(const char *arg) {
|
||||
int i;
|
||||
|
@ -156,6 +195,7 @@ setlayout(const char *arg) {
|
|||
arrange();
|
||||
else
|
||||
drawstatus();
|
||||
savedwmprops();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
5
main.c
5
main.c
|
@ -20,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
|||
unsigned int bh, ntags;
|
||||
unsigned int bpos = BARPOS;
|
||||
unsigned int numlockmask = 0;
|
||||
Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
|
||||
Atom dwmprops, wmatom[WMLast], netatom[NetLast];
|
||||
Bool *seltags;
|
||||
Bool selscreen = True;
|
||||
Client *clients = NULL;
|
||||
|
@ -140,7 +140,7 @@ setup(void) {
|
|||
XSetWindowAttributes wa;
|
||||
|
||||
/* init atoms */
|
||||
dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False);
|
||||
dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False);
|
||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||
|
@ -205,6 +205,7 @@ setup(void) {
|
|||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||
/* multihead support */
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
loaddwmprops();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
10
tag.c
10
tag.c
|
@ -3,8 +3,6 @@
|
|||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static */
|
||||
|
@ -118,7 +116,7 @@ tag(const char *arg) {
|
|||
i = idxoftag(arg);
|
||||
if(i >= 0 && i < ntags)
|
||||
sel->tags[i] = True;
|
||||
saveconfig(sel);
|
||||
saveprops(sel);
|
||||
arrange();
|
||||
}
|
||||
|
||||
|
@ -129,7 +127,7 @@ togglefloating(const char *arg) {
|
|||
sel->isfloating = !sel->isfloating;
|
||||
if(sel->isfloating) {
|
||||
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
|
||||
saveconfig(sel);
|
||||
saveprops(sel);
|
||||
}
|
||||
arrange();
|
||||
}
|
||||
|
@ -145,7 +143,7 @@ toggletag(const char *arg) {
|
|||
for(j = 0; j < ntags && !sel->tags[j]; j++);
|
||||
if(j == ntags)
|
||||
sel->tags[i] = True;
|
||||
saveconfig(sel);
|
||||
saveprops(sel);
|
||||
arrange();
|
||||
}
|
||||
|
||||
|
@ -158,6 +156,7 @@ toggleview(const char *arg) {
|
|||
for(j = 0; j < ntags && !seltags[j]; j++);
|
||||
if(j == ntags)
|
||||
seltags[i] = True; /* cannot toggle last view */
|
||||
savedwmprops();
|
||||
arrange();
|
||||
}
|
||||
|
||||
|
@ -170,5 +169,6 @@ view(const char *arg) {
|
|||
i = idxoftag(arg);
|
||||
if(i >= 0 && i < ntags)
|
||||
seltags[i] = True;
|
||||
savedwmprops();
|
||||
arrange();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue