Browse Source

removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check

config
Anselm R. Garbe 17 years ago
parent
commit
36672d0401
6 changed files with 23 additions and 101 deletions
  1. +7
    -43
      client.c
  2. +2
    -2
      config.mk
  3. +2
    -6
      dwm.h
  4. +3
    -5
      event.c
  5. +2
    -4
      main.c
  6. +7
    -41
      screen.c

+ 7
- 43
client.c View File

@ -1,14 +1,11 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include "dwm.h" #include "dwm.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
/* static */ /* static */
static char buf[128];
static void static void
attachstack(Client *c) { attachstack(Client *c) {
c->snext = stack; c->snext = stack;
@ -102,10 +99,8 @@ void
ban(Client *c) { ban(Client *c) {
if(c->isbanned) if(c->isbanned)
return; return;
XUnmapWindow(dpy, c->win);
setclientstate(c, IconicState);
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
c->isbanned = True; c->isbanned = True;
c->unmapped++;
} }
void void
@ -181,21 +176,6 @@ killclient(const char *arg) {
XKillClient(dpy, sel->win); XKillClient(dpy, sel->win);
} }
Bool
getprops(Client *c) {
unsigned int i;
Bool result = False;
if(gettextprop(c->win, dwmprops, buf, sizeof buf)) {
for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++)
if((c->tags[i] = buf[i] == '1'))
result = True;
if(i < sizeof buf - 1 && buf[i] != '\0')
c->isfloating = buf[i] == '1';
}
return result;
}
void void
manage(Window w, XWindowAttributes *wa) { manage(Window w, XWindowAttributes *wa) {
unsigned int i; unsigned int i;
@ -242,15 +222,14 @@ manage(Window w, XWindowAttributes *wa) {
if(t) if(t)
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
c->tags[i] = t->tags[i]; c->tags[i] = t->tags[i];
if(!getprops(c))
applyrules(c);
applyrules(c);
if(!c->isfloating) if(!c->isfloating)
c->isfloating = (rettrans == Success) || c->isfixed; c->isfloating = (rettrans == Success) || c->isfixed;
setprops(c);
attach(c); attach(c);
attachstack(c); attachstack(c);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
ban(c); ban(c);
XMapWindow(dpy, c->win);
arrange(); arrange();
} }
@ -317,30 +296,16 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
} }
} }
void
setprops(Client *c) {
unsigned int i;
for(i = 0; i < ntags && i < sizeof buf - 1; i++)
buf[i] = c->tags[i] ? '1' : '0';
if(i < sizeof buf - 1)
buf[i++] = c->isfloating ? '1' : '0';
buf[i] = '\0';
XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8,
PropModeReplace, (unsigned char *)buf, i);
}
void void
unban(Client *c) { unban(Client *c) {
if(!c->isbanned) if(!c->isbanned)
return; return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False; c->isbanned = False;
} }
void void
unmanage(Client *c, long state) {
unmanage(Client *c) {
XWindowChanges wc; XWindowChanges wc;
wc.border_width = c->oldborder; wc.border_width = c->oldborder;
@ -353,14 +318,13 @@ unmanage(Client *c, long state) {
if(sel == c) if(sel == c)
focus(NULL); focus(NULL);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, state);
setclientstate(c, WithdrawnState);
free(c->tags); free(c->tags);
free(c); free(c);
XSync(dpy, False); XSync(dpy, False);
XSetErrorHandler(xerror); XSetErrorHandler(xerror);
XUngrabServer(dpy); XUngrabServer(dpy);
if(state != NormalState)
arrange();
arrange();
} }
void void


+ 2
- 2
config.mk View File

@ -20,8 +20,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
# flags # flags
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = -s ${LIBS} LDFLAGS = -s ${LIBS}
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS}
CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = -g ${LIBS}
# Solaris # Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"


+ 2
- 6
dwm.h View File

@ -48,7 +48,6 @@ struct Client {
int rx, ry, rw, rh; /* revert geometry */ int rx, ry, rw, rh; /* revert geometry */
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay; int minax, maxax, minay, maxay;
int unmapped;
long flags; long flags;
unsigned int border, oldborder; unsigned int border, oldborder;
Bool isbanned, isfixed, ismax, isfloating; Bool isbanned, isfixed, ismax, isfloating;
@ -81,7 +80,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 dwmprops, wmatom[WMLast], netatom[NetLast];
extern Atom wmatom[WMLast], netatom[NetLast];
extern Bool selscreen, *seltags; /* seltags is array of Bool */ extern Bool selscreen, *seltags; /* seltags 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];
@ -96,13 +95,11 @@ void configure(Client *c); /* send synthetic configure event */
void detach(Client *c); /* detaches c from global client list */ void detach(Client *c); /* detaches c from global client list */
void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
void killclient(const char *arg); /* kill sel nicely */ void killclient(const char *arg); /* kill sel nicely */
Bool getprops(Client *c); /* gets client properties */
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 setprops(Client *c); /* sets client properties */
void unban(Client *c); /* unbans c */ void unban(Client *c); /* unbans c */
void unmanage(Client *c, long state); /* unmanage c */
void unmanage(Client *c); /* 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 */
@ -131,7 +128,6 @@ void initlayouts(void); /* initialize layout array */
Bool isarrange(void (*func)()); /* returns True if func is the layout function in use */ Bool isarrange(void (*func)()); /* returns True if func is the layout function in use */
Bool isfloating(void); /* returns True if floating layout is enabled */ Bool isfloating(void); /* returns True if floating layout is enabled */
Bool isvisible(Client *c); /* returns True if client is visible */ Bool isvisible(Client *c); /* returns True if client is visible */
void getdwmprops(void); /* gets dwm properties */
Client *nexttiled(Client *c); /* returns tiled successor of c */ Client *nexttiled(Client *c); /* returns tiled successor of c */
void restack(void); /* restores z layers of all clients */ void restack(void); /* restores z layers of all clients */
void setlayout(const char *arg); /* sets layout, NULL means next layout */ void setlayout(const char *arg); /* sets layout, NULL means next layout */


+ 3
- 5
event.c View File

@ -221,7 +221,7 @@ destroynotify(XEvent *e) {
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = getclient(ev->window))) if((c = getclient(ev->window)))
unmanage(c, WithdrawnState);
unmanage(c);
} }
static void static void
@ -332,10 +332,8 @@ unmapnotify(XEvent *e) {
Client *c; Client *c;
XUnmapEvent *ev = &e->xunmap; XUnmapEvent *ev = &e->xunmap;
if((c = getclient(ev->window)) && (ev->event == root)) {
if(ev->send_event || c->unmapped-- == 0)
unmanage(c, WithdrawnState);
}
if((c = getclient(ev->window)))
unmanage(c);
} }
/* extern */ /* extern */


+ 2
- 4
main.c View File

@ -20,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 dwmprops, wmatom[WMLast], netatom[NetLast];
Atom wmatom[WMLast], netatom[NetLast];
Bool *seltags; Bool *seltags;
Bool selscreen = True; Bool selscreen = True;
Client *clients = NULL; Client *clients = NULL;
@ -42,7 +42,7 @@ cleanup(void) {
close(STDIN_FILENO); close(STDIN_FILENO);
while(stack) { while(stack) {
unban(stack); unban(stack);
unmanage(stack, NormalState);
unmanage(stack);
} }
if(dc.font.set) if(dc.font.set)
XFreeFontSet(dpy, dc.font.set); XFreeFontSet(dpy, dc.font.set);
@ -165,7 +165,6 @@ setup(void) {
XSetWindowAttributes wa; XSetWindowAttributes wa;
/* init atoms */ /* init atoms */
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[WMName] = XInternAtom(dpy, "WM_NAME", False);
@ -231,7 +230,6 @@ setup(void) {
XSetFont(dpy, dc.gc, dc.font.xfont->fid); XSetFont(dpy, dc.gc, dc.font.xfont->fid);
/* multihead support */ /* multihead support */
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
getdwmprops();
} }
/* /*


+ 7
- 41
screen.c View File

@ -3,8 +3,6 @@
#include <regex.h> #include <regex.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
/* static */ /* static */
@ -28,7 +26,6 @@ typedef struct {
TAGS TAGS
RULES RULES
static char buf[512];
static unsigned int nrules = 0; static unsigned int nrules = 0;
static unsigned int nlayouts = 0; static unsigned int nlayouts = 0;
static unsigned int ltidx = 0; /* default */ static unsigned int ltidx = 0; /* default */
@ -53,19 +50,6 @@ floating(void) { /* default floating layout */
resize(c, c->x, c->y, c->w, c->h, True); resize(c, c->x, c->y, c->w, c->h, True);
} }
static void
setdwmprops(void) {
unsigned int i;
for(i = 0; i < ntags && i < sizeof buf - 1; i++)
buf[i] = seltags[i] ? '1' : '0';
if(i < sizeof buf - 1)
buf[i++] = (char)ltidx + '0';
buf[i] = '\0';
XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
PropModeReplace, (unsigned char *)buf, i);
}
LAYOUTS LAYOUTS
/* extern */ /* extern */
@ -74,6 +58,7 @@ unsigned int blw = 0;
void void
applyrules(Client *c) { applyrules(Client *c) {
static char buf[512];
unsigned int i, j; unsigned int i, j;
regmatch_t tmp; regmatch_t tmp;
Bool matched = False; Bool matched = False;
@ -215,20 +200,6 @@ isvisible(Client *c) {
return False; return False;
} }
void
getdwmprops(void) {
unsigned int i;
if(gettextprop(root, dwmprops, buf, sizeof buf)) {
for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++)
seltags[i] = buf[i] == '1';
if(i < sizeof buf - 1 && buf[i] != '\0') {
if((unsigned int)(buf[i] - '0') < nlayouts)
ltidx = buf[i] - '0';
}
}
}
Client * Client *
nexttiled(Client *c) { nexttiled(Client *c) {
for(; c && (c->isfloating || !isvisible(c)); c = c->next); for(; c && (c->isfloating || !isvisible(c)); c = c->next);
@ -266,15 +237,17 @@ restack(void) {
void void
setlayout(const char *arg) { setlayout(const char *arg) {
int i;
unsigned int i;
if(!arg) { if(!arg) {
if(++ltidx == nlayouts) if(++ltidx == nlayouts)
ltidx = 0;; ltidx = 0;;
} }
else { else {
i = atoi(arg);
if(i < 0 || i >= nlayouts)
for(i = 0; i < nlayouts; i++)
if(arg == layouts[i].symbol)
break;
if(i == nlayouts)
return; return;
ltidx = i; ltidx = i;
} }
@ -282,7 +255,6 @@ setlayout(const char *arg) {
arrange(); arrange();
else else
drawstatus(); drawstatus();
setdwmprops();
} }
void void
@ -296,7 +268,6 @@ tag(const char *arg) {
i = idxoftag(arg); i = idxoftag(arg);
if(i >= 0 && i < ntags) if(i >= 0 && i < ntags)
sel->tags[i] = True; sel->tags[i] = True;
setprops(sel);
arrange(); arrange();
} }
@ -315,10 +286,8 @@ togglefloating(const char *arg) {
if(!sel || isfloating()) if(!sel || isfloating())
return; return;
sel->isfloating = !sel->isfloating; sel->isfloating = !sel->isfloating;
if(sel->isfloating) {
if(sel->isfloating)
resize(sel, sel->x, sel->y, sel->w, sel->h, True); resize(sel, sel->x, sel->y, sel->w, sel->h, True);
setprops(sel);
}
arrange(); arrange();
} }
@ -352,7 +321,6 @@ toggletag(const char *arg) {
for(j = 0; j < ntags && !sel->tags[j]; j++); for(j = 0; j < ntags && !sel->tags[j]; j++);
if(j == ntags) if(j == ntags)
sel->tags[i] = True; sel->tags[i] = True;
setprops(sel);
arrange(); arrange();
} }
@ -365,7 +333,6 @@ toggleview(const char *arg) {
for(j = 0; j < ntags && !seltags[j]; j++); for(j = 0; j < ntags && !seltags[j]; j++);
if(j == ntags) if(j == ntags)
seltags[i] = True; /* cannot toggle last view */ seltags[i] = True; /* cannot toggle last view */
setdwmprops();
arrange(); arrange();
} }
@ -404,6 +371,5 @@ view(const char *arg) {
i = idxoftag(arg); i = idxoftag(arg);
if(i >= 0 && i < ntags) if(i >= 0 && i < ntags)
seltags[i] = True; seltags[i] = True;
setdwmprops();
arrange(); arrange();
} }

Loading…
Cancel
Save