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