Introduction
Introduction Statistics Contact Development Disclaimer Help
thmm I doubt the usefulness of storing this information... - dwm - [fork] custo…
git clone git://src.adamsgaard.dk/dwm
Log
Files
Refs
README
LICENSE
---
commit 0c6062041035105c6266f6bedb286c1990516fa7
parent 50be6c8b67c500ee4aa07919609fa80785fd389d
Author: Anselm R. Garbe <[email protected]>
Date: Sat, 18 Aug 2007 14:20:56 +0200
hmm I doubt the usefulness of storing this information...
Diffstat:
M client.c | 38 ++++++++++++++++-------------…
M config.mk | 4 ++--
M dwm.h | 8 +++++---
M layout.c | 40 +++++++++++++++++++++++++++++…
M main.c | 5 +++--
M tag.c | 10 +++++-----
6 files changed, 74 insertions(+), 31 deletions(-)
---
diff --git a/client.c b/client.c
t@@ -7,7 +7,7 @@
/* static */
-static char config[128];
+static char prop[128];
static void
attachstack(Client *c) {
t@@ -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] != …
- if((c->tags[i] = config[i] == '1'))
+ for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'…
+ 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;
}
t@@ -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 window…
t@@ -325,16 +325,16 @@ resize(Client *c, int x, int y, int w, int h, Bool sizeh…
}
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
diff --git a/config.mk b/config.mk
t@@ -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}\"
diff --git a/dwm.h b/dwm.h
t@@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* win…
extern unsigned int bh, blw, bpos; /* bar height, bar layout la…
extern unsigned int ntags, numlockmask; /* number of tags, numl…
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…
extern Cursor cursor[CurLast];
t@@ -96,11 +96,11 @@ void configure(Client *c); /* send syntheti…
void detach(Client *c); /* detaches c from global clien…
void focus(Client *c); /* focus c if visible && !NULL, …
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 coo…
-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…
t@@ -122,8 +122,10 @@ const char *getsymbol(void); /* returns sy…
Bool isfloating(void); /* returns True if floating layo…
Bool isarrange(void (*func)()); /* returns True if func is the …
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 cl…
diff --git a/layout.c b/layout.c
t@@ -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 */
t@@ -10,6 +13,7 @@ typedef struct {
} Layout;
unsigned int blw = 0;
+static char prop[128];
static unsigned int ltidx = 0; /* default */
static void
t@@ -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'…
+ 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);
t@@ -139,6 +165,19 @@ restack(void) {
}
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;
t@@ -156,6 +195,7 @@ setlayout(const char *arg) {
arrange();
else
drawstatus();
+ savedwmprops();
}
void
diff --git a/main.c b/main.c
t@@ -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;
t@@ -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);
t@@ -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();
}
/*
diff --git a/tag.c b/tag.c
t@@ -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 */
t@@ -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();
}
t@@ -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();
}
t@@ -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();
}
t@@ -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();
}
t@@ -170,5 +169,6 @@ view(const char *arg) {
i = idxoftag(arg);
if(i >= 0 && i < ntags)
seltags[i] = True;
+ savedwmprops();
arrange();
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.