dwm.c
author a@null
Sun, 08 Feb 2009 12:11:22 +0000
changeset 1383 85a78d8afa0f
parent 1381 8b7836a471f8
child 1385 85a8eff4c123
permissions -rw-r--r--
fixed an issue reported by Nibble, also fixed s/2008/2009/
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
 *
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
     9
 * The event handlers of dwm are organized in an array which is accessed
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
    10
 * whenever a new event has been fetched. This allows event dispatching
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
    11
 * in O(1) time.
992
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    12
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    13
 * 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
    14
 * set the override_redirect flag.  Clients are organized in a global
1362
f6c3491c41f1 applied Gottox' comment fix (thanks)
Anselm R Garbe <garbeam@gmail.com>
parents: 1361
diff changeset
    15
 * linked client list, the focus history is remembered through a global
1242
91e8a7fb3b60 updated the initial comment to reflect the use of bit arrays
Anselm R Garbe <garbeam@gmail.com>
parents: 1241
diff changeset
    16
 * stack list. Each client contains a bit array to indicate the tags of a
91e8a7fb3b60 updated the initial comment to reflect the use of bit arrays
Anselm R Garbe <garbeam@gmail.com>
parents: 1241
diff changeset
    17
 * client.
992
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    18
 *
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
    19
 * 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
    20
 *
d9ab31906133 backporting my intro-comment of old dwm.h
Anselm R. Garbe <garbeam@gmail.com>
parents: 991
diff changeset
    21
 * 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
    22
 */
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    23
#include <errno.h>
1343
f4707b7bd3a2 reverted some resize() changes, reverted setlocale removal
Anselm R Garbe <garbeam@gmail.com>
parents: 1342
diff changeset
    24
#include <locale.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    25
#include <stdarg.h>
1374
ff5fd6693d5d ok, using signal.h for portability reasons
a@null
parents: 1373
diff changeset
    26
#include <signal.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    27
#include <stdio.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    28
#include <stdlib.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    29
#include <string.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    30
#include <unistd.h>
1014
35461e0a4894 fixed inclusion order
arg@suckless.org
parents: 1008
diff changeset
    31
#include <sys/types.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    32
#include <sys/wait.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    33
#include <X11/cursorfont.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    34
#include <X11/keysym.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    35
#include <X11/Xatom.h>
1033
a8efbb301ef4 just making dwm.h saner
arg@suckless.org
parents: 1032
diff changeset
    36
#include <X11/Xlib.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    37
#include <X11/Xproto.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    38
#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
    39
#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
    40
#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
    41
#endif
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    42
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    43
/* macros */
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    44
#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    45
#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    46
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    47
#define ISVISIBLE(x)            (x->tags & tagset[seltags])
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    48
#define LENGTH(x)               (sizeof x / sizeof x[0])
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    49
#define MAX(a, b)               ((a) > (b) ? (a) : (b))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    50
#define MIN(a, b)               ((a) < (b) ? (a) : (b))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    51
#define MAXTAGLEN               16
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    52
#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
    53
#define WIDTH(x)                ((x)->w + 2 * (x)->bw)
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
    54
#define HEIGHT(x)               ((x)->h + 2 * (x)->bw)
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    55
#define TAGMASK                 ((int)((1LL << LENGTH(tags)) - 1))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    56
#define TEXTW(x)                (textnw(x, strlen(x)) + dc.font.height)
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 */
1345
169467e68992 WM_NAME is builtin atom
Premysl Hruby <dfenze@gmail.com>
parents: 1344
diff changeset
    62
enum { WMProtocols, WMDelete, WMState, WMLast };        /* default atoms */
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
    63
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
    64
       ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
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
    65
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    66
typedef union {
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    67
	int i;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    68
	unsigned int ui;
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    69
	float f;
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    70
	void *v;
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    71
} Arg;
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    72
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    73
typedef struct {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    74
	unsigned int click;
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    75
	unsigned int mask;
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    76
	unsigned int button;
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    77
	void (*func)(const Arg *arg);
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    78
	const Arg arg;
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    79
} Button;
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
    80
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
    81
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
    82
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
    83
	char name[256];
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
    84
	float mina, maxa;
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
    85
	int x, y, w, h;
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    86
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
1229
818892d66dc4 Key.mod is uint, Client.[old]bw is int
Anselm R Garbe <garbeam@gmail.com>
parents: 1228
diff changeset
    87
	int bw, oldbw;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    88
	unsigned int tags;
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
    89
	Bool isfixed, isfloating, isurgent;
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
    90
	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
    91
	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
    92
	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
    93
};
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
    94
e6188cb17fa1 removed dwm.h, just include C-files 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
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
    96
	int x, y, w, h;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    97
	unsigned long norm[ColLast];
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    98
	unsigned long 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
    99
	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
   100
	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
   101
	struct {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   102
		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
   103
		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
   104
		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
   105
		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
   106
		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
   107
	} 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
   108
} 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
   109
e6188cb17fa1 removed dwm.h, just include C-files 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
typedef struct {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   111
	unsigned int 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
   112
	KeySym keysym;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   113
	void (*func)(const Arg *);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   114
	const Arg 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
   115
} 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
   116
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   117
typedef struct {
e6188cb17fa1 removed dwm.h, just include C-files 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
	const char *symbol;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   119
	void (*arrange)(void);
1187
264e671527e6 applied the proposal by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1186
diff changeset
   120
} 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
   121
e6188cb17fa1 removed dwm.h, just include C-files 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
typedef struct {
1147
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   123
	const char *class;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   124
	const char *instance;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   125
	const char *title;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   126
	unsigned int 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
   127
	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
   128
} 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
   129
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   130
/* function declarations */
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   131
static void adjustborder(Client *c, unsigned int bw);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   132
static void applyrules(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   133
static void arrange(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   134
static void attach(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   135
static void attachstack(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   136
static void buttonpress(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   137
static void checkotherwm(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   138
static void cleanup(void);
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   139
static void clearurgent(Client *c);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   140
static void configure(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   141
static void configurenotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   142
static void configurerequest(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   143
static void destroynotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   144
static void detach(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   145
static void detachstack(Client *c);
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   146
static void die(const char *errstr, ...);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   147
static void drawbar(void);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   148
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   149
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   150
static void enternotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   151
static void expose(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   152
static void focus(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   153
static void focusin(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   154
static void focusstack(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   155
static Client *getclient(Window w);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   156
static unsigned long getcolor(const char *colstr);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   157
static long getstate(Window w);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   158
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   159
static void grabbuttons(Client *c, Bool focused);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   160
static void grabkeys(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   161
static void initfont(const char *fontstr);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   162
static Bool isprotodel(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   163
static void keypress(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   164
static void killclient(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   165
static void manage(Window w, XWindowAttributes *wa);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   166
static void mappingnotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   167
static void maprequest(XEvent *e);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   168
static void monocle(void);
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   169
static void movemouse(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   170
static Client *nexttiled(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   171
static void propertynotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   172
static void quit(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   173
static void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   174
static void resizemouse(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   175
static void restack(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   176
static void run(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   177
static void scan(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   178
static void setclientstate(Client *c, long state);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   179
static void setlayout(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   180
static void setmfact(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   181
static void setup(void);
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   182
static void showhide(Client *c, unsigned int ntiled);
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
   183
static void sigchld(int signal);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   184
static void spawn(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   185
static void tag(const Arg *arg);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   186
static int textnw(const char *text, unsigned int len);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   187
static void tile(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   188
static void togglebar(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   189
static void togglefloating(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   190
static void toggletag(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   191
static void toggleview(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   192
static void unmanage(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   193
static void unmapnotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   194
static void updatebar(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   195
static void updategeom(void);
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   196
static void updatenumlockmask(void);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   197
static void updatesizehints(Client *c);
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
   198
static void updatestatus(void);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   199
static void updatetitle(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   200
static void updatewmhints(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   201
static void view(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   202
static int xerror(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   203
static int xerrordummy(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   204
static int xerrorstart(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   205
static void zoom(const Arg *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
   206
e6188cb17fa1 removed dwm.h, just include C-files 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
/* variables */
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   208
static char stext[256];
1323
c1d2b106440d added some comments regarding FAQ about s{x,y,w,h}, w{x,y,w,h}, b{y,h,lw}
Anselm R Garbe <garbeam@gmail.com>
parents: 1322
diff changeset
   209
static int screen;
1326
158c50c241b5 making a comment more explicit
Anselm R Garbe <garbeam@gmail.com>
parents: 1325
diff changeset
   210
static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */ 
1323
c1d2b106440d added some comments regarding FAQ about s{x,y,w,h}, w{x,y,w,h}, b{y,h,lw}
Anselm R Garbe <garbeam@gmail.com>
parents: 1322
diff changeset
   211
static int by, bh, blw;    /* bar geometry y, height and layout symbol width */
c1d2b106440d added some comments regarding FAQ about s{x,y,w,h}, w{x,y,w,h}, b{y,h,lw}
Anselm R Garbe <garbeam@gmail.com>
parents: 1322
diff changeset
   212
static int wx, wy, ww, wh; /* window area geometry x, y, width, height, bar excluded */
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   213
static unsigned int seltags = 0, sellt = 0;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   214
static int (*xerrorxlib)(Display *, XErrorEvent *);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   215
static unsigned int numlockmask = 0;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   216
static void (*handler[LASTEvent]) (XEvent *) = {
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
   217
	[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
   218
	[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
   219
	[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
   220
	[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
   221
	[EnterNotify] = enternotify,
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   222
	[Expose] = expose,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   223
	[FocusIn] = focusin,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   224
	[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
   225
	[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
   226
	[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
   227
	[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
   228
	[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
   229
};
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   230
static Atom wmatom[WMLast], netatom[NetLast];
1317
40cd44593977 made readin a config.h variable
Anselm R Garbe <garbeam@gmail.com>
parents: 1315
diff changeset
   231
static Bool otherwm;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   232
static Bool running = True;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   233
static Client *clients = NULL;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   234
static Client *sel = NULL;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   235
static Client *stack = NULL;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   236
static Cursor cursor[CurLast];
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   237
static Display *dpy;
1348
18098673e417 checking result of XGetClassHint, removed some obsolete lines in initfont()
Anselm R Garbe <garbeam@gmail.com>
parents: 1347
diff changeset
   238
static DC dc;
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   239
static Layout *lt[] = { NULL, NULL };
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   240
static 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
   241
/* 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
   242
#include "config.h"
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
   243
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   244
/* compile-time check if all tags fit into an unsigned int bit array. */
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   245
struct NumTags { char limitexceeded[sizeof(unsigned int) * 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
   246
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   247
/* function implementations */
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   248
void
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   249
adjustborder(Client *c, unsigned int bw) {
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   250
	XWindowChanges wc;
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   251
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   252
	if(c->bw != bw) {
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   253
		c->bw = wc.border_width = bw;
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   254
		XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   255
	}
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   256
}
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   257
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   258
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   259
applyrules(Client *c) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   260
	unsigned int i;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   261
	Rule *r;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   262
	XClassHint ch = { 0 };
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
	/* rule matching */
1349
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   265
	if(XGetClassHint(dpy, c->win, &ch)) {
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   266
		for(i = 0; i < LENGTH(rules); i++) {
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   267
			r = &rules[i];
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   268
			if((!r->title || strstr(c->name, r->title))
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   269
			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   270
			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   271
				c->isfloating = r->isfloating;
1377
d10040d81ef8 applied yiyus applyrules() patch
a@null
parents: 1376
diff changeset
   272
				c->tags |= r->tags & TAGMASK ? r->tags & TAGMASK : tagset[seltags]; 
1349
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   273
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   274
		}
1349
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   275
		if(ch.res_class)
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   276
			XFree(ch.res_class);
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   277
		if(ch.res_name)
Anselm R Garbe <garbeam@gmail.com>
parents: 1348
diff changeset
   278
			XFree(ch.res_name);
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   279
	}
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
   280
	if(!c->tags)
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
   281
		c->tags = tagset[seltags];
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   282
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   283
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   284
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
   285
arrange(void) {
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   286
	unsigned int nt;
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   287
	Client *c;
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   288
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   289
	for(nt = 0, c = nexttiled(clients); c; c = nexttiled(c->next), nt++);
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
   290
	showhide(stack, nt);
1112
27d2e0f4ff82 fixed some issues nsz reported in IRC log
anselm@anselm1
parents: 1110
diff changeset
   291
	focus(NULL);
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   292
	if(lt[sellt]->arrange)
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   293
		lt[sellt]->arrange();
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   294
	restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   295
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   296
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   297
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   298
attach(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   299
	c->next = clients;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   300
	clients = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   301
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   302
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   303
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   304
attachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   305
	c->snext = stack;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   306
	stack = c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   307
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   308
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   309
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   310
buttonpress(XEvent *e) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   311
	unsigned int i, x, click;
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   312
	Arg arg = {0};
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   313
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   314
	XButtonPressedEvent *ev = &e->xbutton;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   315
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   316
	click = ClkRootWin;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   317
	if(ev->window == barwin) {
1296
739b1baaa853 fixed Gottox' buttonpress/ClkTagBar code
Anselm R Garbe <garbeam@gmail.com>
parents: 1295
diff changeset
   318
		i = x = 0;
739b1baaa853 fixed Gottox' buttonpress/ClkTagBar code
Anselm R Garbe <garbeam@gmail.com>
parents: 1295
diff changeset
   319
		do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags));
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   320
		if(i < LENGTH(tags)) {
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   321
			click = ClkTagBar;
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   322
			arg.ui = 1 << i;
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   323
		}
1271
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   324
		else if(ev->x < x + blw)
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   325
			click = ClkLtSymbol;
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   326
		else if(ev->x > wx + ww - TEXTW(stext))
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   327
			click = ClkStatusText;
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   328
		else
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   329
			click = ClkWinTitle;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   330
	}
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   331
	else if((c = getclient(ev->window))) {
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   332
		focus(c);
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   333
		click = ClkClientWin;
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   334
	}
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   335
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   336
	for(i = 0; i < LENGTH(buttons); i++)
1271
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   337
		if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   338
		   && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
1351
3f66d2d2cd6e applied yiyus tagbar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1349
diff changeset
   339
			buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   340
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   341
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   342
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   343
checkotherwm(void) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   344
	otherwm = False;
1354
dced80b409d8 applied Martin Hurton's checkotherwm simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1353
diff changeset
   345
	xerrorxlib = XSetErrorHandler(xerrorstart);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   346
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   347
	/* this causes an error if some other window manager is running */
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   348
	XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   349
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   350
	if(otherwm)
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   351
		die("dwm: another window manager is already running\n");
1354
dced80b409d8 applied Martin Hurton's checkotherwm simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1353
diff changeset
   352
	XSetErrorHandler(xerror);
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
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   355
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   356
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   357
cleanup(void) {
1319
fb29ceb5932a fixes using arg->i instead of arg->ui
Premysl Hruby <dfenze@gmail.com>
parents: 1318
diff changeset
   358
	Arg a = {.ui = ~0};
1263
87cd6583546e using foo layout during cleanup (suggested by Gottox), add Arg->v handling for togglelayout() suggested by anydot
Anselm R Garbe <garbeam@gmail.com>
parents: 1262
diff changeset
   359
	Layout foo = { "", NULL };
1262
decf862df839 lt will point to a foo-layout during cleanup now (Gottox' suggestion), and togglelayout respects Arg->v
Anselm R Garbe <garbeam@gmail.com>
parents: 1261
diff changeset
   360
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   361
	view(&a);
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   362
	lt[sellt] = &foo;
1235
13f86ee1a8e6 applied yiyus domax patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1234
diff changeset
   363
	while(stack)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   364
		unmanage(stack);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   365
	if(dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   366
		XFreeFontSet(dpy, dc.font.set);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   367
	else
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   368
		XFreeFont(dpy, dc.font.xfont);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   369
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   370
	XFreePixmap(dpy, dc.drawable);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   371
	XFreeGC(dpy, dc.gc);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   372
	XFreeCursor(dpy, cursor[CurNormal]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   373
	XFreeCursor(dpy, cursor[CurResize]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   374
	XFreeCursor(dpy, cursor[CurMove]);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   375
	XDestroyWindow(dpy, barwin);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   376
	XSync(dpy, False);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   377
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   378
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   379
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   380
void
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   381
clearurgent(Client *c) {
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   382
	XWMHints *wmh;
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   383
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   384
	c->isurgent = False;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   385
	if(!(wmh = XGetWMHints(dpy, c->win)))
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   386
		return;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   387
	wmh->flags &= ~XUrgencyHint;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   388
	XSetWMHints(dpy, c->win, wmh);
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   389
	XFree(wmh);
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   390
}
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   391
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   392
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   393
configure(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   394
	XConfigureEvent ce;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   395
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   396
	ce.type = ConfigureNotify;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   397
	ce.display = dpy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   398
	ce.event = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   399
	ce.window = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   400
	ce.x = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   401
	ce.y = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   402
	ce.width = c->w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   403
	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
   404
	ce.border_width = c->bw;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   405
	ce.above = None;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   406
	ce.override_redirect = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   407
	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   408
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   409
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   410
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   411
configurenotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   412
	XConfigureEvent *ev = &e->xconfigure;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   413
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   414
	if(ev->window == root && (ev->width != sw || ev->height != sh)) {
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   415
		sw = ev->width;
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   416
		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
   417
		updategeom();
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
   418
		updatebar();
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
   419
		arrange();
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   420
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   421
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   422
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   423
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   424
configurerequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   425
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   426
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   427
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   428
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   429
	if((c = getclient(ev->window))) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   430
		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
   431
			c->bw = ev->border_width;
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   432
		else if(c->isfloating || !lt[sellt]->arrange) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   433
			if(ev->value_mask & CWX)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   434
				c->x = sx + ev->x;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   435
			if(ev->value_mask & CWY)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   436
				c->y = sy + ev->y;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   437
			if(ev->value_mask & CWWidth)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   438
				c->w = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   439
			if(ev->value_mask & CWHeight)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   440
				c->h = ev->height;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   441
			if((c->x - sx + c->w) > sw && c->isfloating)
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   442
				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
   443
			if((c->y - sy + c->h) > sh && c->isfloating)
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   444
				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
1291
6a5c4371eb25 resize should apply if !banned
Anselm R Garbe <garbeam@gmail.com>
parents: 1290
diff changeset
   445
			if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   446
				configure(c);
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   447
			if(ISVISIBLE(c))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   448
				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
   449
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   450
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   451
			configure(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   452
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   453
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   454
		wc.x = ev->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   455
		wc.y = ev->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   456
		wc.width = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   457
		wc.height = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   458
		wc.border_width = ev->border_width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   459
		wc.sibling = ev->above;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   460
		wc.stack_mode = ev->detail;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   461
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   462
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   463
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   464
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   465
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   466
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   467
destroynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   468
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   469
	XDestroyWindowEvent *ev = &e->xdestroywindow;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   470
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   471
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   472
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   473
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   474
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   475
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   476
detach(Client *c) {
1307
2c72f7c8826f simplified detach()
Anselm R Garbe <garbeam@gmail.com>
parents: 1306
diff changeset
   477
	Client **tc;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   478
1307
2c72f7c8826f simplified detach()
Anselm R Garbe <garbeam@gmail.com>
parents: 1306
diff changeset
   479
	for(tc = &clients; *tc && *tc != c; tc = &(*tc)->next);
2c72f7c8826f simplified detach()
Anselm R Garbe <garbeam@gmail.com>
parents: 1306
diff changeset
   480
	*tc = c->next;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   481
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   482
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   483
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   484
detachstack(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   485
	Client **tc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   486
1196
58a67fab8143 applied nsz's another style patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1195
diff changeset
   487
	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
   488
	*tc = c->snext;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   489
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   490
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   491
void
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   492
die(const char *errstr, ...) {
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   493
	va_list ap;
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   494
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   495
	va_start(ap, errstr);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   496
	vfprintf(stderr, errstr, ap);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   497
	va_end(ap);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   498
	exit(EXIT_FAILURE);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   499
}
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   500
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   501
void
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   502
drawbar(void) {
1318
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   503
	int x;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   504
	unsigned int i, occ = 0, urg = 0;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   505
	unsigned long *col;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   506
	Client *c;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   507
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   508
	for(c = clients; c; c = c->next) {
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   509
		occ |= c->tags;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   510
		if(c->isurgent)
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   511
			urg |= c->tags;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   512
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   513
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   514
	dc.x = 0;
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
   515
	for(i = 0; i < LENGTH(tags); i++) {
1236
523ba822927f removed TEXTW
Anselm R Garbe <garbeam@gmail.com>
parents: 1235
diff changeset
   516
		dc.w = TEXTW(tags[i]);
1318
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   517
		col = tagset[seltags] & 1 << i ? dc.sel : dc.norm;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   518
		drawtext(tags[i], col, urg & 1 << i);
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   519
		drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   520
		dc.x += dc.w;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   521
	}
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
   522
	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
   523
		dc.w = blw;
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   524
		drawtext(lt[sellt]->symbol, dc.norm, False);
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
   525
		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
   526
	}
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
   527
	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
   528
		x = dc.x;
1236
523ba822927f removed TEXTW
Anselm R Garbe <garbeam@gmail.com>
parents: 1235
diff changeset
   529
	dc.w = TEXTW(stext);
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
   530
	dc.x = ww - dc.w;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   531
	if(dc.x < x) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   532
		dc.x = x;
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
   533
		dc.w = ww - x;
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   534
	}
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   535
	drawtext(stext, dc.norm, False);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   536
	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
   537
		dc.x = x;
1292
0996dbb6a999 use sel instead of seeking the list
Anselm R Garbe <garbeam@gmail.com>
parents: 1291
diff changeset
   538
		if(sel) {
0996dbb6a999 use sel instead of seeking the list
Anselm R Garbe <garbeam@gmail.com>
parents: 1291
diff changeset
   539
			drawtext(sel->name, dc.sel, False);
0996dbb6a999 use sel instead of seeking the list
Anselm R Garbe <garbeam@gmail.com>
parents: 1291
diff changeset
   540
			drawsquare(sel->isfixed, sel->isfloating, False, dc.sel);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   541
		}
1086
dadc0b94f695 some drawbar() polishing, and certain related fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1085
diff changeset
   542
		else
1107
589074fac88d some more changes towards a better dwm
Anselm R Garbe <garbeam@gmail.com>
parents: 1106
diff changeset
   543
			drawtext(NULL, dc.norm, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   544
	}
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
   545
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   546
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   547
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   548
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   549
void
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   550
drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   551
	int x;
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   552
	XGCValues gcv;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   553
	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
   554
1085
9c4355f988f2 urgency hook handling needs also to invert the square if present
Anselm R Garbe <garbeam@gmail.com>
parents: 1084
diff changeset
   555
	gcv.foreground = col[invert ? ColBG : ColFG];
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   556
	XChangeGC(dpy, dc.gc, GCForeground, &gcv);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   557
	x = (dc.font.ascent + dc.font.descent + 2) / 4;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   558
	r.x = dc.x + 1;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   559
	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
   560
	if(filled) {
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   561
		r.width = r.height = x + 1;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   562
		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
   563
	}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   564
	else if(empty) {
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   565
		r.width = r.height = x;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   566
		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
   567
	}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   568
}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   569
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   570
void
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   571
drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
1332
Anselm R Garbe <garbeam@gmail.com>
parents: 1331
diff changeset
   572
	char buf[256];
1254
d04ee4e2336d applied nsz's patches (many thanks!)
arg@suckless.org
parents: 1253
diff changeset
   573
	int i, x, y, h, len, olen;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   574
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   575
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   576
	XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   577
	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   578
	if(!text)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   579
		return;
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   580
	olen = strlen(text);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   581
	h = dc.font.ascent + dc.font.descent;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   582
	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
   583
	x = dc.x + (h / 2);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   584
	/* shorten text if necessary */
1336
6ed902a28221 fixed error I did when applying Martin Hurton's drawtext patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1335
diff changeset
   585
	for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
   586
	if(!len)
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   587
		return;
1328
0fac6d3067d7 applied Martin Hurton's drawtext() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1327
diff changeset
   588
	memcpy(buf, text, len);
1250
1fa12fca6c0e Gottox' drawtext simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1249
diff changeset
   589
	if(len < olen)
1259
f0c900871c87 final version -- Gottox verified it using the test driver
arg@suckless.org
parents: 1258
diff changeset
   590
		for(i = len; i && i > len - 3; buf[--i] = '.');
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   591
	XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   592
	if(dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   593
		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
   594
	else
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   595
		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
   596
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   597
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   598
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   599
enternotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   600
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   601
	XCrossingEvent *ev = &e->xcrossing;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   602
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   603
	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
   604
		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
   605
	if((c = getclient(ev->window)))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   606
		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
   607
	else
1079
ba7486659f1d got initial Xinerama support working, though there is a lot work todo
anselm@aab
parents: 1078
diff changeset
   608
		focus(NULL);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   609
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   610
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   611
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   612
expose(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   613
	XExposeEvent *ev = &e->xexpose;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   614
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   615
	if(ev->count == 0 && (ev->window == barwin))
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   616
		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
   617
}
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
   618
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   619
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   620
focus(Client *c) {
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   621
	if(!c || !ISVISIBLE(c))
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   622
		for(c = stack; c && !ISVISIBLE(c); c = c->snext);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   623
	if(sel && sel != c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   624
		grabbuttons(sel, False);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   625
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   626
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   627
	if(c) {
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   628
		if(c->isurgent)
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   629
			clearurgent(c);
996
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);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   633
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   634
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   635
	}
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   636
	else
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   637
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
1254
d04ee4e2336d applied nsz's patches (many thanks!)
arg@suckless.org
parents: 1253
diff changeset
   638
	sel = c;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   639
	drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   640
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   641
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   642
void
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   643
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
   644
	XFocusChangeEvent *ev = &e->xfocus;
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   645
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   646
	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
   647
		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
   648
}
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   649
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   650
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   651
focusstack(const Arg *arg) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   652
	Client *c = NULL, *i;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   653
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   654
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   655
		return;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   656
	if (arg->i > 0) {
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   657
		for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   658
		if(!c)
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   659
			for(c = clients; c && !ISVISIBLE(c); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   660
	}
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   661
	else {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   662
		for(i = clients; i != sel; i = i->next)
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   663
			if(ISVISIBLE(i))
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   664
				c = i;
1268
fc7dd1b14093 removed trailing spaces reported by Soleen
Anselm R Garbe <garbeam@gmail.com>
parents: 1267
diff changeset
   665
		if(!c)
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   666
			for(; i; i = i->next)
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
   667
				if(ISVISIBLE(i))
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   668
					c = i;
996
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
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   671
		focus(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   672
		restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   673
	}
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
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   676
Client *
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   677
getclient(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   678
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   679
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   680
	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
   681
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   682
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   683
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   684
unsigned long
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   685
getcolor(const char *colstr) {
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   686
	Colormap cmap = DefaultColormap(dpy, screen);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   687
	XColor color;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   688
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   689
	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   690
		die("error, cannot allocate color '%s'\n", colstr);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   691
	return color.pixel;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   692
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   693
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   694
long
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   695
getstate(Window w) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   696
	int format, status;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   697
	long result = -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   698
	unsigned char *p = NULL;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   699
	unsigned long n, extra;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   700
	Atom real;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   701
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   702
	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
   703
			&real, &format, &n, &extra, (unsigned char **)&p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   704
	if(status != Success)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   705
		return -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   706
	if(n != 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   707
		result = *p;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   708
	XFree(p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   709
	return result;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   710
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   711
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   712
Bool
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   713
gettextprop(Window w, Atom atom, char *text, unsigned int size) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   714
	char **list = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   715
	int n;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   716
	XTextProperty name;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   717
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
   718
	if(!text || size == 0)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   719
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   720
	text[0] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   721
	XGetTextProperty(dpy, w, &name, atom);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   722
	if(!name.nitems)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   723
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   724
	if(name.encoding == XA_STRING)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   725
		strncpy(text, (char *)name.value, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   726
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   727
		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
   728
		&& n > 0 && *list) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   729
			strncpy(text, *list, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   730
			XFreeStringList(list);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   731
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   732
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   733
	text[size - 1] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   734
	XFree(name.value);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   735
	return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   736
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   737
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   738
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   739
grabbuttons(Client *c, Bool focused) {
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   740
	updatenumlockmask();
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   741
	{
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   742
		unsigned int i, j;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   743
		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   744
		XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   745
		if(focused) {
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   746
			for(i = 0; i < LENGTH(buttons); i++)
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   747
				if(buttons[i].click == ClkClientWin)
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   748
					for(j = 0; j < LENGTH(modifiers); j++)
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   749
						XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   750
		} else
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   751
			XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   752
			            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   753
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   754
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   755
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   756
void
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
   757
grabkeys(void) {
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   758
	updatenumlockmask();
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   759
	{ /* grab keys */
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   760
		unsigned int i, j;
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   761
		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   762
		KeyCode code;
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   763
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   764
		XUngrabKey(dpy, AnyKey, AnyModifier, root);
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   765
		for(i = 0; i < LENGTH(keys); i++) {
1352
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
   766
			if((code = XKeysymToKeycode(dpy, keys[i].keysym)))
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
   767
				for(j = 0; j < LENGTH(modifiers); j++)
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
   768
					XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
   769
						 True, GrabModeAsync, GrabModeAsync);
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   770
		}
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
	}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   772
}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
   773
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   774
void
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   775
initfont(const char *fontstr) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   776
	char *def, **missing;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   777
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   778
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   779
	missing = NULL;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   780
	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   781
	if(missing) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   782
		while(n--)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   783
			fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   784
		XFreeStringList(missing);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   785
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   786
	if(dc.font.set) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   787
		XFontSetExtents *font_extents;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   788
		XFontStruct **xfonts;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   789
		char **font_names;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   790
		dc.font.ascent = dc.font.descent = 0;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   791
		font_extents = XExtentsOfFontSet(dc.font.set);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   792
		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   793
		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
   794
			dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
   795
			dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   796
			xfonts++;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   797
		}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   798
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   799
	else {
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   800
		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   801
		&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   802
			die("error, cannot load font: '%s'\n", fontstr);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   803
		dc.font.ascent = dc.font.xfont->ascent;
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   804
		dc.font.descent = dc.font.xfont->descent;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   805
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   806
	dc.font.height = dc.font.ascent + dc.font.descent;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   807
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   808
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   809
Bool
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   810
isprotodel(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   811
	int i, n;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   812
	Atom *protocols;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   813
	Bool ret = False;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   814
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   815
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   816
		for(i = 0; !ret && i < n; i++)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   817
			if(protocols[i] == wmatom[WMDelete])
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   818
				ret = True;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   819
		XFree(protocols);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   820
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   821
	return ret;
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
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   824
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   825
keypress(XEvent *e) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   826
	unsigned int i;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   827
	KeySym keysym;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   828
	XKeyEvent *ev;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   829
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   830
	ev = &e->xkey;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   831
	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
   832
	for(i = 0; i < LENGTH(keys); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   833
		if(keysym == keys[i].keysym
1241
c93c552561b4 slight changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1240
diff changeset
   834
		   && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
c93c552561b4 slight changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1240
diff changeset
   835
		   && keys[i].func)
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   836
			keys[i].func(&(keys[i].arg));
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   837
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   838
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   839
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   840
killclient(const Arg *arg) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   841
	XEvent ev;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   842
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   843
	if(!sel)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   844
		return;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   845
	if(isprotodel(sel)) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   846
		ev.type = ClientMessage;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   847
		ev.xclient.window = sel->win;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   848
		ev.xclient.message_type = wmatom[WMProtocols];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   849
		ev.xclient.format = 32;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   850
		ev.xclient.data.l[0] = wmatom[WMDelete];
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   851
		ev.xclient.data.l[1] = CurrentTime;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   852
		XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   853
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   854
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   855
		XKillClient(dpy, sel->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   856
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   857
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   858
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   859
manage(Window w, XWindowAttributes *wa) {
1358
e4bcaca8e6ef using malloc() instead of calloc() and sticking to static initializer and struct assignment, not using *c = (Client){}; right now to avoid some ugly gcc warning, possibly a gcc bug since we are using -std=c99
Anselm R Garbe <garbeam@gmail.com>
parents: 1357
diff changeset
   860
	static Client cz;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   861
	Client *c, *t = NULL;
1333
5be4e277ed7c using None instead of 0 for trans
Anselm R Garbe <garbeam@gmail.com>
parents: 1332
diff changeset
   862
	Window trans = None;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   863
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   864
1358
e4bcaca8e6ef using malloc() instead of calloc() and sticking to static initializer and struct assignment, not using *c = (Client){}; right now to avoid some ugly gcc warning, possibly a gcc bug since we are using -std=c99
Anselm R Garbe <garbeam@gmail.com>
parents: 1357
diff changeset
   865
	if(!(c = malloc(sizeof(Client))))
e4bcaca8e6ef using malloc() instead of calloc() and sticking to static initializer and struct assignment, not using *c = (Client){}; right now to avoid some ugly gcc warning, possibly a gcc bug since we are using -std=c99
Anselm R Garbe <garbeam@gmail.com>
parents: 1357
diff changeset
   866
		die("fatal: could not malloc() %u bytes\n", sizeof(Client));
e4bcaca8e6ef using malloc() instead of calloc() and sticking to static initializer and struct assignment, not using *c = (Client){}; right now to avoid some ugly gcc warning, possibly a gcc bug since we are using -std=c99
Anselm R Garbe <garbeam@gmail.com>
parents: 1357
diff changeset
   867
	*c = cz;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   868
	c->win = w;
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   869
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
   870
	/* 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
   871
	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
   872
	c->y = wa->y;
1201
b66f5380fce3 removed Layout->isfloating
Anselm R Garbe <garbeam@gmail.com>
parents: 1200
diff changeset
   873
	c->w = wa->width;
b66f5380fce3 removed Layout->isfloating
Anselm R Garbe <garbeam@gmail.com>
parents: 1200
diff changeset
   874
	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
   875
	c->oldbw = wa->border_width;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   876
	if(c->w == sw && c->h == sh) {
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   877
		c->x = sx;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
   878
		c->y = sy;
1315
ce355cea9bb8 forcing fullscreen windows to bw=0, though most fullscreen apps are broken anyways
Anselm R Garbe <garbeam@gmail.com>
parents: 1314
diff changeset
   879
		c->bw = 0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   880
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   881
	else {
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   882
		if(c->x + WIDTH(c) > sx + sw)
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   883
			c->x = sx + sw - WIDTH(c);
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   884
		if(c->y + HEIGHT(c) > sy + sh)
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   885
			c->y = sy + sh - HEIGHT(c);
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
   886
		c->x = MAX(c->x, sx);
1284
14929bfb8738 restored y-coordinate fixing of client windows
Anselm R Garbe <garbeam@gmail.com>
parents: 1281
diff changeset
   887
		/* only fix client y-offset, if the client center might cover the bar */
14929bfb8738 restored y-coordinate fixing of client windows
Anselm R Garbe <garbeam@gmail.com>
parents: 1281
diff changeset
   888
		c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? 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
   889
		c->bw = borderpx;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   890
	}
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
   891
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
   892
	wc.border_width = c->bw;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   893
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   894
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   895
	configure(c); /* propagates border_width, if size doesn't change */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   896
	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
   897
	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   898
	grabbuttons(c, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   899
	updatetitle(c);
1321
bca7a556aa03 fix of XGetTransientForHint in manage()
Premysl Hruby <dfenze@gmail.com>
parents: 1320
diff changeset
   900
	if(XGetTransientForHint(dpy, w, &trans))
1320
a63cb246f35c applied cleanup from M. Hurton and S. Nagy
Premysl Hruby <dfenze@gmail.com>
parents: 1319
diff changeset
   901
		t = getclient(trans);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   902
	if(t)
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
   903
		c->tags = t->tags;
1115
61f7a3e134e9 fixed applyrules bug
Anselm R Garbe <garbeam@gmail.com>
parents: 1114
diff changeset
   904
	else
61f7a3e134e9 fixed applyrules bug
Anselm R Garbe <garbeam@gmail.com>
parents: 1114
diff changeset
   905
		applyrules(c);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   906
	if(!c->isfloating)
1333
5be4e277ed7c using None instead of 0 for trans
Anselm R Garbe <garbeam@gmail.com>
parents: 1332
diff changeset
   907
		c->isfloating = trans != None || c->isfixed;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
   908
	if(c->isfloating)
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
   909
		XRaiseWindow(dpy, c->win);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   910
	attach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   911
	attachstack(c);
1297
20481c9d647c does this fix anything?
Anselm R Garbe <garbeam@gmail.com>
parents: 1295
diff changeset
   912
	XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   913
	XMapWindow(dpy, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   914
	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
   915
	arrange();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   916
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   917
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   918
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   919
mappingnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   920
	XMappingEvent *ev = &e->xmapping;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   921
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   922
	XRefreshKeyboardMapping(ev);
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
   923
	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
   924
		grabkeys();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   925
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   926
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   927
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   928
maprequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   929
	static XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   930
	XMapRequestEvent *ev = &e->xmaprequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   931
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   932
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   933
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   934
	if(wa.override_redirect)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   935
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   936
	if(!getclient(ev->window))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   937
		manage(ev->window, &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   938
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   939
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   940
void
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   941
monocle(void) {
1376
9b2b792dce12 implemented noborder for 1 client in the view
a@null
parents: 1374
diff changeset
   942
	unsigned int n;
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   943
	Client *c;
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   944
1376
9b2b792dce12 implemented noborder for 1 client in the view
a@null
parents: 1374
diff changeset
   945
	for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++);
9b2b792dce12 implemented noborder for 1 client in the view
a@null
parents: 1374
diff changeset
   946
	for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
   947
		adjustborder(c, n == 1 ? 0 : borderpx);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
   948
		resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
1376
9b2b792dce12 implemented noborder for 1 client in the view
a@null
parents: 1374
diff changeset
   949
	}
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   950
}
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   951
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   952
void
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   953
movemouse(const Arg *arg) {
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
   954
	int x, y, ocx, ocy, di, nx, ny;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   955
	unsigned int dui;
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   956
	Client *c;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   957
	Window dummy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   958
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   959
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   960
	if(!(c = sel))
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
   961
		return;
1235
13f86ee1a8e6 applied yiyus domax patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1234
diff changeset
   962
	restack();
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
   963
	ocx = c->x;
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
   964
	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
   965
	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
   966
	None, cursor[CurMove], CurrentTime) != GrabSuccess)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   967
		return;
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
   968
	XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
   969
	if(usegrab)
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
   970
		XGrabServer(dpy);
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
   971
	do {
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
   972
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   973
		switch (ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   974
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   975
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   976
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   977
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   978
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   979
		case MotionNotify:
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
   980
			nx = ocx + (ev.xmotion.x - x);
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
   981
			ny = ocy + (ev.xmotion.y - y);
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   982
			if(snap && nx >= wx && nx <= wx + ww
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   983
			        && ny >= wy && ny <= wy + wh) {
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   984
				if(abs(wx - nx) < snap)
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   985
					nx = wx;
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   986
				else if(abs((wx + ww) - (nx + WIDTH(c))) < snap)
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   987
					nx = wx + ww - WIDTH(c);
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   988
				if(abs(wy - ny) < snap)
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   989
					ny = wy;
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   990
				else if(abs((wy + wh) - (ny + HEIGHT(c))) < snap)
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
   991
					ny = wy + wh - HEIGHT(c);
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   992
				if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   993
					togglefloating(NULL);
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
   994
			}
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
   995
			if(!lt[sellt]->arrange || c->isfloating)
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
   996
				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
   997
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   998
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   999
	}
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1000
	while(ev.type != ButtonRelease);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1001
	if(usegrab)
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1002
		XUngrabServer(dpy);
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1003
	XUngrabPointer(dpy, CurrentTime);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1004
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1005
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1006
Client *
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1007
nexttiled(Client *c) {
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
  1008
	for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1009
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1010
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1011
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1012
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1013
propertynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1014
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1015
	Window trans;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1016
	XPropertyEvent *ev = &e->xproperty;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1017
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1018
	if((ev->window == root) && (ev->atom = XA_WM_NAME))
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1019
		updatestatus();
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1020
	else if(ev->state == PropertyDelete)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1021
		return; /* ignore */
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1022
	else if((c = getclient(ev->window))) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1023
		switch (ev->atom) {
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1024
		default: break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1025
		case XA_WM_TRANSIENT_FOR:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1026
			XGetTransientForHint(dpy, c->win, &trans);
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1027
			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
  1028
				arrange();
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1029
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1030
		case XA_WM_NORMAL_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1031
			updatesizehints(c);
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1032
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1033
		case XA_WM_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1034
			updatewmhints(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1035
			drawbar();
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1036
			break;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1037
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1038
		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
  1039
			updatetitle(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1040
			if(c == sel)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1041
				drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1042
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1043
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1044
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1045
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1046
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1047
quit(const Arg *arg) {
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1048
	running = False;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1049
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1050
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1051
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1052
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
  1053
	XWindowChanges wc;
1090
09f1bf0e12ee resize handles offscreen issues
Anselm R Garbe <garbeam@gmail.com>
parents: 1089
diff changeset
  1054
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1055
	if(sizehints) {
1342
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1056
		/* see last two sentences in ICCCM 4.1.2.3 */
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1057
		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1058
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1059
		/* set minimum possible */
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1060
		w = MAX(1, w);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1061
		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
  1062
1342
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1063
		if(!baseismin) { /* temporarily remove base dimensions */
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1064
			w -= c->basew;
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1065
			h -= c->baseh;
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1066
		}
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1067
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1068
		/* adjust for aspect limits */
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1069
		if(c->mina > 0 && c->maxa > 0) {
1353
8a9a1dbeff49 applied Peter Hartlichs aspect revert fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1352
diff changeset
  1070
			if(c->maxa < (float)w / h)
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1071
				w = h * c->maxa;
1353
8a9a1dbeff49 applied Peter Hartlichs aspect revert fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1352
diff changeset
  1072
			else if(c->mina < (float)h / w)
1343
f4707b7bd3a2 reverted some resize() changes, reverted setlocale removal
Anselm R Garbe <garbeam@gmail.com>
parents: 1342
diff changeset
  1073
				h = w * c->mina;
1342
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1074
		}
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1075
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1076
		if(baseismin) { /* increment calculation requires this */
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1077
			w -= c->basew;
a2f37186527c applied Peter Hartlich's patch regarding aspect calculation with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1341
diff changeset
  1078
			h -= c->baseh;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1079
		}
1032
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1080
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1081
		/* 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
  1082
		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
  1083
			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
  1084
		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
  1085
			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
  1086
08bc44d1f985 applied Eric Mertens patch to mainstream dwm, however this needs testing
Anselm R. Garbe <garbeam@gmail.com>
parents: 1031
diff changeset
  1087
		/* 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
  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
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1091
		w = MAX(w, c->minw);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1092
		h = MAX(h, c->minh);
1285
226e616bc123 tiled layout resizehints should be respected by default
Anselm R Garbe <garbeam@gmail.com>
parents: 1284
diff changeset
  1093
226e616bc123 tiled layout resizehints should be respected by default
Anselm R Garbe <garbeam@gmail.com>
parents: 1284
diff changeset
  1094
		if(c->maxw)
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1095
			w = MIN(w, c->maxw);
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1096
1285
226e616bc123 tiled layout resizehints should be respected by default
Anselm R Garbe <garbeam@gmail.com>
parents: 1284
diff changeset
  1097
		if(c->maxh)
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1098
			h = MIN(h, c->maxh);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1099
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1100
	if(w <= 0 || h <= 0)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1101
		return;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1102
	if(x > sx + sw)
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
  1103
		x = sw - WIDTH(c);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1104
	if(y > sy + sh)
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
  1105
		y = sh - HEIGHT(c);
1152
960659820908 renamed c->border into c->bw, fixed monocle to subtract c->bw from each h/w value
Anselm R Garbe <garbeam@gmail.com>
parents: 1151
diff changeset
  1106
	if(x + w + 2 * c->bw < sx)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1107
		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
  1108
	if(y + h + 2 * c->bw < sy)
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1109
		y = sy;
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1110
	if(h < bh)
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1111
		h = bh;
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1112
	if(w < bh)
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1113
		w = bh;
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
  1114
	if(c->x != x || c->y != y || c->w != w || c->h != h) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1115
		c->x = wc.x = x;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1116
		c->y = wc.y = y;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1117
		c->w = wc.width = w;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1118
		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
  1119
		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
  1120
		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
  1121
				CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1122
		configure(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1123
		XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1124
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1125
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1126
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1127
void
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
  1128
resizemouse(const Arg *arg) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1129
	int ocx, ocy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1130
	int nw, nh;
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
  1131
	Client *c;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1132
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1133
1270
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
  1134
	if(!(c = sel))
262ee84a2fdb integrated yiyus mouse.diff (though the bar click handling is slightly broken, I'm to tired to debug it now, yiyus could you please?)
Anselm R Garbe <garbeam@gmail.com>
parents: 1269
diff changeset
  1135
		return;
1235
13f86ee1a8e6 applied yiyus domax patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1234
diff changeset
  1136
	restack();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1137
	ocx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1138
	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
  1139
	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
  1140
	None, cursor[CurResize], CurrentTime) != GrabSuccess)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1141
		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
  1142
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1143
	if(usegrab)
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1144
		XGrabServer(dpy);
1335
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1145
	do {
1337
c4ecef7983b8 Martin Hurtons typo fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1336
diff changeset
  1146
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1147
		switch(ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1148
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1149
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1150
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1151
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1152
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1153
		case MotionNotify:
1380
add6eb26ebaa spotted missing spaces
a@null
parents: 1379
diff changeset
  1154
			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
add6eb26ebaa spotted missing spaces
a@null
parents: 1379
diff changeset
  1155
			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
  1156
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
  1157
			if(snap && nw >= wx && nw <= wx + ww
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
  1158
			        && nh >= wy && nh <= wy + wh) {
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1159
				if(!c->isfloating && lt[sellt]->arrange
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
  1160
				   && (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
  1161
					togglefloating(NULL);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1162
			}
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1163
			if(!lt[sellt]->arrange || c->isfloating)
1081
2345b08ec46b applied dwm-4.8-snaptileds.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1080
diff changeset
  1164
				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
  1165
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1166
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1167
	}
1335
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1168
	while(ev.type != ButtonRelease);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1169
	if(usegrab)
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1170
		XUngrabServer(dpy);
1335
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1171
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1172
	XUngrabPointer(dpy, CurrentTime);
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1173
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1174
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1175
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1176
void
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1177
restack(void) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1178
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1179
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1180
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1181
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1182
	drawbar();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1183
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1184
		return;
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1185
	if(sel->isfloating || !lt[sellt]->arrange)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1186
		XRaiseWindow(dpy, sel->win);
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1187
	if(lt[sellt]->arrange) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1188
		wc.stack_mode = Below;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1189
		wc.sibling = barwin;
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1190
		for(c = stack; c; c = c->snext)
1294
ef082062dccc made arrange again like it was once
Anselm R Garbe <garbeam@gmail.com>
parents: 1293
diff changeset
  1191
			if(!c->isfloating && ISVISIBLE(c)) {
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1192
				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1193
				wc.sibling = c->win;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1194
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1195
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1196
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1197
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1198
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1199
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1200
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1201
run(void) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1202
	XEvent ev;
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1203
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1204
	/* main event loop */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1205
	XSync(dpy, False);
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1206
	while(running && !XNextEvent(dpy, &ev)) {
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1207
		if(handler[ev.type])
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1208
			(handler[ev.type])(&ev); /* call handler */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1209
	}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1210
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
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
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1213
scan(void) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1214
	unsigned int i, num;
1330
06677766e7aa applied Martin Hurton's scan() patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1329
diff changeset
  1215
	Window d1, d2, *wins = NULL;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1216
	XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1217
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1218
	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
  1219
		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
  1220
			if(!XGetWindowAttributes(dpy, wins[i], &wa)
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1221
			|| 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
  1222
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1223
			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
  1224
				manage(wins[i], &wa);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1225
		}
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1226
		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
  1227
			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
  1228
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1229
			if(XGetTransientForHint(dpy, wins[i], &d1)
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1230
			&& (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
  1231
				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
  1232
		}
1330
06677766e7aa applied Martin Hurton's scan() patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1329
diff changeset
  1233
		if(wins)
06677766e7aa applied Martin Hurton's scan() patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1329
diff changeset
  1234
			XFree(wins);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1235
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1236
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1237
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1238
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1239
setclientstate(Client *c, long state) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1240
	long data[] = {state, None};
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1241
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1242
	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1243
			PropModeReplace, (unsigned char *)data, 2);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1244
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1245
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1246
void
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1247
setlayout(const Arg *arg) {
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
  1248
	if(!arg || !arg->v || arg->v != lt[sellt])
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
  1249
		sellt ^= 1;
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
  1250
	if(arg && arg->v)
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1251
		lt[sellt] = (Layout *)arg->v;
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1252
	if(sel)
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1253
		arrange();
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1254
	else
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1255
		drawbar();
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1256
}
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1257
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1258
/* arg > 1.0 will set mfact absolutly */
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1259
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1260
setmfact(const Arg *arg) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1261
	float f;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1262
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1263
	if(!arg || !lt[sellt]->arrange)
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1264
		return;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1265
	f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1266
	if(f < 0.1 || f > 0.9)
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1267
		return;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1268
	mfact = f;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1269
	arrange();
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1270
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1271
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1272
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1273
setup(void) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1274
	unsigned int i;
1257
cd74054c01b0 applied nsz' textnw patch thank you
arg@suckless.org
parents: 1256
diff changeset
  1275
	int w;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1276
	XSetWindowAttributes wa;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1277
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1278
	/* init screen */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1279
	screen = DefaultScreen(dpy);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1280
	root = RootWindow(dpy, screen);
1275
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1281
	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
  1282
	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
  1283
	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
  1284
	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
  1285
	sh = DisplayHeight(dpy, screen);
1275
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1286
	bh = dc.h = dc.font.height + 2;
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1287
	lt[0] = &layouts[0];
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1288
	lt[1] = &layouts[1 % LENGTH(layouts)];
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1289
	updategeom();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1290
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1291
	/* init atoms */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1292
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1293
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1294
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1295
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1296
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1297
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1298
	/* init cursors */
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1299
	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
  1300
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1301
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1302
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1303
	/* init appearance */
1275
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1304
	dc.norm[ColBorder] = getcolor(normbordercolor);
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1305
	dc.norm[ColBG] = getcolor(normbgcolor);
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1306
	dc.norm[ColFG] = getcolor(normfgcolor);
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1307
	dc.sel[ColBorder] = getcolor(selbordercolor);
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1308
	dc.sel[ColBG] = getcolor(selbgcolor);
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1309
	dc.sel[ColFG] = getcolor(selfgcolor);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1310
	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
  1311
	dc.gc = XCreateGC(dpy, root, 0, 0);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1312
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1313
	if(!dc.font.set)
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1314
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1315
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1316
	/* 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
  1317
	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
  1318
		w = TEXTW(layouts[i].symbol);
1178
e0095dbfc0af applied Ph's MIN/MAX patch, nice work!
anselm@anselm1
parents: 1177
diff changeset
  1319
		blw = MAX(blw, w);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1320
	}
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
  1321
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1322
	wa.override_redirect = 1;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1323
	wa.background_pixmap = ParentRelative;
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1324
	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
  1325
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
  1326
	barwin = XCreateWindow(dpy, root, wx, by, ww, bh, 0, DefaultDepth(dpy, screen),
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1327
			CopyFromParent, DefaultVisual(dpy, screen),
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1328
			CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1329
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1330
	XMapRaised(dpy, barwin);
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1331
	updatestatus();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1332
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1333
	/* EWMH support per view */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1334
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1335
			PropModeReplace, (unsigned char *) netatom, NetLast);
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1336
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1337
	/* select for events */
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
  1338
	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1339
			|EnterWindowMask|LeaveWindowMask|StructureNotifyMask
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1340
			|PropertyChangeMask;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1341
	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1342
	XSelectInput(dpy, root, wa.event_mask);
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
  1343
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1344
	grabkeys();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1345
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1346
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1347
void
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
  1348
showhide(Client *c, unsigned int ntiled) {
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1349
	if(!c)
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1350
		return;
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1351
	if(ISVISIBLE(c)) { /* show clients top down */
1383
85a78d8afa0f fixed an issue reported by Nibble, also fixed s/2008/2009/
a@null
parents: 1381
diff changeset
  1352
		if(c->isfloating || ntiled > 1) /* avoid unnecessary border reverts */
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
  1353
			adjustborder(c, borderpx);
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1354
		XMoveWindow(dpy, c->win, c->x, c->y);
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1355
		if(!lt[sellt]->arrange || c->isfloating)
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1356
			resize(c, c->x, c->y, c->w, c->h, True);
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
  1357
		showhide(c->snext, ntiled);
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1358
	}
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1359
	else { /* hide clients bottom up */
1381
8b7836a471f8 avoid reverting the border if it's not necessary (avoids some flashing on view())
a@null
parents: 1380
diff changeset
  1360
		showhide(c->snext, ntiled);
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1361
		XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1362
	}
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1363
}
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1364
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1365
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1366
void
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1367
sigchld(int signal) {
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1368
	while(0 < waitpid(-1, NULL, WNOHANG));
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1369
}
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1370
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1371
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1372
spawn(const Arg *arg) {
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1373
	signal(SIGCHLD, sigchld);
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
  1374
	if(fork() == 0) {
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1375
		if(dpy)
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1376
			close(ConnectionNumber(dpy));
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1377
		setsid();
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1378
		execvp(((char **)arg->v)[0], (char **)arg->v);
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1379
		fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1380
		perror(" failed");
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1381
		exit(0);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1382
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1383
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1384
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1385
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1386
tag(const Arg *arg) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1387
	if(sel && arg->ui & TAGMASK) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1388
		sel->tags = arg->ui & TAGMASK;
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1389
		arrange();
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1390
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1391
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1392
1257
cd74054c01b0 applied nsz' textnw patch thank you
arg@suckless.org
parents: 1256
diff changeset
  1393
int
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1394
textnw(const char *text, unsigned int len) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1395
	XRectangle r;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1396
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1397
	if(dc.font.set) {
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1398
		XmbTextExtents(dc.font.set, text, len, NULL, &r);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1399
		return r.width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1400
	}
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1401
	return XTextWidth(dc.font.xfont, text, len);
996
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
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1404
void
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1405
tile(void) {
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1406
	int x, y, h, w, mw;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1407
	unsigned int i, n;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1408
	Client *c;
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1409
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1410
	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
  1411
	if(n == 0)
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1412
		return;
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1413
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1414
	/* master */
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1415
	c = nexttiled(clients);
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1416
	mw = mfact * ww;
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
  1417
	adjustborder(c, n == 1 ? 0 : borderpx);
1361
41678fc29f2a several changes towards 5.3, XINERAMA is disabled by default, introduced usegrab Bool for grabbing the server during mouse-based resizals/movements (disabled by default), continued debugging tile() with resizehints == True and a lot of terminals supporting resizehints, still no optimal solution, I need to think about it, considering recursive algorithm for the space optimization
Anselm R Garbe <garbeam@gmail.com>
parents: 1360
diff changeset
  1418
	resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1419
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1420
	if(--n == 0)
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1421
		return;
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1422
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1423
	/* tile stack */
1252
d4528eea6e0d fixed the tile() issue with xpdf
Anselm R Garbe <garbeam@gmail.com>
parents: 1251
diff changeset
  1424
	x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : wx + mw;
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1425
	y = wy;
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1426
	w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw;
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1427
	h = wh / n;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1428
	if(h < bh)
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1429
		h = wh;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1430
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1431
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1379
ef09cf3eee26 reverting some border patches
a@null
parents: 1378
diff changeset
  1432
		adjustborder(c, borderpx);
1363
4004d6116035 added Neale Pickett's spawn patch, thanks Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1362
diff changeset
  1433
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
4004d6116035 added Neale Pickett's spawn patch, thanks Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1362
diff changeset
  1434
		       ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
1238
70a2c5f7c716 simplified tile()
Anselm R Garbe <garbeam@gmail.com>
parents: 1237
diff changeset
  1435
		if(h != wh)
1360
dc076b2d28d7 removed NOBORDER(broken and badly used), introduce WIDTH/HEIGHT macros for computing client size with border added, fixes bug announced by sergey_m
Premysl Hruby <dfenze@gmail.com>
parents: 1358
diff changeset
  1436
			y = c->y + HEIGHT(c);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1437
	}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1438
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1439
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1440
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1441
togglebar(const Arg *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
  1442
	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
  1443
	updategeom();
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1444
	updatebar();
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1445
	arrange();
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1446
}
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1447
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1448
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1449
togglefloating(const Arg *arg) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1450
	if(!sel)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1451
		return;
1244
c8bd07e7d006 applied yiyus tip patch from tue
Anselm R Garbe <garbeam@gmail.com>
parents: 1243
diff changeset
  1452
	sel->isfloating = !sel->isfloating || sel->isfixed;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1453
	if(sel->isfloating)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1454
		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
  1455
	arrange();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1456
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1457
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1458
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1459
toggletag(const Arg *arg) {
1338
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1460
	unsigned int mask;
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1461
1338
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1462
	if (!sel)
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1463
		return;
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1464
	
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1465
	mask = sel->tags ^ (arg->ui & TAGMASK);
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1466
	if(sel && mask) {
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1467
		sel->tags = mask;
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1468
		arrange();
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1469
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1470
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1471
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1472
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1473
toggleview(const Arg *arg) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1474
	unsigned int mask = tagset[seltags] ^ (arg->ui & TAGMASK);
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1475
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1476
	if(mask) {
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1477
		tagset[seltags] = mask;
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1478
		arrange();
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1479
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1480
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1481
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1482
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1483
unmanage(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1484
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1485
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
  1486
	wc.border_width = c->oldbw;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1487
	/* The server grab construct avoids race conditions. */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1488
	XGrabServer(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1489
	XSetErrorHandler(xerrordummy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1490
	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1491
	detach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1492
	detachstack(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1493
	if(sel == c)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1494
		focus(NULL);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1495
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1496
	setclientstate(c, WithdrawnState);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1497
	free(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1498
	XSync(dpy, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1499
	XSetErrorHandler(xerror);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1500
	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
  1501
	arrange();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1502
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1503
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1504
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1505
unmapnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1506
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1507
	XUnmapEvent *ev = &e->xunmap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1508
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1509
	if((c = getclient(ev->window)))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1510
		unmanage(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1511
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1512
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1513
void
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1514
updatebar(void) {
1136
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1515
	if(dc.drawable != 0)
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1516
		XFreePixmap(dpy, dc.drawable);
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
  1517
	dc.drawable = XCreatePixmap(dpy, root, ww, bh, DefaultDepth(dpy, screen));
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
  1518
	XMoveResizeWindow(dpy, barwin, wx, by, ww, bh);
1136
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1519
}
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1520
19de7b521826 added updatebarpos()
Anselm R Garbe <garbeam@gmail.com>
parents: 1135
diff changeset
  1521
void
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1522
updategeom(void) {
1254
d04ee4e2336d applied nsz's patches (many thanks!)
arg@suckless.org
parents: 1253
diff changeset
  1523
#ifdef XINERAMA
1312
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1524
	int n, i = 0;
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
  1525
	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
  1526
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1527
	/* window area geometry */
1314
f8c445284353 potential crash fix if xinerama behaves broken, though I doubt it
Anselm R Garbe <garbeam@gmail.com>
parents: 1312
diff changeset
  1528
	if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { 
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1529
		if(n > 1) {
1312
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1530
			int di, x, y;
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1531
			unsigned int dui;
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1532
			Window dummy;
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1533
			if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1534
				for(i = 0; i < n; i++)
1312
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1535
					if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1536
						break;
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1537
		}
1312
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1538
		wx = info[i].x_org;
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1539
		wy = showbar && topbar ?  info[i].y_org + bh : info[i].y_org;
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1540
		ww = info[i].width;
95b9bfa84b57 local use of xidx is useless, got rid of it, falling back to screen 0 if pointer query fails for whatever reason
Anselm R Garbe <garbeam@gmail.com>
parents: 1311
diff changeset
  1541
		wh = showbar ? info[i].height - bh : info[i].height;
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
  1542
		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
  1543
	}
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
  1544
	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
  1545
#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
  1546
	{
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
  1547
		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
  1548
		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
  1549
		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
  1550
		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
  1551
	}
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
  1552
1240
3a7c590338b3 removed bx and bw, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1239
diff changeset
  1553
	/* bar position */
1223
cd9fd0986555 some minor fixes
anselm@anselm1
parents: 1222
diff changeset
  1554
	by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1555
}
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1556
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1557
void
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1558
updatenumlockmask(void) {
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1559
	unsigned int i, j;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1560
	XModifierKeymap *modmap;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1561
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1562
	numlockmask = 0;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1563
	modmap = XGetModifierMapping(dpy);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1564
	for(i = 0; i < 8; i++)
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1565
		for(j = 0; j < modmap->max_keypermod; j++)
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1566
			if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1567
				numlockmask = (1 << i);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1568
	XFreeModifiermap(modmap);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1569
}
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1570
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1571
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1572
updatesizehints(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1573
	long msize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1574
	XSizeHints size;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1575
1357
33591b7c6bf7 applied XGetWMNormalHints fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1356
diff changeset
  1576
	if(!XGetWMNormalHints(dpy, c->win, &size, &msize))
33591b7c6bf7 applied XGetWMNormalHints fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1356
diff changeset
  1577
		/* size is uninitialized, ensure that size.flags aren't used */
33591b7c6bf7 applied XGetWMNormalHints fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1356
diff changeset
  1578
		size.flags = PSize; 
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1579
	if(size.flags & PBaseSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1580
		c->basew = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1581
		c->baseh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1582
	}
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1583
	else if(size.flags & PMinSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1584
		c->basew = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1585
		c->baseh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1586
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1587
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1588
		c->basew = c->baseh = 0;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1589
	if(size.flags & PResizeInc) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1590
		c->incw = size.width_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1591
		c->inch = size.height_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1592
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1593
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1594
		c->incw = c->inch = 0;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1595
	if(size.flags & PMaxSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1596
		c->maxw = size.max_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1597
		c->maxh = size.max_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1598
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1599
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1600
		c->maxw = c->maxh = 0;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1601
	if(size.flags & PMinSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1602
		c->minw = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1603
		c->minh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1604
	}
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1605
	else if(size.flags & PBaseSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1606
		c->minw = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1607
		c->minh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1608
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1609
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1610
		c->minw = c->minh = 0;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1611
	if(size.flags & PAspect) {
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1612
		c->mina = (float)size.min_aspect.y / (float)size.min_aspect.x;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1613
		c->maxa = (float)size.max_aspect.x / (float)size.max_aspect.y;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1614
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1615
	else
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1616
		c->maxa = c->mina = 0.0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1617
	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
1354
dced80b409d8 applied Martin Hurton's checkotherwm simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1353
diff changeset
  1618
	             && c->maxw == c->minw && c->maxh == c->minh);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1619
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1620
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1621
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1622
updatetitle(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1623
	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
1345
169467e68992 WM_NAME is builtin atom
Premysl Hruby <dfenze@gmail.com>
parents: 1344
diff changeset
  1624
		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1625
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1626
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1627
void
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1628
updatestatus() {
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1629
	if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1630
		strcpy(stext, "dwm-"VERSION);
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1631
	drawbar();
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1632
}
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1633
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1634
void
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1635
updatewmhints(Client *c) {
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1636
	XWMHints *wmh;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1637
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1638
	if((wmh = XGetWMHints(dpy, c->win))) {
1369
79bf47074a49 applied yiyus fix
arg@localhost.localdomain
parents: 1366
diff changeset
  1639
		if(c == sel && wmh->flags & XUrgencyHint) {
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  1640
			wmh->flags &= ~XUrgencyHint;
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  1641
			XSetWMHints(dpy, c->win, wmh);
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  1642
		}
1122
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1643
		else
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  1644
			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  1645
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1646
		XFree(wmh);
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1647
	}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1648
}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  1649
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1650
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1651
view(const Arg *arg) {
1327
920833e10274 applied Martin Hurton's view() simplification, not checking arg
Anselm R Garbe <garbeam@gmail.com>
parents: 1326
diff changeset
  1652
	if((arg->ui & TAGMASK) == tagset[seltags])
1304
ef3327d0517a minor fix to view()
Anselm R Garbe <garbeam@gmail.com>
parents: 1303
diff changeset
  1653
		return;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1654
	seltags ^= 1; /* toggle sel tagset */
1327
920833e10274 applied Martin Hurton's view() simplification, not checking arg
Anselm R Garbe <garbeam@gmail.com>
parents: 1326
diff changeset
  1655
	if(arg->ui & TAGMASK)
1319
fb29ceb5932a fixes using arg->i instead of arg->ui
Premysl Hruby <dfenze@gmail.com>
parents: 1318
diff changeset
  1656
		tagset[seltags] = arg->ui & TAGMASK;
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1657
	arrange();
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1658
}
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  1659
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1660
/* 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
  1661
 * 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
  1662
 * 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
  1663
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1664
xerror(Display *dpy, XErrorEvent *ee) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1665
	if(ee->error_code == BadWindow
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1666
	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1667
	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1668
	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1669
	|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1670
	|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
1186
48ffaf800504 applied JUCE patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1185
diff changeset
  1671
	|| (ee->request_code == X_GrabButton && ee->error_code == BadAccess)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1672
	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1673
	|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1674
		return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1675
	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
  1676
			ee->request_code, ee->error_code);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1677
	return xerrorxlib(dpy, ee); /* may call exit */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1678
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1679
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1680
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
  1681
xerrordummy(Display *dpy, XErrorEvent *ee) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1682
	return 0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1683
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1684
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1685
/* Startup Error handler to check if another window manager
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1686
 * 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
  1687
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
  1688
xerrorstart(Display *dpy, XErrorEvent *ee) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1689
	otherwm = True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1690
	return -1;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1691
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1692
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1693
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1694
zoom(const Arg *arg) {
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1695
	Client *c = sel;
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1696
1290
06d46acfe156 applied Gottox patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1289
diff changeset
  1697
	if(!lt[sellt]->arrange || lt[sellt]->arrange == monocle || (sel && sel->isfloating))
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1698
		return;
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1699
	if(c == nexttiled(clients))
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1700
		if(!c || !(c = nexttiled(c->next)))
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1701
			return;
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1702
	detach(c);
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1703
	attach(c);
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  1704
	focus(c);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1705
	arrange();
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1706
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1707
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
  1708
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1709
main(int argc, char *argv[]) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1710
	if(argc == 2 && !strcmp("-v", argv[1]))
1383
85a78d8afa0f fixed an issue reported by Nibble, also fixed s/2008/2009/
a@null
parents: 1381
diff changeset
  1711
		die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n");
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1712
	else if(argc != 1)
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
  1713
		die("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
  1714
1343
f4707b7bd3a2 reverted some resize() changes, reverted setlocale removal
Anselm R Garbe <garbeam@gmail.com>
parents: 1342
diff changeset
  1715
	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
1302
af0f92dd5ab6 locale update
Anselm R Garbe <garbeam@gmail.com>
parents: 1299
diff changeset
  1716
		fprintf(stderr, "warning: no locale support\n");
af0f92dd5ab6 locale update
Anselm R Garbe <garbeam@gmail.com>
parents: 1299
diff changeset
  1717
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1718
	if(!(dpy = XOpenDisplay(0)))
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
  1719
		die("dwm: cannot open display\n");
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1720
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1721
	checkotherwm();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1722
	setup();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1723
	scan();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1724
	run();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1725
	cleanup();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1726
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1727
	XCloseDisplay(dpy);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1728
	return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1729
}