1
0
This commit is contained in:
Anselm R. Garbe 2007-08-15 19:27:32 +02:00
parent 8fcc4ff0ae
commit 10d13f01ff
6 changed files with 35 additions and 30 deletions

View File

@ -36,7 +36,7 @@ dist: clean
@echo creating dist tarball @echo creating dist tarball
@mkdir -p dwm-${VERSION} @mkdir -p dwm-${VERSION}
@cp -R LICENSE Makefile README config.*.h config.mk \ @cp -R LICENSE Makefile README config.*.h config.mk \
dwm.1 dwm.h ${SRC} dwm-${VERSION} dwm.1 dwm.h tile.h ${SRC} dwm-${VERSION}
@tar -cf dwm-${VERSION}.tar dwm-${VERSION} @tar -cf dwm-${VERSION}.tar dwm-${VERSION}
@gzip dwm-${VERSION}.tar @gzip dwm-${VERSION}.tar
@rm -rf dwm-${VERSION} @rm -rf dwm-${VERSION}

View File

@ -296,16 +296,6 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
} }
} }
void
togglefloating(const char *arg) {
if(!sel || isfloating())
return;
sel->isfloating = !sel->isfloating;
if(sel->isfloating)
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
arrange();
}
void void
unban(Client *c) { unban(Client *c) {
if(!c->isbanned) if(!c->isbanned)
@ -316,7 +306,7 @@ unban(Client *c) {
} }
void void
unmanage(Client *c) { unmanage(Client *c, long state) {
XWindowChanges wc; XWindowChanges wc;
wc.border_width = c->oldborder; wc.border_width = c->oldborder;
@ -329,7 +319,7 @@ unmanage(Client *c) {
if(sel == c) if(sel == c)
focus(NULL); focus(NULL);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState); setclientstate(c, state);
free(c->tags); free(c->tags);
free(c); free(c);
XSync(dpy, False); XSync(dpy, False);

6
dwm.h
View File

@ -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 bh, blw, bpos; /* bar height, bar layout label width, bar position */
extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern Atom dwmtags, wmatom[WMLast], netatom[NetLast]; extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
extern Bool selscreen, *seltag; /* seltag is array of Bool */ extern Bool selscreen, *seltag; /* seltag is array of Bool */
extern Client *clients, *sel, *stack; /* global client list and stack */ extern Client *clients, *sel, *stack; /* global client list and stack */
extern Cursor cursor[CurLast]; extern Cursor cursor[CurLast];
@ -99,9 +99,8 @@ void killclient(const char *arg); /* kill sel nicely */
void manage(Window w, XWindowAttributes *wa); /* manage new client */ void manage(Window w, XWindowAttributes *wa); /* manage new client */
void resize(Client *c, int x, int y, void resize(Client *c, int x, int y,
int w, int h, Bool sizehints); /* resize with given coordinates c*/ int w, int h, Bool sizehints); /* resize with given coordinates c*/
void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
void unban(Client *c); /* unbans c */ void unban(Client *c); /* unbans c */
void unmanage(Client *c); /* destroy c */ void unmanage(Client *c, long state); /* unmanage c */
void updatesizehints(Client *c); /* update the size hint variables of c */ void updatesizehints(Client *c); /* update the size hint variables of c */
void updatetitle(Client *c); /* update the name of c */ void updatetitle(Client *c); /* update the name of c */
@ -136,6 +135,7 @@ void compileregs(void); /* initialize regexps of rules defined in config.h */
Bool isvisible(Client *c); /* returns True if client is visible */ Bool isvisible(Client *c); /* returns True if client is visible */
void settags(Client *c, Client *trans); /* sets tags of c */ void settags(Client *c, Client *trans); /* sets tags of c */
void tag(const char *arg); /* tags sel with arg's index */ void tag(const char *arg); /* tags sel with arg's index */
void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
void toggletag(const char *arg); /* toggles sel tags with arg's index */ void toggletag(const char *arg); /* toggles sel tags with arg's index */
void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
void view(const char *arg); /* views the tag with arg's index */ void view(const char *arg); /* views the tag with arg's index */

View File

@ -4,6 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h>
/* static */ /* static */
@ -226,7 +227,7 @@ destroynotify(XEvent *e) {
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = getclient(ev->window))) if((c = getclient(ev->window)))
unmanage(c); unmanage(c, WithdrawnState);
} }
static void static void
@ -338,7 +339,7 @@ unmapnotify(XEvent *e) {
if((c = getclient(ev->window)) && (ev->event == root)) { if((c = getclient(ev->window)) && (ev->event == root)) {
if(ev->send_event || c->unmapped-- == 0) if(ev->send_event || c->unmapped-- == 0)
unmanage(c); unmanage(c, WithdrawnState);
} }
} }

7
main.c
View File

@ -11,6 +11,7 @@
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xutil.h>
/* extern */ /* extern */
@ -19,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
unsigned int bh, ntags; unsigned int bh, ntags;
unsigned int bpos = BARPOS; unsigned int bpos = BARPOS;
unsigned int numlockmask = 0; unsigned int numlockmask = 0;
Atom dwmtags, wmatom[WMLast], netatom[NetLast]; Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
Bool *seltag; Bool *seltag;
Bool selscreen = True; Bool selscreen = True;
Client *clients = NULL; Client *clients = NULL;
@ -41,7 +42,7 @@ cleanup(void) {
close(STDIN_FILENO); close(STDIN_FILENO);
while(stack) { while(stack) {
unban(stack); unban(stack);
unmanage(stack); unmanage(stack, NormalState);
} }
if(dc.font.set) if(dc.font.set)
XFreeFontSet(dpy, dc.font.set); XFreeFontSet(dpy, dc.font.set);
@ -139,7 +140,7 @@ setup(void) {
XSetWindowAttributes wa; XSetWindowAttributes wa;
/* init atoms */ /* init atoms */
dwmtags = XInternAtom(dpy, "__DWM_TAGS", False); dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", 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[WMState] = XInternAtom(dpy, "WM_STATE", False); wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);

31
tag.c
View File

@ -28,14 +28,15 @@ static unsigned int nrules = 0;
static char prop[512]; static char prop[512];
static void static void
persisttags(Client *c) persistconfig(Client *c) {
{
unsigned int i; unsigned int i;
for(i = 0; i < ntags && i < sizeof prop - 1; i++) for(i = 0; i < ntags && i < sizeof prop - 1; i++)
prop[i] = c->tags[i] ? '+' : '-'; prop[i] = c->tags[i] ? '1' : '0';
if(i < sizeof prop - 1)
prop[i++] = c->isfloating ? '1' : '0';
prop[i] = '\0'; prop[i] = '\0';
XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8, XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
PropModeReplace, (unsigned char *)prop, i); PropModeReplace, (unsigned char *)prop, i);
} }
@ -93,14 +94,16 @@ settags(Client *c, Client *trans) {
else { else {
/* check if window has set a property */ /* check if window has set a property */
name.nitems = 0; name.nitems = 0;
XGetTextProperty(dpy, c->win, &name, dwmtags); XGetTextProperty(dpy, c->win, &name, dwmconfig);
if(name.nitems && name.encoding == XA_STRING) { if(name.nitems && name.encoding == XA_STRING) {
strncpy(prop, (char *)name.value, sizeof prop - 1); strncpy(prop, (char *)name.value, sizeof prop - 1);
prop[sizeof prop - 1] = '\0'; prop[sizeof prop - 1] = '\0';
XFree(name.value); 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] == '+')) if((c->tags[i] = prop[i] == '1'))
matched = True; matched = True;
if(i < sizeof prop - 1 && prop[i] != '\0')
c->isfloating = prop[i] == '1';
} }
} }
if(!matched) { if(!matched) {
@ -127,7 +130,7 @@ settags(Client *c, Client *trans) {
if(!matched) if(!matched)
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
c->tags[i] = seltag[i]; c->tags[i] = seltag[i];
persisttags(c); persistconfig(c);
} }
void void
@ -142,7 +145,17 @@ tag(const char *arg) {
if(i >= 0 && i < ntags) if(i >= 0 && i < ntags)
sel->tags[i] = True; sel->tags[i] = True;
if(sel) if(sel)
persisttags(sel); persistconfig(sel);
arrange();
}
void
togglefloating(const char *arg) {
if(!sel || isfloating())
return;
sel->isfloating = !sel->isfloating;
if(sel->isfloating)
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
arrange(); arrange();
} }
@ -158,7 +171,7 @@ toggletag(const char *arg) {
if(j == ntags) if(j == ntags)
sel->tags[i] = True; sel->tags[i] = True;
if(sel) if(sel)
persisttags(sel); persistconfig(sel);
arrange(); arrange();
} }