dwm.c
author Anselm R. Garbe <garbeam@gmail.com>
Sun, 04 Nov 2007 17:49:56 +0100
changeset 1058 5e34476a3a1c
parent 1057 022da3fca625
child 1059 98d06be63ce5
permissions -rw-r--r--
we check variable == value, and not the other way - the other way is for beginner programmers.
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
1057
022da3fca625 removed a misleading comment about client title windows, which don't exist anymore
Anselm R. Garbe <garbeam@gmail.com>
parents: 1056
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>
1014
35461e0a4894 fixed inclusion order
arg@suckless.org
parents: 1008
diff changeset
    36
#include <regex.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    37
#include <X11/cursorfont.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    38
#include <X11/keysym.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    39
#include <X11/Xatom.h>
1033
a8efbb301ef4 just making dwm.h saner
arg@suckless.org
parents: 1032
diff changeset
    40
#include <X11/Xlib.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    41
#include <X11/Xproto.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    42
#include <X11/Xutil.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    43
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    44
/* macros */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    45
#define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    46
#define CLEANMASK(mask)		(mask & ~(numlockmask | LockMask))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    47
#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    48
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
    49
/* 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
    50
enum { BarTop, BarBot, BarOff };			/* bar position */
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
    51
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
    52
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
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
    53
enum { NetSupported, NetWMName, NetLast };		/* EWMH 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
    54
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
    55
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
    56
/* 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
    57
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
    58
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
    59
	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
    60
	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
    61
	int rx, ry, rw, rh; /* revert geometry */
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
	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
    63
	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
    64
	long flags;
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
	unsigned int border, oldborder;
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
	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
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
	Bool *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
    68
	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
    69
	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
    70
	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
    71
	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
    72
};
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
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
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
    75
	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
    76
	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
    77
	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
    78
	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
    79
	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
    80
	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
    81
		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
    82
		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
    83
		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
    84
		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
    85
		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
    86
	} 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
    87
} 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
    88
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
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
    90
	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
    91
	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
    92
	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
    93
	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
    94
} 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
    95
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
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
    97
	const char *symbol;
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
	void (*arrange)(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
    99
} Layout;
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
   100
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
   101
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
   102
	const char *prop;
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
   103
	const char *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
   104
	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
   105
} 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
   106
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
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
   108
	regex_t *propregex;
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
	regex_t *tagregex;
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
} Regs;
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
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   112
/* 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
   113
void applyrules(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
   114
void arrange(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
   115
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
   116
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
   117
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
   118
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
   119
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
   120
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
   121
void compileregs(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
   122
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
   123
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
   124
void configurerequest(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
   125
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
   126
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
   127
void detachstack(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
   128
void drawbar(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
   129
void drawsquare(Bool filled, Bool empty, unsigned long col[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
   130
void drawtext(const char *text, unsigned long col[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
   131
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
   132
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
   133
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
   134
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
   135
void floating(void); /* default floating layout */
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 focus(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
   137
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
   138
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
   139
Client *getclient(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
   140
unsigned long getcolor(const char *colstr);
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
   141
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
   142
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
   143
void grabbuttons(Client *c, Bool focused);
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
unsigned int idxoftag(const char *tag);
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 initfont(const char *fontstr);
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
Bool isoccupied(unsigned int t);
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
Bool isprotodel(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
   148
Bool isvisible(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
   149
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
   150
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
   151
void leavenotify(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
   152
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
   153
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
   154
void maprequest(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
   155
void movemouse(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
   156
Client *nexttiled(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
   157
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
   158
void quit(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
   159
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
   160
void resizemouse(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
   161
void restack(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
   162
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
   163
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
   164
void setclientstate(Client *c, long state);
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 setlayout(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 setmwfact(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
   167
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
   168
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
   169
void tag(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
   170
unsigned int textnw(const char *text, unsigned int len);
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
   171
unsigned int textw(const char *text);
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 tile(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
   173
void togglebar(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
   174
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
   175
void togglemax(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
   176
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
   177
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
   178
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
   179
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
   180
void unmapnotify(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
   181
void updatebarpos(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
   182
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
   183
void updatetitle(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
   184
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
   185
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
   186
int xerror(Display *dpy, XErrorEvent *ee);
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
   187
int xerrordummy(Display *dsply, XErrorEvent *ee);
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
   188
int xerrorstart(Display *dsply, XErrorEvent *ee);
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
   189
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
   190
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
   191
/* 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
   192
char stext[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
   193
double mwfact;
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
   194
int screen, sx, sy, sw, sh, wax, way, waw, wah;
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
int (*xerrorxlib)(Display *, XErrorEvent *);
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
unsigned int bh, bpos;
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
unsigned int blw = 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
   198
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
   199
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
   200
	[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
   201
	[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
   202
	[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
   203
	[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
   204
	[EnterNotify] = enternotify,
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
	[LeaveNotify] = leavenotify,
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
	[Expose] = expose,
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
	[KeyPress] = keypress,
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
   208
	[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
   209
	[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
   210
	[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
   211
	[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
   212
};
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
   213
Atom wmatom[WMLast], netatom[NetLast];
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   214
Bool domwfact = True;
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   215
Bool dozoom = True;
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
   216
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
   217
Bool running = True;
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
   218
Bool selscreen = True;
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
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
   220
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
   221
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
   222
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
   223
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
   224
DC dc = {0};
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   225
Layout *layout = NULL;
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
   226
Window barwin, root;
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
   227
Regs *regs = 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
   228
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
/* 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
   230
#include "config.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
   231
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   232
/* function implementations */
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
   233
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   234
applyrules(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   235
	static char buf[512];
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   236
	unsigned int i, j;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   237
	regmatch_t tmp;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   238
	Bool matched = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   239
	XClassHint ch = { 0 };
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   240
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   241
	/* rule matching */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   242
	XGetClassHint(dpy, c->win, &ch);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   243
	snprintf(buf, sizeof buf, "%s:%s:%s",
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   244
			ch.res_class ? ch.res_class : "",
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   245
			ch.res_name ? ch.res_name : "", c->name);
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   246
	for(i = 0; i < LENGTH(rules); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   247
		if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   248
			c->isfloating = rules[i].isfloating;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   249
			for(j = 0; regs[i].tagregex && j < LENGTH(tags); j++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   250
				if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   251
					matched = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   252
					c->tags[j] = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   253
				}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   254
			}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   255
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   256
	if(ch.res_class)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   257
		XFree(ch.res_class);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   258
	if(ch.res_name)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   259
		XFree(ch.res_name);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   260
	if(!matched)
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
   261
		memcpy(c->tags, seltags, sizeof seltags);
996
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
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
   264
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   265
arrange(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   266
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   267
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   268
	for(c = clients; c; c = c->next)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   269
		if(isvisible(c))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   270
			unban(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   271
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   272
			ban(c);
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   273
	layout->arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   274
	focus(NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   275
	restack();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   276
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   277
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
   278
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   279
attach(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   280
	if(clients)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   281
		clients->prev = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   282
	c->next = clients;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   283
	clients = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   284
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   285
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
   286
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   287
attachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   288
	c->snext = stack;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   289
	stack = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   290
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   291
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
   292
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   293
ban(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   294
	if(c->isbanned)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   295
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   296
	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   297
	c->isbanned = True;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   298
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   299
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
   300
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   301
buttonpress(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   302
	unsigned int i, x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   303
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   304
	XButtonPressedEvent *ev = &e->xbutton;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   305
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
   306
	if(ev->window == barwin) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   307
		x = 0;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   308
		for(i = 0; i < LENGTH(tags); i++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   309
			x += textw(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   310
			if(ev->x < x) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   311
				if(ev->button == Button1) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   312
					if(ev->state & MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   313
						tag(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   314
					else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   315
						view(tags[i]);
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
				else if(ev->button == Button3) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   318
					if(ev->state & MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   319
						toggletag(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   320
					else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   321
						toggleview(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   322
				}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   323
				return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   324
			}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   325
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   326
		if((ev->x < x + blw) && ev->button == Button1)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   327
			setlayout(NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   328
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   329
	else if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   330
		focus(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   331
		if(CLEANMASK(ev->state) != MODKEY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   332
			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
   333
		if(ev->button == Button1) {
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
   334
			if((layout->arrange == floating) || c->isfloating)
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   335
				restack();
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   336
			else
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
   337
				togglefloating(NULL);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   338
			movemouse(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   339
		}
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
   340
		else if(ev->button == Button2) {
1049
a2dae7badb92 sanders patch for b2 toggle
arg@suckless.org
parents: 1048
diff changeset
   341
			if((floating != layout->arrange) && 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
   342
				togglefloating(NULL);
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
   343
			else
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
   344
				zoom(NULL);
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
   345
		}
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
   346
		else if(ev->button == Button3 && !c->isfixed) {
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   347
			if((floating == layout->arrange) || c->isfloating)
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   348
				restack();
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   349
			else
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
   350
				togglefloating(NULL);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   351
			resizemouse(c);
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
	}
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
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
   356
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   357
checkotherwm(void) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   358
	otherwm = False;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   359
	XSetErrorHandler(xerrorstart);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   360
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   361
	/* this causes an error if some other window manager is running */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   362
	XSelectInput(dpy, root, SubstructureRedirectMask);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   363
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   364
	if(otherwm)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   365
		eprint("dwm: another window manager is already running\n");
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   366
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   367
	XSetErrorHandler(NULL);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   368
	xerrorxlib = XSetErrorHandler(xerror);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   369
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   370
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   371
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
   372
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   373
cleanup(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   374
	close(STDIN_FILENO);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   375
	while(stack) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   376
		unban(stack);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   377
		unmanage(stack);
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
	if(dc.font.set)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   380
		XFreeFontSet(dpy, dc.font.set);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   381
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   382
		XFreeFont(dpy, dc.font.xfont);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   383
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   384
	XFreePixmap(dpy, dc.drawable);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   385
	XFreeGC(dpy, dc.gc);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   386
	XDestroyWindow(dpy, barwin);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   387
	XFreeCursor(dpy, cursor[CurNormal]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   388
	XFreeCursor(dpy, cursor[CurResize]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   389
	XFreeCursor(dpy, cursor[CurMove]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   390
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   391
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   392
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   393
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
   394
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   395
compileregs(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   396
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   397
	regex_t *reg;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   398
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   399
	if(regs)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   400
		return;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   401
	regs = emallocz(LENGTH(rules) * sizeof(Regs));
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   402
	for(i = 0; i < LENGTH(rules); i++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   403
		if(rules[i].prop) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   404
			reg = emallocz(sizeof(regex_t));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   405
			if(regcomp(reg, rules[i].prop, REG_EXTENDED))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   406
				free(reg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   407
			else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   408
				regs[i].propregex = reg;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   409
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   410
		if(rules[i].tags) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   411
			reg = emallocz(sizeof(regex_t));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   412
			if(regcomp(reg, rules[i].tags, REG_EXTENDED))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   413
				free(reg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   414
			else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   415
				regs[i].tagregex = reg;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   416
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   417
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   418
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   419
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
   420
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   421
configure(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   422
	XConfigureEvent ce;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   423
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   424
	ce.type = ConfigureNotify;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   425
	ce.display = dpy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   426
	ce.event = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   427
	ce.window = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   428
	ce.x = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   429
	ce.y = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   430
	ce.width = c->w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   431
	ce.height = c->h;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   432
	ce.border_width = c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   433
	ce.above = None;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   434
	ce.override_redirect = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   435
	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   436
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   437
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
   438
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   439
configurenotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   440
	XConfigureEvent *ev = &e->xconfigure;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   441
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   442
	if(ev->window == root && (ev->width != sw || ev->height != sh)) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   443
		sw = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   444
		sh = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   445
		XFreePixmap(dpy, dc.drawable);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   446
		dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   447
		XResizeWindow(dpy, barwin, sw, bh);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   448
		updatebarpos();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   449
		arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   450
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   451
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   452
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
   453
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   454
configurerequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   455
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   456
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   457
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   458
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   459
	if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   460
		c->ismax = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   461
		if(ev->value_mask & CWBorderWidth)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   462
			c->border = ev->border_width;
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   463
		if(c->isfixed || c->isfloating || (floating == layout->arrange)) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   464
			if(ev->value_mask & CWX)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   465
				c->x = ev->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   466
			if(ev->value_mask & CWY)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   467
				c->y = ev->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   468
			if(ev->value_mask & CWWidth)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   469
				c->w = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   470
			if(ev->value_mask & CWHeight)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   471
				c->h = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   472
			if((c->x + c->w) > sw && c->isfloating)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   473
				c->x = sw / 2 - c->w / 2; /* center in x direction */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   474
			if((c->y + c->h) > sh && c->isfloating)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   475
				c->y = sh / 2 - c->h / 2; /* center in y direction */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   476
			if((ev->value_mask & (CWX | CWY))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   477
			&& !(ev->value_mask & (CWWidth | CWHeight)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   478
				configure(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   479
			if(isvisible(c))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   480
				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
   481
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   482
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   483
			configure(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   484
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   485
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   486
		wc.x = ev->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   487
		wc.y = ev->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   488
		wc.width = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   489
		wc.height = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   490
		wc.border_width = ev->border_width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   491
		wc.sibling = ev->above;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   492
		wc.stack_mode = ev->detail;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   493
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   494
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   495
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   496
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   497
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
   498
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   499
destroynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   500
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   501
	XDestroyWindowEvent *ev = &e->xdestroywindow;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   502
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   503
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   504
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   505
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   506
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
   507
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   508
detach(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   509
	if(c->prev)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   510
		c->prev->next = c->next;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   511
	if(c->next)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   512
		c->next->prev = c->prev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   513
	if(c == clients)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   514
		clients = c->next;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   515
	c->next = c->prev = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   516
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   517
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
   518
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   519
detachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   520
	Client **tc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   521
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   522
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   523
	*tc = c->snext;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   524
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   525
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
   526
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   527
drawbar(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   528
	int i, x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   529
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   530
	dc.x = dc.y = 0;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   531
	for(i = 0; i < LENGTH(tags); i++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   532
		dc.w = textw(tags[i]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   533
		if(seltags[i]) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   534
			drawtext(tags[i], dc.sel);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   535
			drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   536
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   537
		else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   538
			drawtext(tags[i], dc.norm);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   539
			drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   540
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   541
		dc.x += dc.w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   542
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   543
	dc.w = blw;
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   544
	drawtext(layout->symbol, dc.norm);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   545
	x = dc.x + dc.w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   546
	dc.w = textw(stext);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   547
	dc.x = sw - dc.w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   548
	if(dc.x < x) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   549
		dc.x = x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   550
		dc.w = sw - x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   551
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   552
	drawtext(stext, dc.norm);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   553
	if((dc.w = dc.x - x) > bh) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   554
		dc.x = x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   555
		if(sel) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   556
			drawtext(sel->name, dc.sel);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   557
			drawsquare(sel->ismax, sel->isfloating, dc.sel);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   558
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   559
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   560
			drawtext(NULL, dc.norm);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   561
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   562
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   563
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   564
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   565
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
   566
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   567
drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   568
	int x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   569
	XGCValues gcv;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   570
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   571
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   572
	gcv.foreground = col[ColFG];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   573
	XChangeGC(dpy, dc.gc, GCForeground, &gcv);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   574
	x = (dc.font.ascent + dc.font.descent + 2) / 4;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   575
	r.x = dc.x + 1;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   576
	r.y = dc.y + 1;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   577
	if(filled) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   578
		r.width = r.height = x + 1;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   579
		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   580
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   581
	else if(empty) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   582
		r.width = r.height = x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   583
		XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   584
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   585
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   586
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
   587
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   588
drawtext(const char *text, unsigned long col[ColLast]) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   589
	int x, y, w, h;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   590
	static char buf[256];
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   591
	unsigned int len, olen;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   592
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   593
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   594
	XSetForeground(dpy, dc.gc, col[ColBG]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   595
	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   596
	if(!text)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   597
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   598
	w = 0;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   599
	olen = len = strlen(text);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   600
	if(len >= sizeof buf)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   601
		len = sizeof buf - 1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   602
	memcpy(buf, text, len);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   603
	buf[len] = 0;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   604
	h = dc.font.ascent + dc.font.descent;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   605
	y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   606
	x = dc.x + (h / 2);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   607
	/* shorten text if necessary */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   608
	while(len && (w = textnw(buf, len)) > dc.w - h)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   609
		buf[--len] = 0;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   610
	if(len < olen) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   611
		if(len > 1)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   612
			buf[len - 1] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   613
		if(len > 2)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   614
			buf[len - 2] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   615
		if(len > 3)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   616
			buf[len - 3] = '.';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   617
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   618
	if(w > dc.w)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   619
		return; /* too long */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   620
	XSetForeground(dpy, dc.gc, col[ColFG]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   621
	if(dc.font.set)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   622
		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   623
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   624
		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   625
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   626
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
   627
void *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   628
emallocz(unsigned int size) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   629
	void *res = calloc(1, size);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   630
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   631
	if(!res)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   632
		eprint("fatal: could not malloc() %u bytes\n", size);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   633
	return res;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   634
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   635
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
   636
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   637
enternotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   638
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   639
	XCrossingEvent *ev = &e->xcrossing;
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(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   642
		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
   643
	if((c = getclient(ev->window)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   644
		focus(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   645
	else if(ev->window == root) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   646
		selscreen = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   647
		focus(NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   648
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   649
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   650
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
   651
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   652
eprint(const char *errstr, ...) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   653
	va_list ap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   654
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   655
	va_start(ap, errstr);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   656
	vfprintf(stderr, errstr, ap);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   657
	va_end(ap);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   658
	exit(EXIT_FAILURE);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   659
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   660
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
   661
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   662
expose(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   663
	XExposeEvent *ev = &e->xexpose;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   664
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
   665
	if(ev->count == 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
   666
		if(ev->window == barwin)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   667
			drawbar();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   668
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   669
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   670
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
   671
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   672
floating(void) { /* default floating layout */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   673
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   674
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
   675
	domwfact = dozoom = False;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   676
	for(c = clients; c; c = c->next)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   677
		if(isvisible(c))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   678
			resize(c, c->x, c->y, c->w, c->h, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   679
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   680
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
   681
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   682
focus(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   683
	if((!c && selscreen) || (c && !isvisible(c)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   684
		for(c = stack; c && !isvisible(c); c = c->snext);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   685
	if(sel && sel != c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   686
		grabbuttons(sel, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   687
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   688
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   689
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   690
		detachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   691
		attachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   692
		grabbuttons(c, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   693
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   694
	sel = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   695
	drawbar();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   696
	if(!selscreen)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   697
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   698
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   699
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   700
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   701
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   702
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   703
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   704
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   705
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
   706
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   707
focusnext(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   708
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   709
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   710
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   711
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   712
	for(c = sel->next; c && !isvisible(c); c = c->next);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   713
	if(!c)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   714
		for(c = clients; c && !isvisible(c); c = c->next);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   715
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   716
		focus(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   717
		restack();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   718
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   719
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   720
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
   721
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   722
focusprev(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   723
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   724
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   725
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   726
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   727
	for(c = sel->prev; c && !isvisible(c); c = c->prev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   728
	if(!c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   729
		for(c = clients; c && c->next; c = c->next);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   730
		for(; c && !isvisible(c); c = c->prev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   731
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   732
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   733
		focus(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   734
		restack();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   735
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   736
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   737
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
   738
Client *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   739
getclient(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   740
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   741
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   742
	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
   743
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   744
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   745
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
   746
unsigned long
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   747
getcolor(const char *colstr) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   748
	Colormap cmap = DefaultColormap(dpy, screen);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   749
	XColor color;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   750
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   751
	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   752
		eprint("error, cannot allocate color '%s'\n", colstr);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   753
	return color.pixel;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   754
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   755
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
   756
long
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   757
getstate(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   758
	int format, status;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   759
	long result = -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   760
	unsigned char *p = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   761
	unsigned long n, extra;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   762
	Atom real;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   763
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   764
	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
   765
			&real, &format, &n, &extra, (unsigned char **)&p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   766
	if(status != Success)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   767
		return -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   768
	if(n != 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   769
		result = *p;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   770
	XFree(p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   771
	return result;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   772
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   773
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
   774
Bool
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   775
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
   776
	char **list = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   777
	int n;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   778
	XTextProperty name;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   779
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
   780
	if(!text || size == 0)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   781
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   782
	text[0] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   783
	XGetTextProperty(dpy, w, &name, atom);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   784
	if(!name.nitems)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   785
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   786
	if(name.encoding == XA_STRING)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   787
		strncpy(text, (char *)name.value, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   788
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   789
		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
   790
		&& n > 0 && *list) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   791
			strncpy(text, *list, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   792
			XFreeStringList(list);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   793
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   794
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   795
	text[size - 1] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   796
	XFree(name.value);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   797
	return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   798
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   799
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
   800
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   801
grabbuttons(Client *c, Bool focused) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   802
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   803
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   804
	if(focused) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   805
		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   806
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   807
		XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   808
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   809
		XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   810
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   811
		XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   812
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   813
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   814
		XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   815
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   816
		XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   817
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   818
		XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   819
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   820
		XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   821
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   822
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   823
		XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   824
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   825
		XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   826
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   827
		XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   828
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   829
		XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   830
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   831
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   832
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   833
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   834
				GrabModeAsync, GrabModeSync, None, None);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   835
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   836
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
   837
unsigned int
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   838
idxoftag(const char *tag) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   839
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   840
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   841
	for(i = 0; (i < LENGTH(tags)) && (tags[i] != tag); i++);
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   842
	return (i < LENGTH(tags)) ? i : 0;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   843
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   844
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
   845
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   846
initfont(const char *fontstr) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   847
	char *def, **missing;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   848
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   849
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   850
	missing = NULL;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   851
	if(dc.font.set)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   852
		XFreeFontSet(dpy, dc.font.set);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   853
	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   854
	if(missing) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   855
		while(n--)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   856
			fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   857
		XFreeStringList(missing);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   858
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   859
	if(dc.font.set) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   860
		XFontSetExtents *font_extents;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   861
		XFontStruct **xfonts;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   862
		char **font_names;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   863
		dc.font.ascent = dc.font.descent = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   864
		font_extents = XExtentsOfFontSet(dc.font.set);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   865
		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   866
		for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   867
			if(dc.font.ascent < (*xfonts)->ascent)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   868
				dc.font.ascent = (*xfonts)->ascent;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   869
			if(dc.font.descent < (*xfonts)->descent)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   870
				dc.font.descent = (*xfonts)->descent;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   871
			xfonts++;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   872
		}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   873
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   874
	else {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   875
		if(dc.font.xfont)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   876
			XFreeFont(dpy, dc.font.xfont);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   877
		dc.font.xfont = NULL;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   878
		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
   879
		&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   880
			eprint("error, cannot load font: '%s'\n", fontstr);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   881
		dc.font.ascent = dc.font.xfont->ascent;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   882
		dc.font.descent = dc.font.xfont->descent;
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
	dc.font.height = dc.font.ascent + dc.font.descent;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   885
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   886
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
   887
Bool
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   888
isoccupied(unsigned int t) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   889
	Client *c;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   890
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   891
	for(c = clients; c; c = c->next)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   892
		if(c->tags[t])
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   893
			return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   894
	return False;
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
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   898
isprotodel(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   899
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   900
	Atom *protocols;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   901
	Bool ret = False;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   902
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   903
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   904
		for(i = 0; !ret && i < n; i++)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   905
			if(protocols[i] == wmatom[WMDelete])
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   906
				ret = True;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   907
		XFree(protocols);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   908
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   909
	return ret;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   910
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   911
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
   912
Bool
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   913
isvisible(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   914
	unsigned int i;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   915
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   916
	for(i = 0; i < LENGTH(tags); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   917
		if(c->tags[i] && seltags[i])
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   918
			return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   919
	return False;
990
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
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   923
keypress(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   924
	KEYS
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   925
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   926
	KeyCode code;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   927
	KeySym keysym;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   928
	XKeyEvent *ev;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   929
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   930
	if(!e) { /* grabkeys */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   931
		XUngrabKey(dpy, AnyKey, AnyModifier, root);
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
   932
		for(i = 0; i < LENGTH(keys); i++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   933
			code = XKeysymToKeycode(dpy, keys[i].keysym);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   934
			XGrabKey(dpy, code, keys[i].mod, root, True,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   935
					GrabModeAsync, GrabModeAsync);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   936
			XGrabKey(dpy, code, keys[i].mod | LockMask, root, True,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   937
					GrabModeAsync, GrabModeAsync);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   938
			XGrabKey(dpy, code, keys[i].mod | numlockmask, root, True,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   939
					GrabModeAsync, GrabModeAsync);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   940
			XGrabKey(dpy, code, keys[i].mod | numlockmask | LockMask, root, True,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   941
					GrabModeAsync, GrabModeAsync);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   942
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   943
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   944
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   945
	ev = &e->xkey;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   946
	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
   947
	for(i = 0; i < LENGTH(keys); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   948
		if(keysym == keys[i].keysym
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   949
		&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   950
		{
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   951
			if(keys[i].func)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   952
				keys[i].func(keys[i].arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   953
		}
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   954
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   955
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
   956
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   957
killclient(const char *arg) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   958
	XEvent ev;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   959
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   960
	if(!sel)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   961
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   962
	if(isprotodel(sel)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   963
		ev.type = ClientMessage;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   964
		ev.xclient.window = sel->win;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   965
		ev.xclient.message_type = wmatom[WMProtocols];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   966
		ev.xclient.format = 32;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   967
		ev.xclient.data.l[0] = wmatom[WMDelete];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   968
		ev.xclient.data.l[1] = CurrentTime;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   969
		XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   970
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   971
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   972
		XKillClient(dpy, sel->win);
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
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
   975
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   976
leavenotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   977
	XCrossingEvent *ev = &e->xcrossing;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   978
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   979
	if((ev->window == root) && !ev->same_screen) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   980
		selscreen = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   981
		focus(NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   982
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   983
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   984
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
   985
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   986
manage(Window w, XWindowAttributes *wa) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   987
	Client *c, *t = NULL;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   988
	Window trans;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   989
	Status rettrans;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   990
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   991
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   992
	c = emallocz(sizeof(Client));
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
   993
	c->tags = emallocz(sizeof seltags);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   994
	c->win = w;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   995
	c->x = wa->x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   996
	c->y = wa->y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   997
	c->w = wa->width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   998
	c->h = wa->height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   999
	c->oldborder = wa->border_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1000
	if(c->w == sw && c->h == sh) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1001
		c->x = sx;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1002
		c->y = sy;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1003
		c->border = wa->border_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1004
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1005
	else {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1006
		if(c->x + c->w + 2 * c->border > wax + waw)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1007
			c->x = wax + waw - c->w - 2 * c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1008
		if(c->y + c->h + 2 * c->border > way + wah)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1009
			c->y = way + wah - c->h - 2 * c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1010
		if(c->x < wax)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1011
			c->x = wax;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1012
		if(c->y < way)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1013
			c->y = way;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1014
		c->border = BORDERPX;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1015
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1016
	wc.border_width = c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1017
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1018
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1019
	configure(c); /* propagates border_width, if size doesn't change */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1020
	updatesizehints(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1021
	XSelectInput(dpy, w,
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1022
		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1023
	grabbuttons(c, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1024
	updatetitle(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1025
	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1026
		for(t = clients; t && t->win != trans; t = t->next);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1027
	if(t)
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
  1028
		memcpy(c->tags, t->tags, sizeof seltags);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1029
	applyrules(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1030
	if(!c->isfloating)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1031
		c->isfloating = (rettrans == Success) || c->isfixed;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1032
	attach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1033
	attachstack(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1034
	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
  1035
	ban(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1036
	XMapWindow(dpy, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1037
	setclientstate(c, NormalState);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1038
	arrange();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1039
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1040
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
  1041
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1042
mappingnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1043
	XMappingEvent *ev = &e->xmapping;
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
	XRefreshKeyboardMapping(ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1046
	if(ev->request == MappingKeyboard)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1047
		keypress(NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1048
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1049
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
  1050
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1051
maprequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1052
	static XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1053
	XMapRequestEvent *ev = &e->xmaprequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1054
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1055
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1056
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1057
	if(wa.override_redirect)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1058
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1059
	if(!getclient(ev->window))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1060
		manage(ev->window, &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1061
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1062
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
  1063
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1064
movemouse(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1065
	int x1, y1, ocx, ocy, di, nx, ny;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1066
	unsigned int dui;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1067
	Window dummy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1068
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1069
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1070
	ocx = nx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1071
	ocy = ny = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1072
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1073
			None, cursor[CurMove], CurrentTime) != GrabSuccess)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1074
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1075
	c->ismax = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1076
	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1077
	for(;;) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1078
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1079
		switch (ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1080
		case ButtonRelease:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1081
			XUngrabPointer(dpy, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1082
			return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1083
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1084
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1085
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1086
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1087
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1088
		case MotionNotify:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1089
			XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1090
			nx = ocx + (ev.xmotion.x - x1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1091
			ny = ocy + (ev.xmotion.y - y1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1092
			if(abs(wax + nx) < SNAP)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1093
				nx = wax;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1094
			else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1095
				nx = wax + waw - c->w - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1096
			if(abs(way - ny) < SNAP)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1097
				ny = way;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1098
			else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1099
				ny = way + wah - c->h - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1100
			resize(c, nx, ny, c->w, c->h, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1101
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1102
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1103
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1104
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1105
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
  1106
Client *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1107
nexttiled(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1108
	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1109
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1110
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1111
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
  1112
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1113
propertynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1114
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1115
	Window trans;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1116
	XPropertyEvent *ev = &e->xproperty;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1117
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1118
	if(ev->state == PropertyDelete)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1119
		return; /* ignore */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1120
	if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1121
		switch (ev->atom) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1122
			default: break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1123
			case XA_WM_TRANSIENT_FOR:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1124
				XGetTransientForHint(dpy, c->win, &trans);
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
  1125
				if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1126
					arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1127
				break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1128
			case XA_WM_NORMAL_HINTS:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1129
				updatesizehints(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1130
				break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1131
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1132
		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
  1133
			updatetitle(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1134
			if(c == sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1135
				drawbar();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1136
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1137
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1138
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1139
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
  1140
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1141
quit(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1142
	readin = running = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1143
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1144
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
  1145
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
  1146
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1147
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
  1148
	XWindowChanges wc;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1149
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1150
	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
  1151
		/* set minimum possible */
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1152
		if (w < 1)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1153
			w = 1;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1154
		if (h < 1)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1155
			h = 1;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1156
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1157
		/* 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
  1158
		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
  1159
		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
  1160
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1161
		/* adjust for aspect limits */
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1162
		if (c->minay > 0 && c->maxay > 0 && c->minax > 0 && c->maxax > 0) {
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1163
			if (w * c->maxay > h * c->maxax)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1164
				w = h * c->maxax / c->maxay;
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1165
			else if (w * c->minay < h * c->minax)
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1166
				h = w * c->minay / c->minax;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1167
		}
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1168
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1169
		/* 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
  1170
		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
  1171
			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
  1172
		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
  1173
			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
  1174
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1175
		/* 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
  1176
		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
  1177
		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
  1178
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1179
		if(c->minw > 0 && w < c->minw)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1180
			w = c->minw;
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1181
		if(c->minh > 0 && h < c->minh)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1182
			h = c->minh;
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1183
		if(c->maxw > 0 && w > c->maxw)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1184
			w = c->maxw;
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1185
		if(c->maxh > 0 && h > c->maxh)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1186
			h = c->maxh;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1187
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1188
	if(w <= 0 || h <= 0)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1189
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1190
	/* offscreen appearance fixes */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1191
	if(x > sw)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1192
		x = sw - w - 2 * c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1193
	if(y > sh)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1194
		y = sh - h - 2 * c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1195
	if(x + w + 2 * c->border < sx)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1196
		x = sx;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1197
	if(y + h + 2 * c->border < sy)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1198
		y = sy;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1199
	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
  1200
		c->x = wc.x = x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1201
		c->y = wc.y = y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1202
		c->w = wc.width = w;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1203
		c->h = wc.height = h;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1204
		wc.border_width = c->border;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1205
		XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1206
		configure(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1207
		XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1208
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1209
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1210
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
  1211
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1212
resizemouse(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1213
	int ocx, ocy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1214
	int nw, nh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1215
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1216
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1217
	ocx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1218
	ocy = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1219
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1220
			None, cursor[CurResize], CurrentTime) != GrabSuccess)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1221
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1222
	c->ismax = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1223
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1224
	for(;;) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1225
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1226
		switch(ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1227
		case ButtonRelease:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1228
			XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1229
					c->w + c->border - 1, c->h + c->border - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1230
			XUngrabPointer(dpy, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1231
			while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1232
			return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1233
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1234
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1235
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1236
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1237
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1238
		case MotionNotify:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1239
			XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1240
			if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1241
				nw = 1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1242
			if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1243
				nh = 1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1244
			resize(c, c->x, c->y, nw, nh, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1245
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1246
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1247
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1248
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1249
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
  1250
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1251
restack(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1252
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1253
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1254
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1255
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1256
	drawbar();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1257
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1258
		return;
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
  1259
	if(sel->isfloating || (layout->arrange == floating))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1260
		XRaiseWindow(dpy, sel->win);
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
  1261
	if(layout->arrange != floating) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1262
		wc.stack_mode = Below;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1263
		wc.sibling = barwin;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1264
		if(!sel->isfloating) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1265
			XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1266
			wc.sibling = sel->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1267
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1268
		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1269
			if(c == sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1270
				continue;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1271
			XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1272
			wc.sibling = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1273
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1274
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1275
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1276
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
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
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
  1279
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1280
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
  1281
	char *p;
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1282
	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
  1283
	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
  1284
	unsigned int len, offset;
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1285
	XEvent ev;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1286
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1287
	/* main event loop, also reads status text from stdin */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1288
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1289
	xfd = ConnectionNumber(dpy);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1290
	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
  1291
	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
  1292
	len = sizeof stext - 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
  1293
	stext[len] = '\0'; /* 0-terminator is never touched */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1294
	while(running) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1295
		FD_ZERO(&rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1296
		if(readin)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1297
			FD_SET(STDIN_FILENO, &rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1298
		FD_SET(xfd, &rd);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1299
		if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1300
			if(errno == EINTR)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1301
				continue;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1302
			eprint("select failed\n");
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1303
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1304
		if(FD_ISSET(STDIN_FILENO, &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
  1305
			switch((r = read(STDIN_FILENO, stext + offset, len - offset))) {
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
			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
  1307
				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
  1308
				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
  1309
				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
  1310
			case 0:
1053
9990c1b25ceb simplified
Anselm R. Garbe <garbeam@gmail.com>
parents: 1052
diff changeset
  1311
				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
  1312
				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
  1313
				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
  1314
			default:
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
  1315
				stext[offset + r] = '\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
  1316
				for(p = stext; *p && *p != '\n'; p++);
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
				if(*p == '\n') {
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
					*p = '\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
  1319
					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
  1320
				}
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
  1321
				else
1055
f2838f633a85 doing it in a shorter way
Anselm R. Garbe <garbeam@gmail.com>
parents: 1054
diff changeset
  1322
					offset = (offset + r < len - 1) ? offset + r : 0;
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
  1323
			}
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1324
			drawbar();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1325
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1326
		while(XPending(dpy)) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1327
			XNextEvent(dpy, &ev);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1328
			if(handler[ev.type])
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1329
				(handler[ev.type])(&ev); /* call handler */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1330
		}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1331
	}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1332
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1333
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
  1334
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1335
scan(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1336
	unsigned int i, num;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1337
	Window *wins, d1, d2;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1338
	XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1339
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1340
	wins = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1341
	if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1342
		for(i = 0; i < num; i++) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1343
			if(!XGetWindowAttributes(dpy, wins[i], &wa)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1344
			|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1345
				continue;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1346
			if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1347
				manage(wins[i], &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1348
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1349
		for(i = 0; i < num; i++) { /* now the transients */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1350
			if(!XGetWindowAttributes(dpy, wins[i], &wa))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1351
				continue;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1352
			if(XGetTransientForHint(dpy, wins[i], &d1)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1353
			&& (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1354
				manage(wins[i], &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1355
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1356
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1357
	if(wins)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1358
		XFree(wins);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1359
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1360
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
  1361
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1362
setclientstate(Client *c, long state) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1363
	long data[] = {state, None};
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1364
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1365
	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1366
			PropModeReplace, (unsigned char *)data, 2);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1367
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1368
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
  1369
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1370
setlayout(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1371
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1372
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1373
	if(!arg) {
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1374
		if(++layout == &layouts[LENGTH(layouts)])
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1375
			layout = &layouts[0];
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1376
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1377
	else {
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1378
		for(i = 0; i < LENGTH(layouts); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1379
			if(!strcmp(arg, layouts[i].symbol))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1380
				break;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1381
		if(i == LENGTH(layouts))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1382
			return;
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1383
		layout = &layouts[i];
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1384
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1385
	if(sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1386
		arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1387
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1388
		drawbar();
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
setmwfact(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1393
	double delta;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1394
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1395
	if(!domwfact)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1396
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1397
	/* arg handling, manipulate mwfact */
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
  1398
	if(arg == NULL)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1399
		mwfact = MWFACT;
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
  1400
	else if(sscanf(arg, "%lf", &delta) == 1) {
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
  1401
		if(arg[0] == '+' || arg[0] == '-')
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
  1402
			mwfact += delta;
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
  1403
		else
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1404
			mwfact = delta;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1405
		if(mwfact < 0.1)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1406
			mwfact = 0.1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1407
		else if(mwfact > 0.9)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1408
			mwfact = 0.9;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1409
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1410
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1411
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1412
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
  1413
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1414
setup(void) {
1005
2acc60d6dfe2 cosmetic fix
Anselm R. Garbe <garbeam@gmail.com>
parents: 1004
diff changeset
  1415
	int d;
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1416
	unsigned int i, j, mask;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1417
	Window w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1418
	XModifierKeymap *modmap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1419
	XSetWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1420
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1421
	/* init atoms */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1422
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1423
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1424
	wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1425
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1426
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1427
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1428
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1429
			PropModeReplace, (unsigned char *) netatom, NetLast);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1430
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1431
	/* init cursors */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1432
	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1433
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1434
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1435
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1436
	/* init geometry */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1437
	sx = sy = 0;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1438
	sw = DisplayWidth(dpy, screen);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1439
	sh = DisplayHeight(dpy, screen);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1440
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1441
	/* init modifier map */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1442
	modmap = XGetModifierMapping(dpy);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1443
	for(i = 0; i < 8; i++)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1444
		for(j = 0; j < modmap->max_keypermod; j++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1445
			if(modmap->modifiermap[i * modmap->max_keypermod + j]
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1446
			== XKeysymToKeycode(dpy, XK_Num_Lock))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1447
				numlockmask = (1 << i);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1448
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1449
	XFreeModifiermap(modmap);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1450
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1451
	/* select for events */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1452
	wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1453
		| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1454
	wa.cursor = cursor[CurNormal];
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1455
	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1456
	XSelectInput(dpy, root, wa.event_mask);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1457
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1458
	/* grab keys */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1459
	keypress(NULL);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1460
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1461
	/* init tags */
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1462
	compileregs();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1463
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1464
	/* init appearance */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1465
	dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1466
	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1467
	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1468
	dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1469
	dc.sel[ColBG] = getcolor(SELBGCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1470
	dc.sel[ColFG] = getcolor(SELFGCOLOR);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1471
	initfont(FONT);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1472
	dc.h = bh = dc.font.height + 2;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1473
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1474
	/* init layouts */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1475
	mwfact = MWFACT;
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1476
	layout = &layouts[0];
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1477
	for(blw = i = 0; i < LENGTH(layouts); i++) {
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1478
		j = textw(layouts[i].symbol);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1479
		if(j > blw)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1480
			blw = j;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1481
	}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1482
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1483
	/* init bar */
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1484
	bpos = BARPOS;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1485
	wa.override_redirect = 1;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1486
	wa.background_pixmap = ParentRelative;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1487
	wa.event_mask = ButtonPressMask | ExposureMask;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1488
	barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1489
			DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1490
			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1491
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1492
	updatebarpos();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1493
	XMapRaised(dpy, barwin);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1494
	strcpy(stext, "dwm-"VERSION);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1495
	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1496
	dc.gc = XCreateGC(dpy, root, 0, 0);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1497
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1498
	if(!dc.font.set)
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1499
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1500
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1501
	/* multihead support */
1005
2acc60d6dfe2 cosmetic fix
Anselm R. Garbe <garbeam@gmail.com>
parents: 1004
diff changeset
  1502
	selscreen = XQueryPointer(dpy, root, &w, &w, &d, &d, &d, &d, &mask);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1503
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1504
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
  1505
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1506
spawn(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1507
	static char *shell = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1508
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1509
	if(!shell && !(shell = getenv("SHELL")))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1510
		shell = "/bin/sh";
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1511
	if(!arg)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1512
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1513
	/* 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
  1514
	 * 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
  1515
	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
  1516
		if(fork() == 0) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1517
			if(dpy)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1518
				close(ConnectionNumber(dpy));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1519
			setsid();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1520
			execl(shell, shell, "-c", arg, (char *)NULL);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1521
			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1522
			perror(" failed");
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1523
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1524
		exit(0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1525
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1526
	wait(0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1527
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1528
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
  1529
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1530
tag(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1531
	unsigned int i;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1532
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1533
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1534
		return;
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1535
	for(i = 0; i < LENGTH(tags); i++)
1040
b8408fc315df some cleanup, removed ntags variable, defined NTAGS macro, simplified tag(), view() and idxoftag(), fixed some NULL comparisions
arg@suckless.org
parents: 1039
diff changeset
  1536
		sel->tags[i] = (NULL == arg);
b8408fc315df some cleanup, removed ntags variable, defined NTAGS macro, simplified tag(), view() and idxoftag(), fixed some NULL comparisions
arg@suckless.org
parents: 1039
diff changeset
  1537
	sel->tags[idxoftag(arg)] = True;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1538
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1539
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1540
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
  1541
unsigned int
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1542
textnw(const char *text, unsigned int len) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1543
	XRectangle r;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1544
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1545
	if(dc.font.set) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1546
		XmbTextExtents(dc.font.set, text, len, NULL, &r);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1547
		return r.width;
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
	return XTextWidth(dc.font.xfont, text, len);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1550
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1551
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
  1552
unsigned int
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1553
textw(const char *text) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1554
	return textnw(text, strlen(text)) + dc.font.height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1555
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1556
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
  1557
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1558
tile(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1559
	unsigned int i, n, nx, ny, nw, nh, mw, th;
1016
3027df4b2c0d improved tile() for the RESIZEHINTS == True case, now more space is consumed by the clients (esp. if those clients use increment handling heavily)
Anselm R. Garbe <garbeam@gmail.com>
parents: 1014
diff changeset
  1560
	Client *c, *mc;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1561
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1562
	domwfact = dozoom = True;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1563
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1564
		n++;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1565
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1566
	/* window geoms */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1567
	mw = (n == 1) ? waw : mwfact * waw;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1568
	th = (n > 1) ? wah / (n - 1) : 0;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1569
	if(n > 1 && th < bh)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1570
		th = wah;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1571
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1572
	nx = wax;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1573
	ny = way;
1016
3027df4b2c0d improved tile() for the RESIZEHINTS == True case, now more space is consumed by the clients (esp. if those clients use increment handling heavily)
Anselm R. Garbe <garbeam@gmail.com>
parents: 1014
diff changeset
  1574
	nw = 0; /* gcc stupidity requires this */
3027df4b2c0d improved tile() for the RESIZEHINTS == True case, now more space is consumed by the clients (esp. if those clients use increment handling heavily)
Anselm R. Garbe <garbeam@gmail.com>
parents: 1014
diff changeset
  1575
	for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1576
		c->ismax = False;
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
  1577
		if(i == 0) { /* master */
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1578
			nw = mw - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1579
			nh = wah - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1580
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1581
		else {  /* tile window */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1582
			if(i == 1) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1583
				ny = way;
1023
f6b71fb9ea39 reverted Peters patch to tile, I will discuss the reasons at dwm@
Anselm R. Garbe <garbeam@gmail.com>
parents: 1018
diff changeset
  1584
				nx += mc->w + 2 * mc->border;
1016
3027df4b2c0d improved tile() for the RESIZEHINTS == True case, now more space is consumed by the clients (esp. if those clients use increment handling heavily)
Anselm R. Garbe <garbeam@gmail.com>
parents: 1014
diff changeset
  1585
				nw = waw - nx - 2 * c->border;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1586
			}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1587
			if(i + 1 == n) /* remainder */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1588
				nh = (way + wah) - ny - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1589
			else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1590
				nh = th - 2 * c->border;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1591
		}
1050
fb5fa382c002 revival of RESIZEHINTS
Anselm R. Garbe <garbeam@gmail.com>
parents: 1049
diff changeset
  1592
		resize(c, nx, ny, nw, nh, RESIZEHINTS);
fb5fa382c002 revival of RESIZEHINTS
Anselm R. Garbe <garbeam@gmail.com>
parents: 1049
diff changeset
  1593
		if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
1043
bcd7e18e196a fixed a comment
arg@suckless.org
parents: 1042
diff changeset
  1594
			/* client doesn't accept size constraints */
1041
ee04fab6ff9c removed RESIZEHINTS and enhanced tile for fixed or aspect-ratio'ed clients
arg@suckless.org
parents: 1040
diff changeset
  1595
			resize(c, nx, ny, nw, nh, False);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1596
		if(n > 1 && th != wah)
1023
f6b71fb9ea39 reverted Peters patch to tile, I will discuss the reasons at dwm@
Anselm R. Garbe <garbeam@gmail.com>
parents: 1018
diff changeset
  1597
			ny = c->y + c->h + 2 * c->border;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1598
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1599
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1600
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
  1601
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1602
togglebar(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1603
	if(bpos == BarOff)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1604
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1605
	else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1606
		bpos = BarOff;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1607
	updatebarpos();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1608
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1609
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1610
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
  1611
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1612
togglefloating(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1613
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1614
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1615
	sel->isfloating = !sel->isfloating;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1616
	if(sel->isfloating)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1617
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1618
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1619
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1620
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
  1621
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1622
togglemax(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1623
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1624
1002
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1625
	if(!sel || sel->isfixed)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1626
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1627
	if((sel->ismax = !sel->ismax)) {
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
  1628
		if((layout->arrange == floating) || sel->isfloating)
1002
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1629
			sel->wasfloating = True;
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1630
		else {
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1631
			togglefloating(NULL);
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1632
			sel->wasfloating = False;
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1633
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1634
		sel->rx = sel->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1635
		sel->ry = sel->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1636
		sel->rw = sel->w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1637
		sel->rh = sel->h;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1638
		resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1639
	}
1002
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1640
	else {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1641
		resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
1003
19d4ccea9745 applied Peters patch, applied yiyus hint to initfont
arg@suckless.org
parents: 1002
diff changeset
  1642
		if(!sel->wasfloating)
1002
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1643
			togglefloating(NULL);
5cc2be8efeb4 applied Peter Hartlich's togglemax patch to allow toggling tiled clients to maximum
Anselm R. Garbe <garbeam@gmail.com>
parents: 1001
diff changeset
  1644
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1645
	drawbar();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1646
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1647
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1648
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
  1649
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1650
toggletag(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1651
	unsigned int i, j;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1652
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1653
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1654
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1655
	i = idxoftag(arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1656
	sel->tags[i] = !sel->tags[i];
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1657
	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
  1658
	if(j == LENGTH(tags))
1040
b8408fc315df some cleanup, removed ntags variable, defined NTAGS macro, simplified tag(), view() and idxoftag(), fixed some NULL comparisions
arg@suckless.org
parents: 1039
diff changeset
  1659
		sel->tags[i] = True; /* at least one tag must be enabled */
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1660
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1661
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1662
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
  1663
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1664
toggleview(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1665
	unsigned int i, j;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1666
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1667
	i = idxoftag(arg);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1668
	seltags[i] = !seltags[i];
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1669
	for(j = 0; j < LENGTH(tags) && !seltags[j]; j++);
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1670
	if(j == LENGTH(tags))
1004
9bb192795c5a fixed a comment
Anselm R. Garbe <garbeam@gmail.com>
parents: 1003
diff changeset
  1671
		seltags[i] = True; /* at least one tag must be viewed */
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1672
	arrange();
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1673
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1674
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
  1675
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1676
unban(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1677
	if(!c->isbanned)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1678
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1679
	XMoveWindow(dpy, c->win, c->x, c->y);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1680
	c->isbanned = False;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1681
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1682
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
  1683
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1684
unmanage(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1685
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1686
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1687
	wc.border_width = c->oldborder;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1688
	/* The server grab construct avoids race conditions. */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1689
	XGrabServer(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1690
	XSetErrorHandler(xerrordummy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1691
	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1692
	detach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1693
	detachstack(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1694
	if(sel == c)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1695
		focus(NULL);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1696
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1697
	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
  1698
	free(c->tags);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1699
	free(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1700
	XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1701
	XSetErrorHandler(xerror);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1702
	XUngrabServer(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1703
	arrange();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1704
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1705
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
  1706
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1707
unmapnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1708
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1709
	XUnmapEvent *ev = &e->xunmap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1710
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1711
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1712
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1713
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1714
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
  1715
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1716
updatebarpos(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1717
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1718
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1719
	wax = sx;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1720
	way = sy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1721
	wah = sh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1722
	waw = sw;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1723
	switch(bpos) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1724
	default:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1725
		wah -= bh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1726
		way += bh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1727
		XMoveWindow(dpy, barwin, sx, sy);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1728
		break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1729
	case BarBot:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1730
		wah -= bh;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1731
		XMoveWindow(dpy, barwin, sx, sy + wah);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1732
		break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1733
	case BarOff:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1734
		XMoveWindow(dpy, barwin, sx, sy - bh);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1735
		break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1736
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1737
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1738
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1739
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1740
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
  1741
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1742
updatesizehints(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1743
	long msize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1744
	XSizeHints size;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1745
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1746
	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1747
		size.flags = PSize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1748
	c->flags = size.flags;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1749
	if(c->flags & PBaseSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1750
		c->basew = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1751
		c->baseh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1752
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1753
	else if(c->flags & PMinSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1754
		c->basew = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1755
		c->baseh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1756
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1757
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1758
		c->basew = c->baseh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1759
	if(c->flags & PResizeInc) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1760
		c->incw = size.width_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1761
		c->inch = size.height_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1762
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1763
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1764
		c->incw = c->inch = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1765
	if(c->flags & PMaxSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1766
		c->maxw = size.max_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1767
		c->maxh = size.max_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1768
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1769
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1770
		c->maxw = c->maxh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1771
	if(c->flags & PMinSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1772
		c->minw = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1773
		c->minh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1774
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1775
	else if(c->flags & PBaseSize) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1776
		c->minw = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1777
		c->minh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1778
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1779
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1780
		c->minw = c->minh = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1781
	if(c->flags & PAspect) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1782
		c->minax = size.min_aspect.x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1783
		c->maxax = size.max_aspect.x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1784
		c->minay = size.min_aspect.y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1785
		c->maxay = size.max_aspect.y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1786
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1787
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1788
		c->minax = c->maxax = c->minay = c->maxay = 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1789
	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1790
			&& c->maxw == c->minw && c->maxh == c->minh);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1791
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1792
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
  1793
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1794
updatetitle(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1795
	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
  1796
		gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
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
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1799
/* 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
  1800
 * 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
  1801
 * 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
  1802
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1803
xerror(Display *dpy, XErrorEvent *ee) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1804
	if(ee->error_code == BadWindow
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1805
	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1806
	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1807
	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1808
	|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1809
	|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1810
	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1811
	|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1812
		return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1813
	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
  1814
		ee->request_code, ee->error_code);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1815
	return xerrorxlib(dpy, ee); /* may call exit */
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
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
  1818
int
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1819
xerrordummy(Display *dsply, XErrorEvent *ee) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1820
	return 0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1821
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1822
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1823
/* Startup Error handler to check if another window manager
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1824
 * 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
  1825
int
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1826
xerrorstart(Display *dsply, XErrorEvent *ee) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1827
	otherwm = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1828
	return -1;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1829
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1830
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
  1831
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1832
view(const char *arg) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1833
	unsigned int i;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1834
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
  1835
	memcpy(prevtags, seltags, sizeof seltags);
1048
98fc0d3c583a replaced Nmacros with LENGTH(x) macro
Anselm R. Garbe <garbeam@gmail.com>
parents: 1047
diff changeset
  1836
	for(i = 0; i < LENGTH(tags); i++)
1046
74aca4c70765 some sanity changes
Anselm R. Garbe <garbeam@gmail.com>
parents: 1045
diff changeset
  1837
		seltags[i] = (NULL == arg);
1040
b8408fc315df some cleanup, removed ntags variable, defined NTAGS macro, simplified tag(), view() and idxoftag(), fixed some NULL comparisions
arg@suckless.org
parents: 1039
diff changeset
  1838
	seltags[idxoftag(arg)] = True;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1839
	arrange();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1840
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1841
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
  1842
void
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
  1843
viewprevtag(const char *arg) {
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
  1844
	static Bool tmptags[sizeof tags / sizeof tags[0]];
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
  1845
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
  1846
	memcpy(tmptags, seltags, sizeof seltags);
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
  1847
	memcpy(seltags, prevtags, sizeof seltags);
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
  1848
	memcpy(prevtags, tmptags, sizeof seltags);
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
  1849
	arrange();
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
  1850
}
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
  1851
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
  1852
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1853
zoom(const char *arg) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1854
	Client *c;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1855
1047
ef0b927bf16c replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltidx, added NRULES, NLAYOUTS and Layout *layout as alternatives, removed isarrange(), checking against layout->arrange instead.
Anselm R. Garbe <garbeam@gmail.com>
parents: 1046
diff changeset
  1856
	if(!sel || !dozoom || sel->isfloating)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1857
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1858
	if((c = sel) == nexttiled(clients))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1859
		if(!(c = nexttiled(c->next)))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1860
			return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1861
	detach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1862
	attach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1863
	focus(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1864
	arrange();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1865
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1866
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1867
int
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1868
main(int argc, char *argv[]) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1869
	if(argc == 2 && !strcmp("-v", argv[1]))
1056
ba87e437bf45 full names in -v output of dwm
Anselm R. Garbe <garbeam@gmail.com>
parents: 1055
diff changeset
  1870
		eprint("dwm-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk, "
ba87e437bf45 full names in -v output of dwm
Anselm R. Garbe <garbeam@gmail.com>
parents: 1055
diff changeset
  1871
		       "Jukka Salmi, Premysl Hruby, Szabolcs Nagy\n");
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1872
	else if(argc != 1)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1873
		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
  1874
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1875
	setlocale(LC_CTYPE, "");
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1876
	if(!(dpy = XOpenDisplay(0)))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1877
		eprint("dwm: cannot open display\n");
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1878
	screen = DefaultScreen(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1879
	root = RootWindow(dpy, screen);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1880
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1881
	checkotherwm();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1882
	setup();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1883
	drawbar();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1884
	scan();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1885
	run();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1886
	cleanup();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1887
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1888
	XCloseDisplay(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1889
	return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1890
}