dwm.c
author Anselm R Garbe <garbeam@gmail.com>
Tue, 06 May 2008 15:52:44 +0100
changeset 1187 264e671527e6
parent 1186 48ffaf800504
child 1188 1765468a0546
permissions -rw-r--r--
applied the proposal by nsz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
992
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     1
/* See LICENSE file for copyright and license details.
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     2
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     3
 * dynamic window manager is designed like any other X client as well. It is
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     4
 * driven through handling X events. In contrast to other X clients, a window
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     5
 * manager selects for SubstructureRedirectMask on the root window, to receive
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     6
 * events about window (dis-)appearance.  Only one X connection at a time is
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     7
 * allowed to select for this event mask.
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     8
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
     9
 * Calls to fetch an X event from the event queue are blocking.  Due reading
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    10
 * status text from standard input, a select()-driven main loop has been
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    11
 * implemented which selects for reads on the X connection and STDIN_FILENO to
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    12
 * handle all data smoothly. The event handlers of dwm are organized in an
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    13
 * array which is accessed whenever a new event has been fetched. This allows
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    14
 * event dispatching in O(1) time.
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    15
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    16
 * Each child of the root window is called a client, except windows which have
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    17
 * set the override_redirect flag.  Clients are organized in a global
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    18
 * doubly-linked client list, the focus history is remembered through a global
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    19
 * stack list. Each client contains an array of Bools of the same size as the
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
    20
 * global tags array to indicate the tags of a client.
992
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    21
 *
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
    22
 * Keys and tagging rules are organized as arrays and defined in config.h.
992
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    23
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    24
 * To understand everything else, start reading main().
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    25
 */
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    26
#include <errno.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    27
#include <locale.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    28
#include <stdarg.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    29
#include <stdio.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    30
#include <stdlib.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    31
#include <string.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    32
#include <unistd.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    33
#include <sys/select.h>
1014
35461e0a4894 fixed inclusion order
arg@suckless.org
parents: 1008
diff changeset
    34
#include <sys/types.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    35
#include <sys/wait.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    36
#include <X11/cursorfont.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    37
#include <X11/keysym.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    38
#include <X11/Xatom.h>
1033
a8efbb301ef4 just making dwm.h saner
arg@suckless.org
parents: 1032
diff changeset
    39
#include <X11/Xlib.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    40
#include <X11/Xproto.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    41
#include <X11/Xutil.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    42
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    43
/* macros */
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
    44
#define MAX(a, b) ((a)>(b)?(a):(b))
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
    45
#define MIN(a, b) ((a)<(b)?(a):(b))
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
    46
#define BUTTONMASK		(ButtonPressMask|ButtonReleaseMask)
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
    47
#define CLEANMASK(mask)		(mask & ~(numlockmask|LockMask))
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
    48
#define LENGTH(x)		(sizeof x / sizeof x[0])
1118
e8efb587e751 renamed MAXLEN into MAXTAGLEN (backward compliance)
anselm@anselm1
parents: 1117
diff changeset
    49
#define MAXTAGLEN		16
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
    50
#define MOUSEMASK		(BUTTONMASK|PointerMotionMask)
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    51
#define DEFGEOM(GEONAME,BX,BY,BW,WX,WY,WW,WH,MX,MY,MW,MH,TX,TY,TW,TH,MOX,MOY,MOW,MOH) \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    52
void GEONAME(void) { \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    53
	bx = (BX); by = (BY); bw = (BW); \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    54
	wx = (WX); wy = (WY); ww = (WW); wh = (WH); \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    55
	mx = (MX); my = (MY); mw = (MW); mh = (MH); \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    56
	tx = (TX); ty = (TY); tw = (TW); th = (TH); \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    57
	mox = (MOX); moy = (MOY); mow = (MOW); moh = (MOH); \
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
    58
}
1059
98d06be63ce5 moved LENGTH to dwm.c, moved prevtags to dwm.c
arg@suckless.org
parents: 1058
diff changeset
    59
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    60
/* enums */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    61
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    62
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
1066
9f49779c6562 removed support for the NetSupportingWmCheck stuff, netbeans, argouml and others also don't work with compiz, so it is Suns problem to provide a fix
Anselm R. Garbe <garbeam@gmail.com>
parents: 1065
diff changeset
    63
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    64
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    65
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    66
/* typedefs */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    67
typedef struct Client Client;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    68
struct Client {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    69
	char name[256];
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    70
	int x, y, w, h;
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
    71
	int fx, fy, fw, fh;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    72
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    73
	int minax, maxax, minay, maxay;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    74
	long flags;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
    75
	unsigned int bw, oldbw;
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
    76
	Bool isbanned, isfixed, isfloating, isurgent;
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
    77
	Bool *tags;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    78
	Client *next;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    79
	Client *prev;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    80
	Client *snext;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    81
	Window win;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    82
};
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    83
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    84
typedef struct {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    85
	int x, y, w, h;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    86
	unsigned long norm[ColLast];
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    87
	unsigned long sel[ColLast];
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    88
	Drawable drawable;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    89
	GC gc;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    90
	struct {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    91
		int ascent;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    92
		int descent;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    93
		int height;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    94
		XFontSet set;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    95
		XFontStruct *xfont;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    96
	} font;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    97
} DC; /* draw context */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    98
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    99
typedef struct {
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
   100
	const char *symbol;
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
   101
	void (*apply)(void);
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
   102
} Geom;
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
   103
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
   104
typedef struct {
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   105
	unsigned long mod;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   106
	KeySym keysym;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   107
	void (*func)(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   108
	const char *arg;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   109
} Key;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   110
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   111
typedef struct {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   112
	const char *symbol;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   113
	void (*arrange)(void);
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   114
	Bool isfloating;
1187
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   115
} Layout;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   116
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   117
typedef struct {
1147
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   118
	const char *class;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   119
	const char *instance;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   120
	const char *title;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   121
	const char *tag;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   122
	Bool isfloating;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   123
} Rule;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   124
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   125
/* function declarations */
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   126
void applyrules(Client *c);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   127
void arrange(void);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   128
void attach(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   129
void attachstack(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   130
void ban(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   131
void buttonpress(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   132
void checkotherwm(void);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   133
void cleanup(void);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   134
void configure(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   135
void configurenotify(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   136
void configurerequest(XEvent *e);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   137
unsigned int counttiled(void);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   138
void destroynotify(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   139
void detach(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   140
void detachstack(Client *c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   141
void drawbar(void);
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   142
void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   143
void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   144
void *emallocz(unsigned int size);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   145
void enternotify(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   146
void eprint(const char *errstr, ...);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   147
void expose(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   148
void focus(Client *c);
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   149
void focusin(XEvent *e);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   150
void focusnext(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   151
void focusprev(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   152
Client *getclient(Window w);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   153
unsigned long getcolor(const char *colstr);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   154
long getstate(Window w);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   155
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   156
void grabbuttons(Client *c, Bool focused);
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   157
void grabkeys(void);
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   158
unsigned int idxoftag(const char *t);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   159
void initfont(const char *fontstr);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   160
Bool isoccupied(unsigned int t);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   161
Bool isprotodel(Client *c);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   162
Bool isurgent(unsigned int t);
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   163
Bool isvisible(Client *c);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   164
void keypress(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   165
void killclient(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   166
void manage(Window w, XWindowAttributes *wa);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   167
void mappingnotify(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   168
void maprequest(XEvent *e);
1121
898952a1689d renamed maximise to monocle again.
Anselm R Garbe <garbeam@gmail.com>
parents: 1120
diff changeset
   169
void monocle(void);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   170
void movemouse(Client *c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   171
Client *nexttiled(Client *c);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   172
void propertynotify(XEvent *e);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   173
void quit(const char *arg);
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
   174
void reapply(const char *arg);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   175
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   176
void resizemouse(Client *c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   177
void restack(void);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   178
void run(void);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   179
void scan(void);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   180
void setclientstate(Client *c, long state);
1148
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
   181
void setgeom(const char *arg);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   182
void setlayout(const char *arg);
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
   183
void setmfact(const char *arg);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   184
void setup(void);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   185
void spawn(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   186
void tag(const char *arg);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   187
unsigned int textnw(const char *text, unsigned int len);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   188
unsigned int textw(const char *text);
1130
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
   189
void tileh(void);
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
   190
void tilehstack(unsigned int n);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   191
Client *tilemaster(unsigned int n);
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   192
void tileresize(Client *c, int x, int y, int w, int h);
1130
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
   193
void tilev(void);
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   194
void tilevstack(unsigned int n);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   195
void togglefloating(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   196
void toggletag(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   197
void toggleview(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   198
void unban(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   199
void unmanage(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   200
void unmapnotify(XEvent *e);
1136
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
   201
void updatebarpos(void);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   202
void updatesizehints(Client *c);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   203
void updatetitle(Client *c);
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   204
void updatewmhints(Client *c);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   205
void view(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   206
void viewprevtag(const char *arg);	/* views previous selected tags */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   207
int xerror(Display *dpy, XErrorEvent *ee);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   208
int xerrordummy(Display *dpy, XErrorEvent *ee);
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   209
int xerrorstart(Display *dpy, XErrorEvent *ee);
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   210
void zoom(const char *arg);
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   211
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   212
/* variables */
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   213
char stext[256];
1123
76f6c8659f40 implemented the stuff as I discussed on dwm@
Anselm R Garbe <garbeam@gmail.com>
parents: 1122
diff changeset
   214
int screen, sx, sy, sw, sh;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   215
int (*xerrorxlib)(Display *, XErrorEvent *);
1151
8b2bff54fd0f geoms are now drawed in the status bar
Anselm R Garbe <garbeam@gmail.com>
parents: 1150
diff changeset
   216
int bx, by, bw, bh, blw, bgw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh;
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
   217
int seltags = 0;
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   218
double mfact;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   219
unsigned int numlockmask = 0;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   220
void (*handler[LASTEvent]) (XEvent *) = {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   221
	[ButtonPress] = buttonpress,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   222
	[ConfigureRequest] = configurerequest,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   223
	[ConfigureNotify] = configurenotify,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   224
	[DestroyNotify] = destroynotify,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   225
	[EnterNotify] = enternotify,
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   226
	[Expose] = expose,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   227
	[FocusIn] = focusin,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   228
	[KeyPress] = keypress,
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   229
	[MappingNotify] = mappingnotify,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   230
	[MapRequest] = maprequest,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   231
	[PropertyNotify] = propertynotify,
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   232
	[UnmapNotify] = unmapnotify
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   233
};
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   234
Atom wmatom[WMLast], netatom[NetLast];
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   235
Bool otherwm, readin;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   236
Bool running = True;
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
   237
Bool *tagset[2];
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   238
Client *clients = NULL;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   239
Client *sel = NULL;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   240
Client *stack = NULL;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   241
Cursor cursor[CurLast];
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   242
Display *dpy;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   243
DC dc = {0};
1187
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   244
Geom geoms[];
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   245
Geom *geom = geoms;
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   246
Layout layouts[];
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   247
Layout *lt = layouts;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   248
Window root, barwin;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   249
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   250
/* configuration, allows nested code to access above variables */
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   251
#include "config.h"
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   252
#define TAGSZ (LENGTH(tags) * sizeof(Bool))
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   253
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   254
/* function implementations */
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   255
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   256
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   257
applyrules(Client *c) {
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   258
	unsigned int i;
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   259
	Bool matched = False;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   260
	Rule *r;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   261
	XClassHint ch = { 0 };
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   262
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   263
	/* rule matching */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   264
	XGetClassHint(dpy, c->win, &ch);
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   265
	for(i = 0; i < LENGTH(rules); i++) {
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   266
		r = &rules[i];
1174
cb9dcaba37b6 applied applyrules-fix by Jukka, thank you Jukka!
Anselm R Garbe <garbeam@gmail.com>
parents: 1173
diff changeset
   267
		if((!r->title || strstr(c->name, r->title))
1176
44df4a068f31 applied Gottox' applyrules() fix
anselm@anselm1
parents: 1174
diff changeset
   268
		&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
44df4a068f31 applied Gottox' applyrules() fix
anselm@anselm1
parents: 1174
diff changeset
   269
		&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   270
			c->isfloating = r->isfloating;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   271
			if(r->tag) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   272
				c->tags[idxoftag(r->tag)] = True;
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   273
				matched = True;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   274
			}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   275
		}
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   276
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   277
	if(ch.res_class)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   278
		XFree(ch.res_class);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   279
	if(ch.res_name)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   280
		XFree(ch.res_name);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   281
	if(!matched)
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
   282
		memcpy(c->tags, tagset[seltags], TAGSZ);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   283
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   284
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   285
void
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   286
arrange(void) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   287
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   288
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   289
	for(c = clients; c; c = c->next)
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   290
		if(isvisible(c)) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   291
			unban(c);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   292
			if(lt->isfloating || c->isfloating)
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   293
				resize(c, c->fx, c->fy, c->fw, c->fh, True);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   294
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   295
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   296
			ban(c);
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   297
1112
27d2e0f4ff82 fixed some issues nsz reported in IRC log
anselm@anselm1
parents: 1110
diff changeset
   298
	focus(NULL);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   299
	if(lt->arrange)
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   300
		lt->arrange();
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   301
	restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   302
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   303
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   304
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   305
attach(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   306
	if(clients)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   307
		clients->prev = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   308
	c->next = clients;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   309
	clients = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   310
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   311
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   312
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   313
attachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   314
	c->snext = stack;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   315
	stack = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   316
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   317
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   318
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   319
ban(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   320
	if(c->isbanned)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   321
		return;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   322
	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   323
	c->isbanned = True;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   324
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   325
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   326
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   327
buttonpress(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   328
	unsigned int i, x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   329
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   330
	XButtonPressedEvent *ev = &e->xbutton;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   331
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   332
	if(ev->window == barwin) {
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   333
		if((ev->x < bgw) && ev->button == Button1) {
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   334
			setgeom(NULL);
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   335
			return;
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   336
		}
1151
8b2bff54fd0f geoms are now drawed in the status bar
Anselm R Garbe <garbeam@gmail.com>
parents: 1150
diff changeset
   337
		x = bgw;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   338
		for(i = 0; i < LENGTH(tags); i++) {
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   339
			x += textw(tags[i]);
1163
Anselm R Garbe <garbeam@gmail.com>
parents: 1162
diff changeset
   340
			if(ev->x >= bgw && ev->x < x) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   341
				if(ev->button == Button1) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   342
					if(ev->state & MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   343
						tag(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   344
					else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   345
						view(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   346
				}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   347
				else if(ev->button == Button3) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   348
					if(ev->state & MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   349
						toggletag(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   350
					else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   351
						toggleview(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   352
				}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   353
				return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   354
			}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   355
		}
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   356
		if((ev->x < x + blw) && ev->button == Button1) 
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   357
			setlayout(NULL);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   358
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   359
	else if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   360
		focus(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   361
		if(CLEANMASK(ev->state) != MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   362
			return;
998
854a324f5c92 now tiled windows can be resized/moved, their floating state will be toggled implicitely
Anselm R. Garbe <garbeam@gmail.com>
parents: 997
diff changeset
   363
		if(ev->button == Button1) {
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   364
			restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   365
			movemouse(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   366
		}
999
d036b2f17567 Mod1-Button2 on a floating but not-fixed client will make it tiled again
Anselm R. Garbe <garbeam@gmail.com>
parents: 998
diff changeset
   367
		else if(ev->button == Button2) {
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   368
			if(!lt->isfloating && c->isfloating)
999
d036b2f17567 Mod1-Button2 on a floating but not-fixed client will make it tiled again
Anselm R. Garbe <garbeam@gmail.com>
parents: 998
diff changeset
   369
				togglefloating(NULL);
1083
f07dd2c127c1 fixed missing else branch
Anselm R Garbe <garbeam@gmail.com>
parents: 1082
diff changeset
   370
			else
f07dd2c127c1 fixed missing else branch
Anselm R Garbe <garbeam@gmail.com>
parents: 1082
diff changeset
   371
				zoom(NULL);
999
d036b2f17567 Mod1-Button2 on a floating but not-fixed client will make it tiled again
Anselm R. Garbe <garbeam@gmail.com>
parents: 998
diff changeset
   372
		}
998
854a324f5c92 now tiled windows can be resized/moved, their floating state will be toggled implicitely
Anselm R. Garbe <garbeam@gmail.com>
parents: 997
diff changeset
   373
		else if(ev->button == Button3 && !c->isfixed) {
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   374
			restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   375
			resizemouse(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   376
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   377
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   378
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   379
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   380
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   381
checkotherwm(void) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   382
	otherwm = False;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   383
	XSetErrorHandler(xerrorstart);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   384
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   385
	/* this causes an error if some other window manager is running */
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   386
	XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   387
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   388
	if(otherwm)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   389
		eprint("dwm: another window manager is already running\n");
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   390
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   391
	XSetErrorHandler(NULL);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   392
	xerrorxlib = XSetErrorHandler(xerror);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   393
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   394
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   395
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   396
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   397
cleanup(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   398
	close(STDIN_FILENO);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   399
	while(stack) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   400
		unban(stack);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   401
		unmanage(stack);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   402
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   403
	if(dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   404
		XFreeFontSet(dpy, dc.font.set);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   405
	else
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   406
		XFreeFont(dpy, dc.font.xfont);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   407
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   408
	XFreePixmap(dpy, dc.drawable);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   409
	XFreeGC(dpy, dc.gc);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   410
	XFreeCursor(dpy, cursor[CurNormal]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   411
	XFreeCursor(dpy, cursor[CurResize]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   412
	XFreeCursor(dpy, cursor[CurMove]);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   413
	XDestroyWindow(dpy, barwin);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   414
	XSync(dpy, False);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   415
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   416
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   417
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   418
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   419
configure(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   420
	XConfigureEvent ce;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   421
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   422
	ce.type = ConfigureNotify;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   423
	ce.display = dpy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   424
	ce.event = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   425
	ce.window = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   426
	ce.x = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   427
	ce.y = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   428
	ce.width = c->w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   429
	ce.height = c->h;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
   430
	ce.border_width = c->bw;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   431
	ce.above = None;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   432
	ce.override_redirect = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   433
	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   434
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   435
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   436
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   437
configurenotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   438
	XConfigureEvent *ev = &e->xconfigure;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   439
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   440
	if(ev->window == root && (ev->width != sw || ev->height != sh)) {
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   441
		sw = ev->width;
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   442
		sh = ev->height;
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
   443
		setgeom(geom->symbol);
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   444
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   445
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   446
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   447
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   448
configurerequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   449
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   450
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   451
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   452
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   453
	if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   454
		if(ev->value_mask & CWBorderWidth)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
   455
			c->bw = ev->border_width;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   456
		if(c->isfixed || c->isfloating || lt->isfloating) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   457
			if(ev->value_mask & CWX)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   458
				c->x = sx + ev->x;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   459
			if(ev->value_mask & CWY)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   460
				c->y = sy + ev->y;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   461
			if(ev->value_mask & CWWidth)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   462
				c->w = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   463
			if(ev->value_mask & CWHeight)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   464
				c->h = ev->height;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   465
			if((c->x - sx + c->w) > sw && c->isfloating)
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   466
				c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   467
			if((c->y - sy + c->h) > sh && c->isfloating)
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   468
				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   469
			if((ev->value_mask & (CWX|CWY))
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   470
			&& !(ev->value_mask & (CWWidth|CWHeight)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   471
				configure(c);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   472
			if(isvisible(c))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   473
				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   474
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   475
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   476
			configure(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   477
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   478
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   479
		wc.x = ev->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   480
		wc.y = ev->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   481
		wc.width = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   482
		wc.height = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   483
		wc.border_width = ev->border_width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   484
		wc.sibling = ev->above;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   485
		wc.stack_mode = ev->detail;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   486
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   487
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   488
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   489
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   490
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   491
unsigned int
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   492
counttiled(void) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   493
	unsigned int n;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   494
	Client *c;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   495
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   496
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   497
	return n;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   498
}
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
   499
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   500
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   501
destroynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   502
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   503
	XDestroyWindowEvent *ev = &e->xdestroywindow;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   504
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   505
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   506
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   507
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   508
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   509
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   510
detach(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   511
	if(c->prev)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   512
		c->prev->next = c->next;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   513
	if(c->next)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   514
		c->next->prev = c->prev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   515
	if(c == clients)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   516
		clients = c->next;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   517
	c->next = c->prev = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   518
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   519
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   520
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   521
detachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   522
	Client **tc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   523
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   524
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   525
	*tc = c->snext;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   526
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   527
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   528
void
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   529
drawbar(void) {
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   530
	int i, x;
1086
dadc0b94f695 some drawbar() polishing, and certain related fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1085
diff changeset
   531
	Client *c;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   532
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   533
	dc.x = 0;
1158
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   534
	if(bgw > 0) {
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   535
		dc.w = bgw;
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   536
		drawtext(geom->symbol, dc.norm, False);
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   537
		dc.x += bgw;
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   538
	}
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   539
	for(c = stack; c && !isvisible(c); c = c->snext);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   540
	for(i = 0; i < LENGTH(tags); i++) {
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   541
		dc.w = textw(tags[i]);
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
   542
		if(tagset[seltags][i]) {
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   543
			drawtext(tags[i], dc.sel, isurgent(i));
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   544
			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   545
		}
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   546
		else {
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   547
			drawtext(tags[i], dc.norm, isurgent(i));
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   548
			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.norm);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   549
		}
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   550
		dc.x += dc.w;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   551
	}
1158
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   552
	if(blw > 0) {
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   553
		dc.w = blw;
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   554
		drawtext(lt->symbol, dc.norm, False);
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   555
		x = dc.x + dc.w;
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   556
	}
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   557
	else
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
   558
		x = dc.x;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   559
	dc.w = textw(stext);
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
   560
	dc.x = bw - dc.w;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   561
	if(dc.x < x) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   562
		dc.x = x;
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
   563
		dc.w = bw - x;
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   564
	}
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   565
	drawtext(stext, dc.norm, False);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   566
	if((dc.w = dc.x - x) > bh) {
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   567
		dc.x = x;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   568
		if(c) {
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   569
			drawtext(c->name, dc.sel, False);
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   570
			drawsquare(False, c->isfloating, False, dc.sel);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   571
		}
1086
dadc0b94f695 some drawbar() polishing, and certain related fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1085
diff changeset
   572
		else
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   573
			drawtext(NULL, dc.norm, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   574
	}
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
   575
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   576
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   577
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   578
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   579
void
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   580
drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   581
	int x;
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   582
	XGCValues gcv;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   583
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   584
1085
9c4355f988f2 urgency hook handling needs also to invert the square if present
Anselm R Garbe <garbeam@gmail.com>
parents: 1084
diff changeset
   585
	gcv.foreground = col[invert ? ColBG : ColFG];
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   586
	XChangeGC(dpy, dc.gc, GCForeground, &gcv);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   587
	x = (dc.font.ascent + dc.font.descent + 2) / 4;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   588
	r.x = dc.x + 1;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   589
	r.y = dc.y + 1;
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   590
	if(filled) {
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   591
		r.width = r.height = x + 1;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   592
		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   593
	}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   594
	else if(empty) {
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   595
		r.width = r.height = x;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   596
		XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   597
	}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   598
}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   599
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   600
void
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   601
drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   602
	int x, y, w, h;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   603
	unsigned int len, olen;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   604
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   605
	char buf[256];
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   606
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   607
	XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   608
	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   609
	if(!text)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   610
		return;
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   611
	olen = strlen(text);
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   612
	len = MIN(olen, sizeof buf);
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   613
	memcpy(buf, text, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   614
	w = 0;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   615
	h = dc.font.ascent + dc.font.descent;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   616
	y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   617
	x = dc.x + (h / 2);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   618
	/* shorten text if necessary */
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   619
	for(; len && (w = textnw(buf, len)) > dc.w - h; len--);
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   620
	if (!len)
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   621
		return;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   622
	if(len < olen) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   623
		if(len > 1)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   624
			buf[len - 1] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   625
		if(len > 2)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   626
			buf[len - 2] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   627
		if(len > 3)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   628
			buf[len - 3] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   629
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   630
	XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   631
	if(dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   632
		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   633
	else
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   634
		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   635
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   636
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   637
void *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   638
emallocz(unsigned int size) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   639
	void *res = calloc(1, size);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   640
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   641
	if(!res)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   642
		eprint("fatal: could not malloc() %u bytes\n", size);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   643
	return res;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   644
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   645
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   646
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   647
enternotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   648
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   649
	XCrossingEvent *ev = &e->xcrossing;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   650
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   651
	if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   652
		return;
1023
f6b71fb9ea39 reverted Peters patch to tile, I will discuss the reasons at dwm@
Anselm R. Garbe <garbeam@gmail.com>
parents: 1018
diff changeset
   653
	if((c = getclient(ev->window)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   654
		focus(c);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   655
	else
1079
ba7486659f1d got initial Xinerama support working, though there is a lot work todo
anselm@aab
parents: 1078
diff changeset
   656
		focus(NULL);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   657
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   658
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   659
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   660
eprint(const char *errstr, ...) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   661
	va_list ap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   662
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   663
	va_start(ap, errstr);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   664
	vfprintf(stderr, errstr, ap);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   665
	va_end(ap);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   666
	exit(EXIT_FAILURE);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   667
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   668
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   669
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   670
expose(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   671
	XExposeEvent *ev = &e->xexpose;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   672
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   673
	if(ev->count == 0 && (ev->window == barwin))
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   674
		drawbar();
1110
227f2d07c63f made the basics of the tagging concept working -- if people want dynamic tags, that's even possible with this concept, the vtags[] array needs to be modified during runtime for this -- the new code is quite experimental, ugly and needs polishing
anselm@anselm1
parents: 1109
diff changeset
   675
}
227f2d07c63f made the basics of the tagging concept working -- if people want dynamic tags, that's even possible with this concept, the vtags[] array needs to be modified during runtime for this -- the new code is quite experimental, ugly and needs polishing
anselm@anselm1
parents: 1109
diff changeset
   676
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   677
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   678
focus(Client *c) {
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   679
	if(!c || (c && !isvisible(c)))
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   680
		for(c = stack; c && !isvisible(c); c = c->snext);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   681
	if(sel && sel != c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   682
		grabbuttons(sel, False);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   683
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   684
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   685
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   686
		detachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   687
		attachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   688
		grabbuttons(c, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   689
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   690
	sel = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   691
	if(c) {
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   692
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   693
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   694
	}
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   695
	else
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   696
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   697
	drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   698
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   699
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   700
void
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   701
focusin(XEvent *e) { /* there are some broken focus acquiring clients */
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   702
	XFocusChangeEvent *ev = &e->xfocus;
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   703
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   704
	if(sel && ev->window != sel->win)
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   705
		XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   706
}
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   707
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   708
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   709
focusnext(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   710
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   711
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   712
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   713
		return;
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   714
	for(c = sel->next; c && !isvisible(c); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   715
	if(!c)
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   716
		for(c = clients; c && !isvisible(c); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   717
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   718
		focus(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   719
		restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   720
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   721
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   722
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   723
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   724
focusprev(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   725
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   726
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   727
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   728
		return;
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   729
	for(c = sel->prev; c && !isvisible(c); c = c->prev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   730
	if(!c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   731
		for(c = clients; c && c->next; c = c->next);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   732
		for(; c && !isvisible(c); c = c->prev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   733
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   734
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   735
		focus(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   736
		restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   737
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   738
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   739
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   740
Client *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   741
getclient(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   742
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   743
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   744
	for(c = clients; c && c->win != w; c = c->next);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   745
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   746
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   747
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   748
unsigned long
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   749
getcolor(const char *colstr) {
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   750
	Colormap cmap = DefaultColormap(dpy, screen);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   751
	XColor color;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   752
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   753
	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   754
		eprint("error, cannot allocate color '%s'\n", colstr);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   755
	return color.pixel;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   756
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   757
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   758
long
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   759
getstate(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   760
	int format, status;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   761
	long result = -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   762
	unsigned char *p = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   763
	unsigned long n, extra;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   764
	Atom real;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   765
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   766
	status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   767
			&real, &format, &n, &extra, (unsigned char **)&p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   768
	if(status != Success)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   769
		return -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   770
	if(n != 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   771
		result = *p;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   772
	XFree(p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   773
	return result;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   774
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   775
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   776
Bool
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   777
gettextprop(Window w, Atom atom, char *text, unsigned int size) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   778
	char **list = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   779
	int n;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   780
	XTextProperty name;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   781
1058
5e34476a3a1c we check variable == value, and not the other way - the other way is for beginner programmers.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1057
diff changeset
   782
	if(!text || size == 0)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   783
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   784
	text[0] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   785
	XGetTextProperty(dpy, w, &name, atom);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   786
	if(!name.nitems)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   787
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   788
	if(name.encoding == XA_STRING)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   789
		strncpy(text, (char *)name.value, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   790
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   791
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
1058
5e34476a3a1c we check variable == value, and not the other way - the other way is for beginner programmers.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1057
diff changeset
   792
		&& n > 0 && *list) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   793
			strncpy(text, *list, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   794
			XFreeStringList(list);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   795
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   796
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   797
	text[size - 1] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   798
	XFree(name.value);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   799
	return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   800
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   801
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   802
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   803
grabbuttons(Client *c, Bool focused) {
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   804
	int i, j;
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   805
	unsigned int buttons[]   = { Button1, Button2, Button3 };
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   806
	unsigned int modifiers[] = { MODKEY, MODKEY|LockMask, MODKEY|numlockmask,
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   807
	                             MODKEY|numlockmask|LockMask} ;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   808
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   809
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   810
	if(focused)
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   811
		for(i = 0; i < LENGTH(buttons); i++)
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   812
			for(j = 0; j < LENGTH(modifiers); j++)
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   813
				XGrabButton(dpy, buttons[i], modifiers[j], c->win, False,
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   814
				            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   815
	else
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   816
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
   817
		            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   818
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   819
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   820
void
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   821
grabkeys(void)  {
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   822
	unsigned int i, j;
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   823
	KeyCode code;
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   824
	XModifierKeymap *modmap;
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   825
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   826
	/* init modifier map */
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   827
	modmap = XGetModifierMapping(dpy);
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   828
	for(i = 0; i < 8; i++)
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   829
		for(j = 0; j < modmap->max_keypermod; j++) {
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   830
			if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   831
				numlockmask = (1 << i);
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   832
		}
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   833
	XFreeModifiermap(modmap);
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   834
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   835
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   836
	for(i = 0; i < LENGTH(keys); i++) {
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   837
		code = XKeysymToKeycode(dpy, keys[i].keysym);
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   838
		XGrabKey(dpy, code, keys[i].mod, root, True,
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   839
				GrabModeAsync, GrabModeAsync);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   840
		XGrabKey(dpy, code, keys[i].mod|LockMask, root, True,
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   841
				GrabModeAsync, GrabModeAsync);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   842
		XGrabKey(dpy, code, keys[i].mod|numlockmask, root, True,
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   843
				GrabModeAsync, GrabModeAsync);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   844
		XGrabKey(dpy, code, keys[i].mod|numlockmask|LockMask, root, True,
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   845
				GrabModeAsync, GrabModeAsync);
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   846
	}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   847
}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   848
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   849
unsigned int
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   850
idxoftag(const char *t) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   851
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   852
1157
5fb97aa00e2f hotfix of idxoftag
anselm@anselm1
parents: 1156
diff changeset
   853
	for(i = 0; (i < LENGTH(tags)) && t && strcmp(tags[i], t); i++);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   854
	return (i < LENGTH(tags)) ? i : 0;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   855
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   856
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   857
void
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   858
initfont(const char *fontstr) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   859
	char *def, **missing;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   860
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   861
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   862
	missing = NULL;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   863
	if(dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   864
		XFreeFontSet(dpy, dc.font.set);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   865
	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   866
	if(missing) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   867
		while(n--)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   868
			fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   869
		XFreeStringList(missing);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   870
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   871
	if(dc.font.set) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   872
		XFontSetExtents *font_extents;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   873
		XFontStruct **xfonts;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   874
		char **font_names;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   875
		dc.font.ascent = dc.font.descent = 0;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   876
		font_extents = XExtentsOfFontSet(dc.font.set);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   877
		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   878
		for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
   879
			dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
   880
			dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   881
			xfonts++;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   882
		}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   883
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   884
	else {
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   885
		if(dc.font.xfont)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   886
			XFreeFont(dpy, dc.font.xfont);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   887
		dc.font.xfont = NULL;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   888
		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   889
		&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   890
			eprint("error, cannot load font: '%s'\n", fontstr);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   891
		dc.font.ascent = dc.font.xfont->ascent;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   892
		dc.font.descent = dc.font.xfont->descent;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   893
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   894
	dc.font.height = dc.font.ascent + dc.font.descent;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   895
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   896
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   897
Bool
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   898
isoccupied(unsigned int t) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   899
	Client *c;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   900
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   901
	for(c = clients; c; c = c->next)
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   902
		if(c->tags[t])
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   903
			return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   904
	return False;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   905
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   906
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   907
Bool
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   908
isprotodel(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   909
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   910
	Atom *protocols;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   911
	Bool ret = False;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   912
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   913
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   914
		for(i = 0; !ret && i < n; i++)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   915
			if(protocols[i] == wmatom[WMDelete])
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   916
				ret = True;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   917
		XFree(protocols);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   918
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   919
	return ret;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   920
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   921
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   922
Bool
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   923
isurgent(unsigned int t) {
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   924
	Client *c;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   925
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   926
	for(c = clients; c; c = c->next)
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   927
		if(c->isurgent && c->tags[t])
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   928
			return True;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   929
	return False;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   930
}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   931
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
   932
Bool
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
   933
isvisible(Client *c) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   934
	unsigned int i;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   935
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   936
	for(i = 0; i < LENGTH(tags); i++)
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
   937
		if(c->tags[i] && tagset[seltags][i])
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   938
			return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   939
	return False;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   940
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   941
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   942
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   943
keypress(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   944
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   945
	KeySym keysym;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   946
	XKeyEvent *ev;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   947
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   948
	ev = &e->xkey;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   949
	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   950
	for(i = 0; i < LENGTH(keys); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   951
		if(keysym == keys[i].keysym
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   952
		&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   953
		{
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   954
			if(keys[i].func)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   955
				keys[i].func(keys[i].arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   956
		}
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   957
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   958
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   959
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   960
killclient(const char *arg) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   961
	XEvent ev;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   962
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   963
	if(!sel)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   964
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   965
	if(isprotodel(sel)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   966
		ev.type = ClientMessage;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   967
		ev.xclient.window = sel->win;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   968
		ev.xclient.message_type = wmatom[WMProtocols];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   969
		ev.xclient.format = 32;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   970
		ev.xclient.data.l[0] = wmatom[WMDelete];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   971
		ev.xclient.data.l[1] = CurrentTime;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   972
		XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   973
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   974
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   975
		XKillClient(dpy, sel->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   976
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   977
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   978
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   979
manage(Window w, XWindowAttributes *wa) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   980
	Client *c, *t = NULL;
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   981
	Status rettrans;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   982
	Window trans;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   983
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   984
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   985
	c = emallocz(sizeof(Client));
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   986
	c->tags = emallocz(TAGSZ);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   987
	c->win = w;
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   988
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   989
	/* geometry */
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   990
	c->x = wa->x;
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
   991
	c->y = wa->y;
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   992
	c->w = c->fw = wa->width;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
   993
	c->h = c->fh = wa->height;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
   994
	c->oldbw = wa->border_width;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   995
	if(c->w == sw && c->h == sh) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   996
		c->x = sx;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   997
		c->y = sy;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
   998
		c->bw = wa->border_width;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   999
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1000
	else {
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1001
		if(c->x + c->w + 2 * c->bw > wx + ww)
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1002
			c->x = wx + ww - c->w - 2 * c->bw;
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1003
		if(c->y + c->h + 2 * c->bw > wy + wh)
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1004
			c->y = wy + wh - c->h - 2 * c->bw;
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1005
		c->x = MAX(c->x, wx);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1006
		c->y = MAX(c->y, wy);
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1007
		c->bw = BORDERPX;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1008
	}
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1009
	c->fx = c->x;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1010
	c->fy = c->y;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1011
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1012
	wc.border_width = c->bw;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1013
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1014
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1015
	configure(c); /* propagates border_width, if size doesn't change */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1016
	updatesizehints(c);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1017
	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1018
	grabbuttons(c, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1019
	updatetitle(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1020
	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1021
		for(t = clients; t && t->win != trans; t = t->next);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1022
	if(t)
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
  1023
		memcpy(c->tags, t->tags, TAGSZ);
1115
61f7a3e134e9 fixed applyrules bug
Anselm R Garbe <garbeam@gmail.com>
parents: 1114
diff changeset
  1024
	else
61f7a3e134e9 fixed applyrules bug
Anselm R Garbe <garbeam@gmail.com>
parents: 1114
diff changeset
  1025
		applyrules(c);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1026
	if(!c->isfloating)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1027
		c->isfloating = (rettrans == Success) || c->isfixed;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1028
	attach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1029
	attachstack(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1030
	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1031
	ban(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1032
	XMapWindow(dpy, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1033
	setclientstate(c, NormalState);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1034
	arrange();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1035
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1036
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1037
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1038
mappingnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1039
	XMappingEvent *ev = &e->xmapping;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1040
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1041
	XRefreshKeyboardMapping(ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1042
	if(ev->request == MappingKeyboard)
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1043
		grabkeys();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1044
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1045
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1046
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1047
maprequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1048
	static XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1049
	XMapRequestEvent *ev = &e->xmaprequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1050
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1051
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1052
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1053
	if(wa.override_redirect)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1054
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1055
	if(!getclient(ev->window))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1056
		manage(ev->window, &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1057
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1058
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1059
void
1147
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
  1060
monocle(void) {
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1061
	Client *c;
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1062
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1063
	for(c = clients; c; c = c->next)
1173
Anselm R Garbe <garbeam@gmail.com>
parents: 1172
diff changeset
  1064
		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1065
			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
1116
73ef516a4a88 monocle goes mainstream
Anselm R Garbe <garbeam@gmail.com>
parents: 1115
diff changeset
  1066
}
73ef516a4a88 monocle goes mainstream
Anselm R Garbe <garbeam@gmail.com>
parents: 1115
diff changeset
  1067
73ef516a4a88 monocle goes mainstream
Anselm R Garbe <garbeam@gmail.com>
parents: 1115
diff changeset
  1068
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1069
movemouse(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1070
	int x1, y1, ocx, ocy, di, nx, ny;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1071
	unsigned int dui;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1072
	Window dummy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1073
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1074
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1075
	ocx = nx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1076
	ocy = ny = c->y;
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1077
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1078
			None, cursor[CurMove], CurrentTime) != GrabSuccess)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1079
		return;
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1080
	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1081
	for(;;) {
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1082
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1083
		switch (ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1084
		case ButtonRelease:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1085
			XUngrabPointer(dpy, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1086
			return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1087
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1088
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1089
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1090
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1091
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1092
		case MotionNotify:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1093
			XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1094
			nx = ocx + (ev.xmotion.x - x1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1095
			ny = ocy + (ev.xmotion.y - y1);
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1096
			if(abs(wx - nx) < SNAP)
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1097
				nx = wx;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1098
			else if(abs((wx + ww) - (nx + c->w + 2 * c->bw)) < SNAP)
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1099
				nx = wx + ww - c->w - 2 * c->bw;
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1100
			if(abs(wy - ny) < SNAP)
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1101
				ny = wy;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1102
			else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < SNAP)
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1103
				ny = wy + wh - c->h - 2 * c->bw;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1104
			if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
  1105
				togglefloating(NULL);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1106
			if(lt->isfloating || c->isfloating) {
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1107
				c->fx = nx;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1108
				c->fy = ny;
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
  1109
				resize(c, nx, ny, c->w, c->h, False);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1110
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1111
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1112
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1113
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1114
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1115
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1116
Client *
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1117
nexttiled(Client *c) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1118
	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1119
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1120
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1121
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1122
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1123
propertynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1124
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1125
	Window trans;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1126
	XPropertyEvent *ev = &e->xproperty;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1127
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1128
	if(ev->state == PropertyDelete)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1129
		return; /* ignore */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1130
	if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1131
		switch (ev->atom) {
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1132
		default: break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1133
		case XA_WM_TRANSIENT_FOR:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1134
			XGetTransientForHint(dpy, c->win, &trans);
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1135
			if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1136
				arrange();
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1137
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1138
		case XA_WM_NORMAL_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1139
			updatesizehints(c);
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1140
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1141
		case XA_WM_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1142
			updatewmhints(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1143
			drawbar();
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1144
			break;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1145
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1146
		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1147
			updatetitle(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1148
			if(c == sel)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1149
				drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1150
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1151
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1152
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1153
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1154
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1155
quit(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1156
	readin = running = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1157
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1158
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1159
void
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1160
reapply(const char *arg) {
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1161
	Client *c;
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1162
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1163
	for(c = clients; c; c = c->next) {
1179
6fad217390c6 applied Ph's seltags-simplification with some modifications
anselm@anselm1
parents: 1178
diff changeset
  1164
		memset(c->tags, 0, TAGSZ);
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1165
		applyrules(c);
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1166
	}
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1167
	arrange();
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1168
}
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1169
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1170
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1171
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1024
17a935c3017f removed two spaces reported by Soleen
Anselm R. Garbe <garbeam@gmail.com>
parents: 1023
diff changeset
  1172
	XWindowChanges wc;
1090
09f1bf0e12ee resize handles offscreen issues
Anselm R Garbe <garbeam@gmail.com>
parents: 1089
diff changeset
  1173
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1174
	if(sizehints) {
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1175
		/* set minimum possible */
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1176
		w = MAX(1, w);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1177
		h = MAX(1, h);
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1178
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1179
		/* temporarily remove base dimensions */
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1180
		w -= c->basew;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1181
		h -= c->baseh;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1182
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1183
		/* adjust for aspect limits */
1165
3ac7eb240b52 aspects hints seem broken for fullscreen apps
Anselm R Garbe <garbeam@gmail.com>
parents: 1163
diff changeset
  1184
		if(c->minax != c->maxax && c->minay != c->maxay 
3ac7eb240b52 aspects hints seem broken for fullscreen apps
Anselm R Garbe <garbeam@gmail.com>
parents: 1163
diff changeset
  1185
		&& c->minax > 0 && c->maxax > 0 && c->minay > 0 && c->maxay > 0)
3ac7eb240b52 aspects hints seem broken for fullscreen apps
Anselm R Garbe <garbeam@gmail.com>
parents: 1163
diff changeset
  1186
		{
1169
22c669b2dd36 yet another cleanup
Anselm R Garbe <garbeam@gmail.com>
parents: 1166
diff changeset
  1187
			if(w * c->maxay > h * c->maxax)
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1188
				w = h * c->maxax / c->maxay;
1169
22c669b2dd36 yet another cleanup
Anselm R Garbe <garbeam@gmail.com>
parents: 1166
diff changeset
  1189
			else if(w * c->minay < h * c->minax)
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1190
				h = w * c->minay / c->minax;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1191
		}
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1192
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1193
		/* adjust for increment value */
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1194
		if(c->incw)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1195
			w -= w % c->incw;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1196
		if(c->inch)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1197
			h -= h % c->inch;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1198
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1199
		/* restore base dimensions */
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1200
		w += c->basew;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1201
		h += c->baseh;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1202
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1203
		w = MAX(w, c->minw);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1204
		h = MAX(h, c->minh);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1205
		
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1206
		if (c->maxw)
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1207
			w = MIN(w, c->maxw);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1208
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1209
		if (c->maxh)
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1210
			h = MIN(h, c->maxh);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1211
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1212
	if(w <= 0 || h <= 0)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1213
		return;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1214
	if(x > sx + sw)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1215
		x = sw - w - 2 * c->bw;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1216
	if(y > sy + sh)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1217
		y = sh - h - 2 * c->bw;
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1218
	if(x + w + 2 * c->bw < sx)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1219
		x = sx;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1220
	if(y + h + 2 * c->bw < sy)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1221
		y = sy;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1222
	if(c->x != x || c->y != y || c->w != w || c->h != h) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1223
		c->x = wc.x = x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1224
		c->y = wc.y = y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1225
		c->w = wc.width = w;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1226
		c->h = wc.height = h;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1227
		wc.border_width = c->bw;
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1228
		XConfigureWindow(dpy, c->win,
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1229
				CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1230
		configure(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1231
		XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1232
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1233
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1234
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1235
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1236
resizemouse(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1237
	int ocx, ocy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1238
	int nw, nh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1239
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1240
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1241
	ocx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1242
	ocy = c->y;
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1243
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1244
			None, cursor[CurResize], CurrentTime) != GrabSuccess)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1245
		return;
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1246
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1247
	for(;;) {
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1248
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask , &ev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1249
		switch(ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1250
		case ButtonRelease:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1251
			XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1252
					c->w + c->bw - 1, c->h + c->bw - 1);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1253
			XUngrabPointer(dpy, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1254
			while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1255
			return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1256
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1257
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1258
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1259
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1260
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1261
		case MotionNotify:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1262
			XSync(dpy, False);
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1263
			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1264
			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1265
			if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) {
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1266
				c->fx = c->x;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1267
				c->fy = c->y;
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
  1268
				togglefloating(NULL);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1269
			}
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1270
			if((lt->isfloating) || c->isfloating) {
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
  1271
				resize(c, c->x, c->y, nw, nh, True);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1272
				c->fw = nw;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1273
				c->fh = nh;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1274
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1275
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1276
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1277
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1278
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1279
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1280
void
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1281
restack(void) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1282
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1283
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1284
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1285
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1286
	drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1287
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1288
		return;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1289
	if(sel->isfloating || lt->isfloating)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1290
		XRaiseWindow(dpy, sel->win);
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1291
	if(!lt->isfloating) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1292
		wc.stack_mode = Below;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1293
		wc.sibling = barwin;
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1294
		for(c = stack; c; c = c->snext)
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1295
			if(!c->isfloating && isvisible(c)) {
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1296
				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1297
				wc.sibling = c->win;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1298
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1299
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1300
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1301
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1302
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1303
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1304
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1305
run(void) {
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1306
	char *p;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1307
	char sbuf[sizeof stext];
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1308
	fd_set rd;
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1309
	int r, xfd;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1310
	unsigned int len, offset;
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1311
	XEvent ev;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1312
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1313
	/* main event loop, also reads status text from stdin */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1314
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1315
	xfd = ConnectionNumber(dpy);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1316
	readin = True;
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1317
	offset = 0;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1318
	len = sizeof stext - 1;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1319
	sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1320
	while(running) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1321
		FD_ZERO(&rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1322
		if(readin)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1323
			FD_SET(STDIN_FILENO, &rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1324
		FD_SET(xfd, &rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1325
		if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1326
			if(errno == EINTR)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1327
				continue;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1328
			eprint("select failed\n");
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1329
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1330
		if(FD_ISSET(STDIN_FILENO, &rd)) {
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1331
			switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) {
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1332
			case -1:
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1333
				strncpy(stext, strerror(errno), len);
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1334
				readin = False;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1335
				break;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1336
			case 0:
1053
9990c1b25ceb simplified
Anselm R. Garbe <garbeam@gmail.com>
parents: 1052
diff changeset
  1337
				strncpy(stext, "EOF", 4);
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1338
				readin = False;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1339
				break;
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1340
			default:
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1341
				for(p = sbuf + offset; r > 0; p++, r--, offset++)
1062
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1342
					if(*p == '\n' || *p == '\0') {
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1343
						*p = '\0';
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1344
						strncpy(stext, sbuf, len);
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1345
						p += r - 1; /* p is sbuf + offset + r - 1 */
1062
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1346
						for(r = 0; *(p - r) && *(p - r) != '\n'; r++);
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1347
						offset = r;
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1348
						if(r)
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1349
							memmove(sbuf, p - r + 1, r);
1062
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1350
						break;
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1351
					}
767e76426fda applied Ritesh's patch to stext handling with some minor modifications
Anselm R. Garbe <garbeam@gmail.com>
parents: 1061
diff changeset
  1352
				break;
1054
28813060c35f removed fgets usage, increment offset until a line is read, dwm will drop all lines read in one call, except the first!!! one (previously it preferred the last) - but the current approach is simplier and works better for general purpose in conjunction with the offset handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 1053
diff changeset
  1353
			}
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1354
			drawbar();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1355
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1356
		while(XPending(dpy)) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1357
			XNextEvent(dpy, &ev);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1358
			if(handler[ev.type])
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1359
				(handler[ev.type])(&ev); /* call handler */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1360
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1361
	}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1362
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1363
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1364
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1365
scan(void) {
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1366
	unsigned int i, num;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1367
	Window *wins, d1, d2;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1368
	XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1369
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1370
	wins = NULL;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1371
	if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1372
		for(i = 0; i < num; i++) {
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1373
			if(!XGetWindowAttributes(dpy, wins[i], &wa)
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1374
					|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1375
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1376
			if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1377
				manage(wins[i], &wa);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1378
		}
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1379
		for(i = 0; i < num; i++) { /* now the transients */
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1380
			if(!XGetWindowAttributes(dpy, wins[i], &wa))
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1381
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1382
			if(XGetTransientForHint(dpy, wins[i], &d1)
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1383
					&& (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1384
				manage(wins[i], &wa);
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1385
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1386
	}
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1387
	if(wins)
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1388
		XFree(wins);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1389
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1390
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1391
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1392
setclientstate(Client *c, long state) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1393
	long data[] = {state, None};
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1394
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1395
	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1396
			PropModeReplace, (unsigned char *)data, 2);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1397
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1398
1148
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1399
void
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1400
setgeom(const char *arg) {
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1401
	unsigned int i;
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1402
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1403
	if(!arg) {
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1404
		if(++geom == &geoms[LENGTH(geoms)])
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1405
			geom = &geoms[0];
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1406
	}
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1407
	else {
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1408
		for(i = 0; i < LENGTH(geoms); i++)
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1409
			if(!strcmp(geoms[i].symbol, arg))
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1410
				break;
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1411
		if(i == LENGTH(geoms))
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1412
			return;
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1413
		geom = &geoms[i];
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1414
	}
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1415
	geom->apply();
1148
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1416
	updatebarpos();
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1417
	arrange();
1135
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1418
}
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1419
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1420
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1421
setlayout(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1422
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1423
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1424
	if(!arg) {
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1425
		if(++lt == &layouts[LENGTH(layouts)])
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1426
			lt = &layouts[0];
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1427
	}
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1428
	else {
1159
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1429
		for(i = 0; i < LENGTH(layouts); i++)
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1430
			if(!strcmp(arg, layouts[i].symbol))
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1431
				break;
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1432
		if(i == LENGTH(layouts))
34c88d74dff0 setlayout and setgeom are now togglable again
Anselm R Garbe <garbeam@gmail.com>
parents: 1158
diff changeset
  1433
			return;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1434
		lt = &layouts[i];
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1435
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1436
	if(sel)
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1437
		arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1438
	else
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1439
		drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1440
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1441
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1442
void
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1443
setmfact(const char *arg) {
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1444
	double d;
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1445
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1446
	if(lt->isfloating)
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1447
		return;
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1448
	if(!arg)
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1449
		mfact = MFACT;
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1450
	else {
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1451
		d = strtod(arg, NULL);
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1452
		if(arg[0] == '-' || arg[0] == '+')
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1453
			d += mfact;
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1454
		if(d < 0.1 || d > 0.9)
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1455
			return;
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1456
		mfact = d;
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1457
	}
1161
008ed7ecf563 minor fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1160
diff changeset
  1458
	setgeom(geom->symbol);
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1459
}
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1460
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1461
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1462
setup(void) {
1156
987c8d5c0bf8 blw/bgw calculation bugfix
anselm@anselm1
parents: 1155
diff changeset
  1463
	unsigned int i, w;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1464
	XSetWindowAttributes wa;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1465
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1466
	/* init screen */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1467
	screen = DefaultScreen(dpy);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1468
	root = RootWindow(dpy, screen);
1135
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1469
	initfont(FONT);
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1470
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1471
	/* apply default geometry */
1148
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1472
	sx = 0;
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1473
	sy = 0;
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1474
	sw = DisplayWidth(dpy, screen);
d49ff154375f some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Anselm R Garbe <garbeam@gmail.com>
parents: 1147
diff changeset
  1475
	sh = DisplayHeight(dpy, screen);
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1476
	bh = dc.font.height + 2;
1166
bf38679903b3 applied Peter Hartlich's simplification patch of setmfact and his revival of MFACT, appliead Janness Hofmann's simplification of grabbuttons() -- thanks guys!
anselm@anselm1
parents: 1165
diff changeset
  1477
	mfact = MFACT;
1150
40b2b183073b removed the string-based setgeom approach, introduced a new Geom type instead and a helper macro
Anselm R Garbe <garbeam@gmail.com>
parents: 1149
diff changeset
  1478
	geom->apply();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1479
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1480
	/* init atoms */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1481
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1482
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1483
	wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1484
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1485
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1486
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1487
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1488
	/* init cursors */
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1489
	wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1490
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1491
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1492
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1493
	/* init appearance */
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1494
	dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1495
	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1496
	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1497
	dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1498
	dc.sel[ColBG] = getcolor(SELBGCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1499
	dc.sel[ColFG] = getcolor(SELFGCOLOR);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1500
	initfont(FONT);
1135
a3be6b8a792d removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms
Anselm R Garbe <garbeam@gmail.com>
parents: 1134
diff changeset
  1501
	dc.h = bh;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1502
	dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1503
	dc.gc = XCreateGC(dpy, root, 0, 0);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1504
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1505
	if(!dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1506
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1507
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1508
	/* init tags */
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1509
	tagset[0] = emallocz(TAGSZ);
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1510
	tagset[1] = emallocz(TAGSZ);
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1511
	tagset[0][0] = tagset[1][0] = True;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1512
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1513
	/* init bar */
1158
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
  1514
	for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
1156
987c8d5c0bf8 blw/bgw calculation bugfix
anselm@anselm1
parents: 1155
diff changeset
  1515
		w = textw(layouts[i].symbol);
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1516
		blw = MAX(blw, w);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1517
	}
1158
7c40610de8df geom indicator and layout indicator is only displayed if there are several geoms/layouts
Anselm R Garbe <garbeam@gmail.com>
parents: 1157
diff changeset
  1518
	for(bgw = i = 0; LENGTH(geoms) > 1 && i < LENGTH(geoms); i++) {
1156
987c8d5c0bf8 blw/bgw calculation bugfix
anselm@anselm1
parents: 1155
diff changeset
  1519
		w = textw(geoms[i].symbol);
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1520
		bgw = MAX(bgw, w);
1151
8b2bff54fd0f geoms are now drawed in the status bar
Anselm R Garbe <garbeam@gmail.com>
parents: 1150
diff changeset
  1521
	}
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1522
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1523
	wa.override_redirect = 1;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1524
	wa.background_pixmap = ParentRelative;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1525
	wa.event_mask = ButtonPressMask|ExposureMask;
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1526
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1527
	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1528
				CopyFromParent, DefaultVisual(dpy, screen),
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1529
				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1530
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1531
	XMapRaised(dpy, barwin);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1532
	strcpy(stext, "dwm-"VERSION);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1533
	drawbar();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1534
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1535
	/* EWMH support per view */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1536
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1537
			PropModeReplace, (unsigned char *) netatom, NetLast);
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1538
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1539
	/* select for events */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1540
	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1541
			|EnterWindowMask|LeaveWindowMask|StructureNotifyMask;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1542
	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1543
	XSelectInput(dpy, root, wa.event_mask);
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1544
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
  1545
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1546
	/* grab keys */
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1547
	grabkeys();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1548
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1549
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1550
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1551
spawn(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1552
	static char *shell = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1553
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1554
	if(!shell && !(shell = getenv("SHELL")))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1555
		shell = "/bin/sh";
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1556
	if(!arg)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1557
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1558
	/* The double-fork construct avoids zombie processes and keeps the code
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1559
	 * clean from stupid signal handlers. */
1058
5e34476a3a1c we check variable == value, and not the other way - the other way is for beginner programmers.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1057
diff changeset
  1560
	if(fork() == 0) {
5e34476a3a1c we check variable == value, and not the other way - the other way is for beginner programmers.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1057
diff changeset
  1561
		if(fork() == 0) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1562
			if(dpy)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1563
				close(ConnectionNumber(dpy));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1564
			setsid();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1565
			execl(shell, shell, "-c", arg, (char *)NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1566
			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1567
			perror(" failed");
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1568
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1569
		exit(0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1570
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1571
	wait(0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1572
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1573
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1574
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1575
tag(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1576
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1577
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1578
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1579
		return;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1580
	for(i = 0; i < LENGTH(tags); i++)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1581
		sel->tags[i] = (NULL == arg);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1582
	sel->tags[idxoftag(arg)] = True;
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1583
	arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1584
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1585
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1586
unsigned int
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1587
textnw(const char *text, unsigned int len) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1588
	XRectangle r;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1589
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1590
	if(dc.font.set) {
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1591
		XmbTextExtents(dc.font.set, text, len, NULL, &r);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1592
		return r.width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1593
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1594
	return XTextWidth(dc.font.xfont, text, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1595
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1596
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1597
unsigned int
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1598
textw(const char *text) {
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1599
	return textnw(text, strlen(text)) + dc.font.height;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1600
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1601
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1602
void
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1603
tileh(void) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1604
	int x, w;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1605
	unsigned int i, n = counttiled();
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1606
	Client *c;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1607
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1608
	if(n == 0)
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1609
		return;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1610
	c = tilemaster(n);
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1611
	if(--n == 0)
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1612
		return;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1613
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1614
	x = tx;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1615
	w = tw / n;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1616
	if(w < bh)
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1617
		w = tw;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1618
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1619
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1620
		if(i + 1 == n) /* remainder */
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1621
			tileresize(c, x, ty, (tx + tw) - x - 2 * c->bw, th - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1622
		else
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1623
			tileresize(c, x, ty, w - 2 * c->bw, th - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1624
		if(w != tw)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1625
			x = c->x + c->w + 2 * c->bw;
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1626
	}
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1627
}
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1628
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1629
Client *
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1630
tilemaster(unsigned int n) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1631
	Client *c = nexttiled(clients);
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1632
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1633
	if(n == 1)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1634
		tileresize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1635
	else
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1636
		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1637
	return c;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1638
}
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1639
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1640
void
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1641
tileresize(Client *c, int x, int y, int w, int h) {
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1642
	resize(c, x, y, w, h, RESIZEHINTS);
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1643
	if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1644
		/* client doesn't accept size constraints */
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1645
		resize(c, x, y, w, h, False);
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1646
}
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1647
1130
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
  1648
void
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1649
tilev(void) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1650
	int y, h;
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1651
	unsigned int i, n = counttiled();
1130
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
  1652
	Client *c;
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
  1653
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
  1654
	if(n == 0)
b661ad410646 new stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1129
diff changeset
  1655
		return;
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1656
	c = tilemaster(n);
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1657
	if(--n == 0)
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1658
		return;
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1659
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1660
	y = ty;
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1661
	h = th / n;
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1662
	if(h < bh)
1132
a1c28da5bc91 added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
anselm@anselm1
parents: 1130
diff changeset
  1663
		h = th;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1664
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1665
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1666
		if(i + 1 == n) /* remainder */
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1667
			tileresize(c, tx, y, tw - 2 * c->bw, (ty + th) - y - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1668
		else
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1669
			tileresize(c, tx, y, tw - 2 * c->bw, h - 2 * c->bw);
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1670
		if(h != th)
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1671
			y = c->y + c->h + 2 * c->bw;
1144
20faf6b62b7f some polishing in tileh/tilev
Anselm R Garbe <garbeam@gmail.com>
parents: 1143
diff changeset
  1672
	}
1129
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1673
}
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1674
43d862bda73e implemented setlayout in the way proposed on the ml, split tile() into two functions, a third will follow soon
Anselm R Garbe <garbeam@gmail.com>
parents: 1128
diff changeset
  1675
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1676
togglefloating(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1677
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1678
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1679
	sel->isfloating = !sel->isfloating;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1680
	if(sel->isfloating)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1681
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1682
	arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1683
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1684
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1685
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1686
toggletag(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1687
	unsigned int i, j;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1688
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1689
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1690
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1691
	i = idxoftag(arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1692
	sel->tags[i] = !sel->tags[i];
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1693
	for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1694
	if(j == LENGTH(tags))
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
  1695
		sel->tags[i] = True; /* at least one tag must be enabled */
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1696
	arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1697
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1698
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1699
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1700
toggleview(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1701
	unsigned int i, j;
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
  1702
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1703
	i = idxoftag(arg);
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1704
	tagset[seltags][i] = !tagset[seltags][i];
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1705
	for(j = 0; j < LENGTH(tags) && !tagset[seltags][j]; j++);
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1706
	if(j == LENGTH(tags))
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1707
		tagset[seltags][i] = True; /* at least one tag must be viewed */
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1708
	arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1709
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1710
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1711
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1712
unban(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1713
	if(!c->isbanned)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1714
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1715
	XMoveWindow(dpy, c->win, c->x, c->y);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1716
	c->isbanned = False;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1717
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1718
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1719
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1720
unmanage(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1721
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1722
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1723
	wc.border_width = c->oldbw;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1724
	/* The server grab construct avoids race conditions. */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1725
	XGrabServer(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1726
	XSetErrorHandler(xerrordummy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1727
	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1728
	detach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1729
	detachstack(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1730
	if(sel == c)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1731
		focus(NULL);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1732
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1733
	setclientstate(c, WithdrawnState);
1027
0735e86bbd49 added antoszka's viewprev patch with some minor modifications, restored Client->tags as Bool *, however kept the static initialization of ntags and seltags (prevtags) - this seems to be the best compromise
Anselm R. Garbe <garbeam@gmail.com>
parents: 1026
diff changeset
  1734
	free(c->tags);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1735
	free(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1736
	XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1737
	XSetErrorHandler(xerror);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1738
	XUngrabServer(dpy);
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1739
	arrange();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1740
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1741
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1742
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1743
unmapnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1744
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1745
	XUnmapEvent *ev = &e->xunmap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1746
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1747
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1748
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1749
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1750
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1751
void
1136
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1752
updatebarpos(void) {
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1753
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1754
	if(dc.drawable != 0)
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1755
		XFreePixmap(dpy, dc.drawable);
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1756
	dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen));
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1757
	XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1758
}
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1759
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1760
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1761
updatesizehints(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1762
	long msize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1763
	XSizeHints size;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1764
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1765
	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1766
		size.flags = PSize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1767
	c->flags = size.flags;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1768
	if(c->flags & PBaseSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1769
		c->basew = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1770
		c->baseh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1771
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1772
	else if(c->flags & PMinSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1773
		c->basew = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1774
		c->baseh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1775
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1776
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1777
		c->basew = c->baseh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1778
	if(c->flags & PResizeInc) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1779
		c->incw = size.width_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1780
		c->inch = size.height_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1781
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1782
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1783
		c->incw = c->inch = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1784
	if(c->flags & PMaxSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1785
		c->maxw = size.max_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1786
		c->maxh = size.max_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1787
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1788
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1789
		c->maxw = c->maxh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1790
	if(c->flags & PMinSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1791
		c->minw = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1792
		c->minh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1793
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1794
	else if(c->flags & PBaseSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1795
		c->minw = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1796
		c->minh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1797
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1798
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1799
		c->minw = c->minh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1800
	if(c->flags & PAspect) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1801
		c->minax = size.min_aspect.x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1802
		c->maxax = size.max_aspect.x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1803
		c->minay = size.min_aspect.y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1804
		c->maxay = size.max_aspect.y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1805
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1806
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1807
		c->minax = c->maxax = c->minay = c->maxay = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1808
	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1809
			&& c->maxw == c->minw && c->maxh == c->minh);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1810
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1811
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1812
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1813
updatetitle(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1814
	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1815
		gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1816
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1817
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1818
void
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1819
updatewmhints(Client *c) {
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1820
	XWMHints *wmh;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1821
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1822
	if((wmh = XGetWMHints(dpy, c->win))) {
1122
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1823
		if(c == sel)
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1824
			sel->isurgent = False;
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1825
		else
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1826
			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1827
		XFree(wmh);
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1828
	}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1829
}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1830
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1831
void
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1832
view(const char *arg) {
1185
e6b4b21680be simplification of view() as proposed by anydot
Anselm R Garbe <garbeam@gmail.com>
parents: 1184
diff changeset
  1833
	seltags ^= 1;
e6b4b21680be simplification of view() as proposed by anydot
Anselm R Garbe <garbeam@gmail.com>
parents: 1184
diff changeset
  1834
	memset(tagset[seltags], (NULL == arg), TAGSZ);
e6b4b21680be simplification of view() as proposed by anydot
Anselm R Garbe <garbeam@gmail.com>
parents: 1184
diff changeset
  1835
	tagset[seltags][idxoftag(arg)] = True;
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1836
	arrange();
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1837
}
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1838
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1839
void
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1840
viewprevtag(const char *arg) {
1184
bf63402f3b33 applied yiyus tagset patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1183
diff changeset
  1841
	seltags ^= 1; /* toggle sel tagset */
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1842
	arrange();
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1843
}
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1844
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1845
/* There's no way to check accesses to destroyed windows, thus those cases are
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1846
 * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1847
 * default error handler, which may call exit.  */
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1848
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1849
xerror(Display *dpy, XErrorEvent *ee) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1850
	if(ee->error_code == BadWindow
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1851
	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1852
	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1853
	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1854
	|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1855
	|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
1186
48ffaf800504 applied JUCE patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1185
diff changeset
  1856
	|| (ee->request_code == X_GrabButton && ee->error_code == BadAccess)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1857
	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1858
	|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1859
		return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1860
	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1861
		ee->request_code, ee->error_code);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1862
	return xerrorxlib(dpy, ee); /* may call exit */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1863
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1864
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1865
int
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1866
xerrordummy(Display *dpy, XErrorEvent *ee) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1867
	return 0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1868
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1869
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1870
/* Startup Error handler to check if another window manager
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1871
 * is already running. */
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1872
int
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1873
xerrorstart(Display *dpy, XErrorEvent *ee) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1874
	otherwm = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1875
	return -1;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1876
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1877
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1878
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1879
zoom(const char *arg) {
1091
908feb1da3c4 applied Jukka's zoom-patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1090
diff changeset
  1880
	Client *c = sel;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1881
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1882
	if(c == nexttiled(clients))
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1883
		if(!c || !(c = nexttiled(c->next)))
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1884
			return;
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1885
	if(!lt->isfloating && !sel->isfloating) {
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1886
		detach(c);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1887
		attach(c);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1888
		focus(c);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1889
	}
1102
239f5ee65766 pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but those changes are necessary to get a decent multihead support) -- I renamed Monitor into View, to reflect in a better way the dwm terminology of the past
anselm@anselm1
parents: 1101
diff changeset
  1890
	arrange();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1891
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1892
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
  1893
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1894
main(int argc, char *argv[]) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1895
	if(argc == 2 && !strcmp("-v", argv[1]))
1099
5b4e2e1aba85 added Gottox to Copyright holders after all his contributions, applied his last patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1098
diff changeset
  1896
		eprint("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1897
	else if(argc != 1)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1898
		eprint("usage: dwm [-v]\n");
994
201550f99b8e macros which have been defined in config.h can only be used at function level, however you can nest code into config.h now for implementing a different layout (just for example), eg. #include "supertile.c"
Anselm R. Garbe <garbeam@gmail.com>
parents: 993
diff changeset
  1899
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1900
	setlocale(LC_CTYPE, "");
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1901
	if(!(dpy = XOpenDisplay(0)))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1902
		eprint("dwm: cannot open display\n");
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1903
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1904
	checkotherwm();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1905
	setup();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1906
	scan();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1907
	run();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1908
	cleanup();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1909
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1910
	XCloseDisplay(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1911
	return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1912
}
1177
22d8c2fb999f applied Ph's patch regarding geom and lt initialization
anselm@anselm1
parents: 1176
diff changeset
  1913