Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
c31648d15d | |||
52250e7c1e | |||
51a94a2f14 | |||
c95bf3db9d | |||
4bf3b01953 | |||
ff957d1eac | |||
83aa110c6f | |||
5a1a2edf0e | |||
b3419f49a3 | |||
141beb2704 | |||
4e49d5a0ad | |||
2c6be7239f | |||
d934296476 | |||
39ae286861 | |||
59e65d1709 | |||
9fdd2cd1a9 | |||
e1deda9e04 | |||
199a601611 | |||
492c6f10fc | |||
caa7ab5362 | |||
f3e672efd8 | |||
02d5dddc00 | |||
c789941bba | |||
e45b3ced67 | |||
5a9af492ae | |||
32563abe86 | |||
70c7b432ea | |||
69dfcaa317 | |||
6ee8e3e93b | |||
8439369db9 | |||
81658eaab3 | |||
81aebf8cae | |||
fa32f02a43 | |||
598e22907e | |||
1e826ddd3e | |||
a967d7f664 | |||
ce450c5bf1 | |||
8f5f7a5b5a | |||
5ad2828c57 | |||
b896b58d6d | |||
fef6c5c66b | |||
37e062b0ed | |||
cf58091736 | |||
2aef8b9b4c | |||
d96307cbe4 | |||
124866e269 | |||
ab3d6a7dfe | |||
c67dbb28e4 | |||
b8bccb4ac5 | |||
b6b2f584ec | |||
f7bdb39d9e | |||
ecd9c3e222 | |||
216099d072 | |||
fc2e3eae20 | |||
f9e7a33019 | |||
7c9fa2566f |
3
.hgtags
3
.hgtags
@ -42,3 +42,6 @@ d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
baee494346e520f8dee2cee9491b8350064770d2 3.7
|
||||
2ea201354cf016407ea93e1e390d1422940d29b0 3.8
|
||||
55478328b2422c700c5404a774c85e77322f41a3 3.9
|
||||
018c3846842291cb6c009dc087e7fe2f0ef53bea 4.0
|
||||
00f4180df72b49aadb2933804fde4bfb33e5666d 4.1
|
||||
c13cb8c6b7a56af74cc88346e71d2490470b546f 4.2
|
||||
|
3
LICENSE
3
LICENSE
@ -2,6 +2,9 @@ MIT/X Consortium License
|
||||
|
||||
© 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
© 2006-2007 Jukka Salmi <jukka at salmi dot ch>
|
||||
© 2007 Premysl Hruby <dfenze at gmail dot com>
|
||||
© 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
1
Makefile
1
Makefile
@ -27,7 +27,6 @@ config.h:
|
||||
dwm: ${OBJ}
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
@strip $@
|
||||
|
||||
clean:
|
||||
@echo cleaning
|
||||
|
86
client.c
86
client.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -98,6 +96,14 @@ attach(Client *c) {
|
||||
clients = c;
|
||||
}
|
||||
|
||||
void
|
||||
ban(Client *c) {
|
||||
if (c->isbanned)
|
||||
return;
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
c->isbanned = True;
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
XConfigureEvent ce;
|
||||
@ -129,8 +135,8 @@ detach(Client *c) {
|
||||
|
||||
void
|
||||
focus(Client *c) {
|
||||
if(c && !isvisible(c))
|
||||
return;
|
||||
if((!c && selscreen)|| (c && !isvisible(c)))
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
if(sel && sel != c) {
|
||||
grabbuttons(sel, False);
|
||||
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
|
||||
@ -218,12 +224,10 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->isfloating = (rettrans == Success) || c->isfixed;
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
c->isbanned = True;
|
||||
XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
|
||||
ban(c);
|
||||
XMapWindow(dpy, w);
|
||||
setclientstate(c, NormalState);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
focus(c);
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
@ -297,6 +301,39 @@ togglefloating(const char *arg) {
|
||||
if(!sel || lt->arrange == floating)
|
||||
return;
|
||||
sel->isfloating = !sel->isfloating;
|
||||
if(sel->isfloating)
|
||||
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
unban(Client *c) {
|
||||
if (!c->isbanned)
|
||||
return;
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c) {
|
||||
XWindowChanges wc;
|
||||
|
||||
wc.border_width = c->oldborder;
|
||||
/* The server grab construct avoids race conditions. */
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
if(sel == c)
|
||||
focus(NULL);
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
setclientstate(c, WithdrawnState);
|
||||
free(c->tags);
|
||||
free(c);
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
@ -366,40 +403,15 @@ updatetitle(Client *c) {
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||
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);
|
||||
strncpy(c->name, *list, sizeof c->name - 1);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
}
|
||||
c->name[sizeof c->name - 1] = '\0';
|
||||
XFree(name.value);
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c) {
|
||||
Client *nc;
|
||||
XWindowChanges wc;
|
||||
|
||||
wc.border_width = c->oldborder;
|
||||
/* The server grab construct avoids race conditions. */
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
if(sel == c) {
|
||||
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
||||
focus(nc);
|
||||
}
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
setclientstate(c, WithdrawnState);
|
||||
free(c->tags);
|
||||
free(c);
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
lt->arrange();
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
#define BARPOS BarTop /* BarBot, BarOff */
|
||||
#define BORDERPX 1
|
||||
#define FONT "-*-pixelcarnage monospace-*-r-*-*-14-*-*-*-*-*-*-*"
|
||||
#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-iso10646-*"
|
||||
#define NORMBORDERCOLOR "#333"
|
||||
#define NORMBGCOLOR "#222"
|
||||
#define NORMFGCOLOR "#ccc"
|
||||
#define SELBORDERCOLOR "#8c8"
|
||||
#define SELBGCOLOR "#555"
|
||||
#define SELFGCOLOR "#fff"
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
@ -47,6 +45,7 @@ static Key key[] = { \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||
"exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_b, togglebar, NULL }, \
|
||||
{ MODKEY, XK_h, incmasterw, "-32" }, \
|
||||
{ MODKEY, XK_l, incmasterw, "32" }, \
|
||||
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
#define BARPOS BarTop /* BarBot, BarOff */
|
||||
#define BORDERPX 1
|
||||
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#dddddd"
|
||||
@ -11,7 +10,6 @@
|
||||
#define SELBORDERCOLOR "#ff0000"
|
||||
#define SELBGCOLOR "#006699"
|
||||
#define SELFGCOLOR "#ffffff"
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
@ -45,6 +43,7 @@ static Key key[] = { \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, "exec xterm" }, \
|
||||
{ MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_b, togglebar, NULL }, \
|
||||
{ MODKEY, XK_h, incmasterw, "-32" }, \
|
||||
{ MODKEY, XK_l, incmasterw, "32" }, \
|
||||
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 4.0
|
||||
VERSION = 4.3
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -16,7 +16,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
|
||||
|
||||
# flags
|
||||
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = ${LIBS}
|
||||
LDFLAGS = -s ${LIBS}
|
||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
|
||||
|
4
draw.c
4
draw.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <string.h>
|
||||
|
||||
|
11
dwm.1
11
dwm.1
@ -59,6 +59,9 @@ Start
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-b
|
||||
Shows/hides the status bar.
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
@ -146,3 +149,11 @@ you can use JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or you
|
||||
can set the following environment variable (to use the older Motif
|
||||
backend instead):
|
||||
.BR AWT_TOOLKIT=MToolkit .
|
||||
.P
|
||||
Recent GTK 2.10.9+ versions contain a broken
|
||||
.BR Save\-As
|
||||
file dialog implementation,
|
||||
which requests to reconfigure its window size in an endless loop. However, its
|
||||
window is still respondable during this state, so you can simply ignore the flicker
|
||||
until a new GTK version appears, which will fix this bug, approximately
|
||||
GTK 2.10.12+ versions.
|
||||
|
61
dwm.h
61
dwm.h
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
/* See LICENSE file for copyright and license details.
|
||||
*
|
||||
* dynamic window manager is designed like any other X client as well. It is
|
||||
* driven through handling X events. In contrast to other X clients, a window
|
||||
@ -37,10 +35,11 @@
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
|
||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||
enum { BarTop, BarBot, BarOff }; /* bar position */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
@ -79,35 +78,37 @@ typedef struct {
|
||||
void (*arrange)(void);
|
||||
} Layout;
|
||||
|
||||
extern const char *tags[]; /* all tags */
|
||||
char stext[256]; /* status text */
|
||||
int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
int wax, way, wah, waw; /* windowarea geometry */
|
||||
unsigned int bh, blw; /* bar height, bar layout label width */
|
||||
unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
||||
void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool selscreen, *seltag; /* seltag is array of Bool */
|
||||
Client *clients, *sel, *stack; /* global client list and stack */
|
||||
Cursor cursor[CurLast];
|
||||
DC dc; /* global draw context */
|
||||
Display *dpy;
|
||||
Layout *lt;
|
||||
Window root, barwin;
|
||||
extern const char *tags[]; /* all tags */
|
||||
extern char stext[256]; /* status text */
|
||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
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 wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool selscreen, *seltag; /* seltag is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc; /* global draw context */
|
||||
extern Display *dpy;
|
||||
extern Layout *lt;
|
||||
extern Window root, barwin;
|
||||
|
||||
/* client.c */
|
||||
void attach(Client *c); /* attaches c to global client list */
|
||||
void ban(Client *c); /* bans c */
|
||||
void configure(Client *c); /* send synthetic configure event */
|
||||
void detach(Client *c); /* detaches c from global client list */
|
||||
void focus(Client *c); /* focus c, c may be NULL */
|
||||
void killclient(const char *arg); /* kill c nicely */
|
||||
void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
|
||||
void killclient(const char *arg); /* kill sel nicely */
|
||||
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 togglefloating(const char *arg); /* toggles focused client between floating/tiled state */
|
||||
void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
void updatetitle(Client *c); /* update the name of c */
|
||||
void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
|
||||
void unban(Client *c); /* unbans c */
|
||||
void unmanage(Client *c); /* destroy c */
|
||||
void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
void updatetitle(Client *c); /* update the name of c */
|
||||
|
||||
/* draw.c */
|
||||
void drawstatus(void); /* draw the bar */
|
||||
@ -125,11 +126,13 @@ void incnmaster(const char *arg); /* increments nmaster with arg's index value *
|
||||
void initlayouts(void); /* initialize layout array */
|
||||
Client *nexttiled(Client *c); /* returns tiled successor of c */
|
||||
void restack(void); /* restores z layers of all clients */
|
||||
void setlayout(const char *arg); /* sets layout, -1 toggles */
|
||||
void togglemax(const char *arg); /* toggles maximization of floating client */
|
||||
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 */
|
||||
void zoom(const char *arg); /* zooms the focused client to master area, arg is ignored */
|
||||
|
||||
/* main.c */
|
||||
void updatebarpos(void); /* updates the bar position */
|
||||
void quit(const char *arg); /* quit dwm nicely */
|
||||
int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
||||
@ -137,8 +140,8 @@ int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
void compileregs(void); /* initialize regexps of rules defined in config.h */
|
||||
Bool isvisible(Client *c); /* returns True if client is visible */
|
||||
void settags(Client *c, Client *trans); /* sets tags of c */
|
||||
void tag(const char *arg); /* tags c with arg's index */
|
||||
void toggletag(const char *arg); /* toggles c tags with arg's index */
|
||||
void tag(const char *arg); /* tags sel 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 view(const char *arg); /* views the tag with arg's index */
|
||||
|
||||
|
29
event.c
29
event.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -185,6 +183,10 @@ configurerequest(XEvent *e) {
|
||||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->h = ev->height;
|
||||
if((c->x + c->w) > sw && c->isfloating)
|
||||
c->x = sw / 2 - c->w / 2; /* center in x direction */
|
||||
if((c->y + c->h) > sh && c->isfloating)
|
||||
c->y = sh / 2 - c->h / 2; /* center in y direction */
|
||||
if((ev->value_mask & (CWX | CWY))
|
||||
&& !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
configure(c);
|
||||
@ -207,6 +209,21 @@ configurerequest(XEvent *e) {
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
configurenotify(XEvent *e) {
|
||||
XConfigureEvent *ev = &e->xconfigure;
|
||||
|
||||
if (ev->window == root && (ev->width != sw || ev->height != sh)) {
|
||||
sw = ev->width;
|
||||
sh = ev->height;
|
||||
XFreePixmap(dpy, dc.drawable);
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
XResizeWindow(dpy, barwin, sw, bh);
|
||||
updatebarpos();
|
||||
lt->arrange();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
destroynotify(XEvent *e) {
|
||||
Client *c;
|
||||
@ -223,12 +240,11 @@ enternotify(XEvent *e) {
|
||||
|
||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||
return;
|
||||
if((c = getclient(ev->window)) && isvisible(c))
|
||||
if((c = getclient(ev->window)))
|
||||
focus(c);
|
||||
else if(ev->window == root) {
|
||||
selscreen = True;
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
focus(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,6 +349,7 @@ unmapnotify(XEvent *e) {
|
||||
void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[ButtonPress] = buttonpress,
|
||||
[ConfigureRequest] = configurerequest,
|
||||
[ConfigureNotify] = configurenotify,
|
||||
[DestroyNotify] = destroynotify,
|
||||
[EnterNotify] = enternotify,
|
||||
[LeaveNotify] = leavenotify,
|
||||
|
84
layout.c
84
layout.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -28,9 +26,7 @@ tile(void) {
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isbanned)
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
unban(c);
|
||||
if(c->isfloating)
|
||||
continue;
|
||||
c->ismax = False;
|
||||
@ -39,14 +35,20 @@ tile(void) {
|
||||
if(i < nmaster) {
|
||||
ny += i * mh;
|
||||
nw = mw - 2 * c->border;
|
||||
nh = mh - 2 * c->border;
|
||||
nh = mh;
|
||||
if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
|
||||
nh = wah - mh * i;
|
||||
nh -= 2 * c->border;
|
||||
}
|
||||
else { /* tile window */
|
||||
nx += mw;
|
||||
nw = tw - 2 * c->border;
|
||||
if(th > 2 * c->border) {
|
||||
ny += (i - nmaster) * th;
|
||||
nh = th - 2 * c->border;
|
||||
nh = th;
|
||||
if(i + 1 == n) /* remainder */
|
||||
nh = wah - th * (i - nmaster);
|
||||
nh -= 2 * c->border;
|
||||
}
|
||||
else /* fallback if th <= 2 * c->border */
|
||||
nh = wah - 2 * c->border;
|
||||
@ -54,14 +56,9 @@ tile(void) {
|
||||
resize(c, nx, ny, nw, nh, False);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
c->isbanned = True;
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
focus(NULL);
|
||||
restack();
|
||||
}
|
||||
|
||||
@ -73,22 +70,14 @@ void
|
||||
floating(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
for(c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isbanned)
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
unban(c);
|
||||
resize(c, c->x, c->y, c->w, c->h, True);
|
||||
}
|
||||
else {
|
||||
c->isbanned = True;
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
}
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
focus(NULL);
|
||||
restack();
|
||||
}
|
||||
|
||||
@ -175,6 +164,7 @@ void
|
||||
restack(void) {
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
XWindowChanges wc;
|
||||
|
||||
drawstatus();
|
||||
if(!sel)
|
||||
@ -182,12 +172,17 @@ restack(void) {
|
||||
if(sel->isfloating || lt->arrange == floating)
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
if(lt->arrange != floating) {
|
||||
if(!sel->isfloating)
|
||||
XLowerWindow(dpy, sel->win);
|
||||
wc.stack_mode = Below;
|
||||
wc.sibling = barwin;
|
||||
if(!sel->isfloating) {
|
||||
XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
|
||||
wc.sibling = sel->win;
|
||||
}
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
if(c == sel)
|
||||
continue;
|
||||
XLowerWindow(dpy, c->win);
|
||||
XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
|
||||
wc.sibling = c->win;
|
||||
}
|
||||
}
|
||||
XSync(dpy, False);
|
||||
@ -199,11 +194,9 @@ setlayout(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(!arg) {
|
||||
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
|
||||
if(i == nlayouts - 1)
|
||||
lt = &layout[0];
|
||||
else
|
||||
lt = &layout[++i];
|
||||
lt++;
|
||||
if(lt == layout + nlayouts)
|
||||
lt = layout;
|
||||
}
|
||||
else {
|
||||
i = atoi(arg);
|
||||
@ -217,6 +210,16 @@ setlayout(const char *arg) {
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
togglebar(const char *arg) {
|
||||
if(bpos == BarOff)
|
||||
bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
|
||||
else
|
||||
bpos = BarOff;
|
||||
updatebarpos();
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
togglemax(const char *arg) {
|
||||
XEvent ev;
|
||||
@ -228,7 +231,7 @@ togglemax(const char *arg) {
|
||||
sel->ry = sel->y;
|
||||
sel->rw = sel->w;
|
||||
sel->rh = sel->h;
|
||||
resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
|
||||
resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
|
||||
}
|
||||
else
|
||||
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
|
||||
@ -238,13 +241,10 @@ togglemax(const char *arg) {
|
||||
|
||||
void
|
||||
zoom(const char *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
if(!sel || lt->arrange != tile || sel->isfloating)
|
||||
if(!sel || lt->arrange == floating || sel->isfloating)
|
||||
return;
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
return;
|
||||
|
53
main.c
53
main.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
@ -18,7 +16,9 @@
|
||||
|
||||
char stext[256];
|
||||
int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int bh, ntags, numlockmask;
|
||||
unsigned int bh, ntags;
|
||||
unsigned int bpos = BARPOS;
|
||||
unsigned int numlockmask = 0;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool *seltag;
|
||||
Bool selscreen = True;
|
||||
@ -40,8 +40,7 @@ static void
|
||||
cleanup(void) {
|
||||
close(STDIN_FILENO);
|
||||
while(stack) {
|
||||
if(stack->isbanned)
|
||||
XMoveWindow(dpy, stack->win, stack->x, stack->y);
|
||||
unban(stack);
|
||||
unmanage(stack);
|
||||
}
|
||||
if(dc.font.set)
|
||||
@ -152,7 +151,6 @@ setup(void) {
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
/* init modifier map */
|
||||
numlockmask = 0;
|
||||
modmap = XGetModifierMapping(dpy);
|
||||
for (i = 0; i < 8; i++)
|
||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||
@ -163,9 +161,10 @@ setup(void) {
|
||||
XFreeModifiermap(modmap);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask;
|
||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||
XSelectInput(dpy, root, wa.event_mask);
|
||||
grabkeys();
|
||||
compileregs();
|
||||
for(ntags = 0; tags[ntags]; ntags++);
|
||||
@ -189,17 +188,13 @@ setup(void) {
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
barwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? 0 : sh - bh), sw, bh, 0,
|
||||
barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
updatebarpos();
|
||||
XMapRaised(dpy, barwin);
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* windowarea */
|
||||
wax = sx;
|
||||
way = sy + (TOPBAR ? bh : 0);
|
||||
wah = sh - bh;
|
||||
waw = sw;
|
||||
/* pixmap for everything */
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
@ -227,6 +222,32 @@ quit(const char *arg) {
|
||||
readin = running = False;
|
||||
}
|
||||
|
||||
void
|
||||
updatebarpos(void) {
|
||||
XEvent ev;
|
||||
|
||||
wax = sx;
|
||||
way = sy;
|
||||
wah = sh;
|
||||
waw = sw;
|
||||
switch(bpos) {
|
||||
default:
|
||||
wah -= bh;
|
||||
way += bh;
|
||||
XMoveWindow(dpy, barwin, sx, sy);
|
||||
break;
|
||||
case BarBot:
|
||||
wah -= bh;
|
||||
XMoveWindow(dpy, barwin, sx, sy + wah);
|
||||
break;
|
||||
case BarOff:
|
||||
XMoveWindow(dpy, barwin, sx, sy - bh);
|
||||
break;
|
||||
}
|
||||
XSync(dpy, False);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||
* default error handler, which may call exit.
|
||||
@ -254,8 +275,8 @@ main(int argc, char *argv[]) {
|
||||
fd_set rd;
|
||||
XEvent ev;
|
||||
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3))
|
||||
eprint("dwm-"VERSION", © 2004-2007 Anselm R. Garbe, Sander van Dijk\n");
|
||||
if(argc == 2 && !strcmp("-v", argv[1]))
|
||||
eprint("dwm-"VERSION", © 2006-2007 A. R. Garbe, S. van Dijk, J. Salmi, P. Hruby, S. Nagy\n");
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
4
tag.c
4
tag.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
|
4
util.c
4
util.c
@ -1,6 +1,4 @@
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
Reference in New Issue
Block a user