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