dwm.c
author Stiletto <blasux@blasux.ru>
Sat, 25 Oct 2014 15:12:32 +0400
branchstil
changeset 1542 a699915c007f
parent 1541 16039d3a6270
permissions -rw-r--r--
Make automatic tag switching optional
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
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
    14
 * set the override_redirect flag.  Clients are organized in a linked client
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
    15
 * list on each monitor, the focus history is remembered through a stack list
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
    16
 * on each monitor. Each client contains a bit array to indicate the tags of a
1242
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>
1537
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
    31
#include <sys/mman.h>
1014
35461e0a4894 fixed inclusion order
arg@suckless.org
parents: 1008
diff changeset
    32
#include <sys/types.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    33
#include <sys/wait.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    34
#include <X11/cursorfont.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    35
#include <X11/keysym.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    36
#include <X11/Xatom.h>
1033
a8efbb301ef4 just making dwm.h saner
arg@suckless.org
parents: 1032
diff changeset
    37
#include <X11/Xlib.h>
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    38
#include <X11/Xproto.h>
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    39
#include <X11/Xutil.h>
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    40
#include <X11/Xft/Xft.h>
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    41
#include <pango/pango.h>
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    42
#include <pango/pangoxft.h>
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    43
#include <pango/pango-font.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
    44
#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
    45
#include <X11/extensions/Xinerama.h>
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
    46
#endif /* XINERAMA */
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    47
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    48
/* macros */
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    49
#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    50
#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    51
#define INTERSECT(x,y,w,h,m)    (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    52
                               * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
    53
#define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
1399
0decadd79fd5 several fixes through ISVISIBLE change (takes Monitor into account)
Anselm R Garbe <anselm@garbe.us>
parents: 1398
diff changeset
    54
#define LENGTH(X)               (sizeof X / sizeof X[0])
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    55
#ifndef MAX
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
    56
#define MAX(A, B)               ((A) > (B) ? (A) : (B))
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    57
#endif
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    58
#ifndef MIN
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
    59
#define MIN(A, B)               ((A) < (B) ? (A) : (B))
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    60
#endif
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
    61
#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
    62
#define WIDTH(X)                ((X)->w + 2 * (X)->bw)
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
    63
#define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
1463
ba3114b785a1 removed int cast in TAGMASK as suggested by nsz
Anselm R Garbe <garbeam@gmail.com>
parents: 1462
diff changeset
    64
#define TAGMASK                 ((1 << LENGTH(tags)) - 1)
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
    65
#define TEXTW(X)                (textnw(X, strlen(X), False) + dc.font.height)
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
    66
#define TEXTWM(X)               (textnw(X, strlen(X), True) + dc.font.height)
1059
98d06be63ce5 moved LENGTH to dwm.c, moved prevtags to dwm.c
arg@suckless.org
parents: 1058
diff changeset
    67
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
    68
/* 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
    69
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
    70
enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
    71
enum { NetSupported, NetWMName, NetWMState,
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    72
       NetWMFullscreen, NetActiveWindow, NetWMWindowType,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    73
       NetWMWindowTypeDialog, NetLast };     /* EWMH atoms */
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
    74
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
    75
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
    76
       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
    77
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
    78
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
    79
	int i;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    80
	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
    81
	float f;
1452
769fb14ae867 introducing const where it might make some sense
Anselm R Garbe <anselm@garbe.us>
parents: 1451
diff changeset
    82
	const void *v;
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
    83
} 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
    84
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
    85
typedef struct {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    86
	unsigned int click;
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    87
	unsigned int mask;
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
    88
	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
    89
	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
    90
	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
    91
} 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
    92
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
    93
typedef struct Monitor Monitor;
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
    94
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
    95
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
    96
	char name[256];
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
    97
	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
    98
	int x, y, w, h;
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
    99
	int oldx, oldy, oldw, oldh;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   100
	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
   101
	int bw, oldbw;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   102
	unsigned int tags;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   103
	Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
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
   104
	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
   105
	Client *snext;
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   106
	Monitor *mon;
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
   107
	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
   108
};
e6188cb17fa1 removed dwm.h, just include C-files 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 {
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   111
	int x, y, w, h;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   112
	unsigned long norm[ColLast];
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   113
	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
   114
	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
   115
	GC gc;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   116
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   117
	XftColor  xftnorm[ColLast];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   118
	XftColor  xftsel[ColLast];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   119
	XftDraw  *xftdrawable;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   120
	PangoContext *pgc;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   121
	PangoLayout  *plo;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   122
	PangoFontDescription *pfd;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   123
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
   124
	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
   125
		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
   126
		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
   127
		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
   128
	} 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
   129
} 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
   130
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   131
typedef struct {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   132
	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
   133
	KeySym keysym;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   134
	void (*func)(const Arg *);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   135
	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
   136
} 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
   137
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   138
typedef struct {
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   139
	const char *symbol;
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   140
	void (*arrange)(Monitor *);
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   141
} Layout;
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   142
1397
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
   143
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
   144
typedef struct {
1147
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   145
	const char *class;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   146
	const char *instance;
def76530f636 some changes towards 4.9
Anselm R Garbe <garbeam@gmail.com>
parents: 1145
diff changeset
   147
	const char *title;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   148
	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
   149
	Bool isfloating;
1458
e30739eebeed extended rule to apply monitors if set up accordingly
Anselm R Garbe <anselm@garbe.us>
parents: 1457
diff changeset
   150
	int monitor;
1036
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   151
} 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
   152
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   153
/* function declarations */
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   154
static void applyrules(Client *c);
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   155
static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   156
static void arrange(Monitor *m);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   157
static void arrangemon(Monitor *m);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   158
static void attach(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   159
static void attachstack(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   160
static void buttonpress(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   161
static void checkotherwm(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   162
static void cleanup(void);
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   163
static void cleanupmon(Monitor *mon);
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   164
static void clearurgent(Client *c);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   165
static void clientmessage(XEvent *e);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   166
static void configure(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   167
static void configurenotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   168
static void configurerequest(XEvent *e);
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   169
static Monitor *createmon(void);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   170
static void destroynotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   171
static void detach(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   172
static void detachstack(Client *c);
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   173
static void die(const char *errstr, ...);
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   174
static Monitor *dirtomon(int dir);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   175
static void drawbar(Monitor *m);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   176
static void drawbars(void);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   177
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   178
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert, Bool markup);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   179
static void enternotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   180
static void expose(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   181
static void focus(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   182
static void focusin(XEvent *e);
1437
bb00510a176a several bugfixes
Anselm R Garbe <anselm@garbe.us>
parents: 1436
diff changeset
   183
static void focusmon(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   184
static void focusstack(const Arg *arg);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   185
static unsigned long getcolor(const char *colstr, XftColor *color);
1450
b2d18a052137 some minor changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1449
diff changeset
   186
static Bool getrootptr(int *x, int *y);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   187
static long getstate(Window w);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   188
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
   189
static void grabbuttons(Client *c, Bool focused);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   190
static void grabkeys(void);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   191
static void incnmaster(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   192
static void initfont(const char *fontstr);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   193
static void keypress(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   194
static void killclient(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   195
static void manage(Window w, XWindowAttributes *wa);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   196
static void mappingnotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   197
static void maprequest(XEvent *e);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   198
static void monocle(Monitor *m);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   199
static void motionnotify(XEvent *e);
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
   200
static void movemouse(const Arg *arg);
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   201
static Client *nexttiled(Client *c);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   202
static void pop(Client *);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   203
static void propertynotify(XEvent *e);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   204
static void quit(const Arg *arg);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   205
static Monitor *recttomon(int x, int y, int w, int h);
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   206
static void resize(Client *c, int x, int y, int w, int h, Bool interact);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   207
static void resizeclient(Client *c, int x, int y, int w, int h);
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
   208
static void resizemouse(const Arg *arg);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   209
static void restack(Monitor *m);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   210
static void run(void);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   211
static void scan(void);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   212
static Bool sendevent(Client *c, Atom proto);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   213
static void sendmon(Client *c, Monitor *m);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   214
static void setclientstate(Client *c, long state);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   215
static void setfocus(Client *c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   216
static void setfullscreen(Client *c, Bool fullscreen);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
   217
static void setlayout(const Arg *arg);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   218
static void setmfact(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   219
static void setup(void);
1393
deaa276abac1 applied Marc Andre Tanners showhide patch, the removal of ntiled
Anselm R Garbe <garbeam@gmail.com>
parents: 1392
diff changeset
   220
static void showhide(Client *c);
1478
cf5bb4e72804 added merged patch of anydot and Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1477
diff changeset
   221
static void sigchld(int unused);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   222
static void spawn(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   223
static void tag(const Arg *arg);
1437
bb00510a176a several bugfixes
Anselm R Garbe <anselm@garbe.us>
parents: 1436
diff changeset
   224
static void tagmon(const Arg *arg);
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   225
static int textnw(const char *text, unsigned int len, Bool markup);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   226
static void tile(Monitor *);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   227
static void togglebar(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   228
static void togglefloating(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   229
static void toggletag(const Arg *arg);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   230
static void toggleview(const Arg *arg);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   231
static void unfocus(Client *c, Bool setfocus);
1487
430ebd3c0050 renaming isdestroyed into destroyed
Anselm R Garbe <garbeam@gmail.com>
parents: 1486
diff changeset
   232
static void unmanage(Client *c, Bool destroyed);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   233
static void unmapnotify(XEvent *e);
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   234
static Bool updategeom(void);
1404
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
   235
static void updatebarpos(Monitor *m);
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   236
static void updatebars(void);
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
   237
static void updatenumlockmask(void);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   238
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
   239
static void updatestatus(void);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   240
static void updatewindowtype(Client *c);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   241
static void updatetitle(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   242
static void updatewmhints(Client *c);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   243
static void view(const Arg *arg);
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   244
static Client *wintoclient(Window w);
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   245
static Monitor *wintomon(Window w);
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   246
static int xerror(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   247
static int xerrordummy(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   248
static int xerrorstart(Display *dpy, XErrorEvent *ee);
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   249
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
   250
e6188cb17fa1 removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
arg@suckless.org
parents: 1033
diff changeset
   251
/* variables */
1460
606761ddf6d6 mark broken clients as broken
anselm@x200s.config
parents: 1459
diff changeset
   252
static const char broken[] = "broken";
1542
a699915c007f Make automatic tag switching optional
Stiletto <blasux@blasux.ru>
parents: 1541
diff changeset
   253
static char stext[512];
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
   254
static int screen;
1458
e30739eebeed extended rule to apply monitors if set up accordingly
Anselm R Garbe <anselm@garbe.us>
parents: 1457
diff changeset
   255
static int sw, sh;           /* X display screen geometry width, height */
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   256
static int bh, blw = 0;      /* bar geometry */
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   257
static int (*xerrorxlib)(Display *, XErrorEvent *);
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   258
static unsigned int numlockmask = 0;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   259
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
   260
	[ButtonPress] = buttonpress,
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   261
	[ClientMessage] = clientmessage,
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
   262
	[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
   263
	[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
   264
	[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
   265
	[EnterNotify] = enternotify,
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   266
	[Expose] = expose,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   267
	[FocusIn] = focusin,
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   268
	[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
   269
	[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
   270
	[MapRequest] = maprequest,
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   271
	[MotionNotify] = motionnotify,
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
   272
	[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
   273
	[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
   274
};
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   275
static Atom wmatom[WMLast], netatom[NetLast];
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   276
static Bool running = True;
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   277
static Cursor cursor[CurLast];
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   278
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
   279
static DC dc;
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   280
static Monitor *mons = NULL, *selmon = NULL;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   281
static Window root;
1447
4fff5050c835 some cleanups
Anselm R Garbe <anselm@garbe.us>
parents: 1446
diff changeset
   282
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
   283
/* configuration, allows nested code to access above variables */
1532
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents: 1531
diff changeset
   284
#include "push.h"
1534
ff21639cb978 Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents: 1532
diff changeset
   285
#include "layouts/fibonacci.h"
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
   286
#include "config.h"
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
   287
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   288
struct Monitor {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   289
	char ltsymbol[16];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   290
	float mfact;
1541
16039d3a6270 Fix broken merge
Stiletto <blasux@blasux.ru>
parents: 1540
diff changeset
   291
	int nmaster;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   292
	int num;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   293
	int by;               /* bar geometry */
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   294
	int mx, my, mw, mh;   /* screen size */
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   295
	int wx, wy, ww, wh;   /* window area  */
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   296
	unsigned int seltags;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   297
	unsigned int sellt;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   298
	unsigned int tagset[2];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   299
	Bool showbar;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   300
	Bool topbar;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   301
	Client *clients;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   302
	Client *sel;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   303
	Client *stack;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   304
	Monitor *next;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   305
	Window barwin;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   306
	const Layout *lt[2];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   307
	int curtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   308
	int prevtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   309
	const Layout *lts[LENGTH(tags) + 1];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   310
	double mfacts[LENGTH(tags) + 1];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   311
	Bool showbars[LENGTH(tags) + 1];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   312
};
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   313
1532
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents: 1531
diff changeset
   314
#include "push.c"
1534
ff21639cb978 Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents: 1532
diff changeset
   315
#include "layouts/fibonacci.c"
1532
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents: 1531
diff changeset
   316
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   317
/* compile-time check if all tags fit into an unsigned int bit array. */
1462
7997ebe5484f some stylistic changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1460
diff changeset
   318
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -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
   319
1037
6f07d607d607 fixed two comments
arg@suckless.org
parents: 1036
diff changeset
   320
/* function implementations */
1106
084b17f96d9b proceeded, though we still miss a real Tag struct
anselm@anselm1
parents: 1104
diff changeset
   321
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   322
applyrules(Client *c) {
1460
606761ddf6d6 mark broken clients as broken
anselm@x200s.config
parents: 1459
diff changeset
   323
	const char *class, *instance;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   324
	unsigned int i;
1452
769fb14ae867 introducing const where it might make some sense
Anselm R Garbe <anselm@garbe.us>
parents: 1451
diff changeset
   325
	const Rule *r;
1458
e30739eebeed extended rule to apply monitors if set up accordingly
Anselm R Garbe <anselm@garbe.us>
parents: 1457
diff changeset
   326
	Monitor *m;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   327
	XClassHint ch = { NULL, NULL };
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   328
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   329
	/* rule matching */
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   330
	c->isfloating = c->tags = 0;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   331
	XGetClassHint(dpy, c->win, &ch);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   332
	class    = ch.res_class ? ch.res_class : broken;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   333
	instance = ch.res_name  ? ch.res_name  : broken;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   334
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   335
	for(i = 0; i < LENGTH(rules); i++) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   336
		r = &rules[i];
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   337
		if((!r->title || strstr(c->name, r->title))
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   338
		&& (!r->class || strstr(class, r->class))
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   339
		&& (!r->instance || strstr(instance, r->instance)))
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   340
		{
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   341
			c->isfloating = r->isfloating;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   342
			c->tags |= r->tags;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   343
			for(m = mons; m && m->num != r->monitor; m = m->next);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   344
			if(m)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   345
				c->mon = m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   346
		}
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
   347
	}
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   348
	if(ch.res_class)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   349
		XFree(ch.res_class);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   350
	if(ch.res_name)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   351
		XFree(ch.res_name);
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   352
	c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   353
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   354
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   355
Bool
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   356
applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
1390
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   357
	Bool baseismin;
1434
b0ac204a2c03 fixed usage of sx, sy, sw, sh
Anselm R Garbe <anselm@garbe.us>
parents: 1433
diff changeset
   358
	Monitor *m = c->mon;
1390
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   359
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   360
	/* set minimum possible */
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   361
	*w = MAX(1, *w);
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   362
	*h = MAX(1, *h);
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   363
	if(interact) {
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   364
		if(*x > sw)
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   365
			*x = sw - WIDTH(c);
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   366
		if(*y > sh)
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   367
			*y = sh - HEIGHT(c);
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   368
		if(*x + *w + 2 * c->bw < 0)
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   369
			*x = 0;
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   370
		if(*y + *h + 2 * c->bw < 0)
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   371
			*y = 0;
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   372
	}
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   373
	else {
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   374
		if(*x >= m->wx + m->ww)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   375
			*x = m->wx + m->ww - WIDTH(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   376
		if(*y >= m->wy + m->wh)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   377
			*y = m->wy + m->wh - HEIGHT(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   378
		if(*x + *w + 2 * c->bw <= m->wx)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   379
			*x = m->wx;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   380
		if(*y + *h + 2 * c->bw <= m->wy)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   381
			*y = m->wy;
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
   382
	}
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   383
	if(*h < bh)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   384
		*h = bh;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   385
	if(*w < bh)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   386
		*w = bh;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   387
	if(resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   388
		/* see last two sentences in ICCCM 4.1.2.3 */
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   389
		baseismin = c->basew == c->minw && c->baseh == c->minh;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   390
		if(!baseismin) { /* temporarily remove base dimensions */
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   391
			*w -= c->basew;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   392
			*h -= c->baseh;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   393
		}
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   394
		/* adjust for aspect limits */
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   395
		if(c->mina > 0 && c->maxa > 0) {
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   396
			if(c->maxa < (float)*w / *h)
1468
654a2e8064ae removed misleading comment
Anselm R Garbe <garbeam@gmail.com>
parents: 1466
diff changeset
   397
				*w = *h * c->maxa + 0.5;
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   398
			else if(c->mina < (float)*h / *w)
1468
654a2e8064ae removed misleading comment
Anselm R Garbe <garbeam@gmail.com>
parents: 1466
diff changeset
   399
				*h = *w * c->mina + 0.5;
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   400
		}
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   401
		if(baseismin) { /* increment calculation requires this */
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   402
			*w -= c->basew;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   403
			*h -= c->baseh;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   404
		}
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   405
		/* adjust for increment value */
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   406
		if(c->incw)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   407
			*w -= *w % c->incw;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   408
		if(c->inch)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   409
			*h -= *h % c->inch;
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   410
		/* restore base dimensions */
1526
64eb02a74f2b applied Hiltjo's tiny cleanup patch, thanks!
Anselm R Garbe <anselm@garbe.us>
parents: 1525
diff changeset
   411
		*w = MAX(*w + c->basew, c->minw);
64eb02a74f2b applied Hiltjo's tiny cleanup patch, thanks!
Anselm R Garbe <anselm@garbe.us>
parents: 1525
diff changeset
   412
		*h = MAX(*h + c->baseh, c->minh);
1392
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   413
		if(c->maxw)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   414
			*w = MIN(*w, c->maxw);
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   415
		if(c->maxh)
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   416
			*h = MIN(*h, c->maxh);
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   417
	}
ee12ffbf93df applied Gottox' patches, and also removed usegrab
Anselm R Garbe <garbeam@gmail.com>
parents: 1391
diff changeset
   418
	return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
1390
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   419
}
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   420
c0534213fc52 applied Gottox' resizehints patch, thanks Gottox!
Anselm R Garbe <garbeam@gmail.com>
parents: 1389
diff changeset
   421
void
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   422
arrange(Monitor *m) {
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   423
	if(m)
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   424
		showhide(m->stack);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   425
	else for(m = mons; m; m = m->next)
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   426
		showhide(m->stack);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   427
	if(m)
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   428
		arrangemon(m);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   429
	else for(m = mons; m; m = m->next)
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   430
		arrangemon(m);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   431
}
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   432
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   433
void
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   434
arrangemon(Monitor *m) {
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   435
	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   436
	if(m->lt[m->sellt]->arrange)
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   437
		m->lt[m->sellt]->arrange(m);
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   438
	restack(m);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   439
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   440
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   441
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   442
attach(Client *c) {
1409
ed5530a91efe fixed tagmon, re-using detach/detachstack and attach/attachstack
Anselm R Garbe <anselm@garbe.us>
parents: 1408
diff changeset
   443
	c->next = c->mon->clients;
ed5530a91efe fixed tagmon, re-using detach/detachstack and attach/attachstack
Anselm R Garbe <anselm@garbe.us>
parents: 1408
diff changeset
   444
	c->mon->clients = c;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   445
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   446
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   447
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   448
attachstack(Client *c) {
1409
ed5530a91efe fixed tagmon, re-using detach/detachstack and attach/attachstack
Anselm R Garbe <anselm@garbe.us>
parents: 1408
diff changeset
   449
	c->snext = c->mon->stack;
ed5530a91efe fixed tagmon, re-using detach/detachstack and attach/attachstack
Anselm R Garbe <anselm@garbe.us>
parents: 1408
diff changeset
   450
	c->mon->stack = c;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   451
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   452
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   453
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   454
buttonpress(XEvent *e) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   455
	unsigned int i, x, click;
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   456
	Arg arg = {0};
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   457
	Client *c;
1417
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
   458
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   459
	XButtonPressedEvent *ev = &e->xbutton;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   460
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   461
	click = ClkRootWin;
1417
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
   462
	/* focus monitor if necessary */
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   463
	if((m = wintomon(ev->window)) && m != selmon) {
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   464
		unfocus(selmon->sel, True);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   465
		selmon = m;
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   466
		focus(NULL);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   467
	}
1454
b55c7bd92fda removed monsyms, useless
Anselm R Garbe <garbeam@gmail.com>
parents: 1453
diff changeset
   468
	if(ev->window == selmon->barwin) {
b55c7bd92fda removed monsyms, useless
Anselm R Garbe <garbeam@gmail.com>
parents: 1453
diff changeset
   469
		i = x = 0;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   470
		do
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   471
			x += TEXTW(tags[i]);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   472
		while(ev->x >= x && ++i < LENGTH(tags));
1295
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   473
		if(i < LENGTH(tags)) {
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   474
			click = ClkTagBar;
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   475
			arg.ui = 1 << i;
9f20458e3bbc applied Gottox' ClkTagBar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1294
diff changeset
   476
		}
1271
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   477
		else if(ev->x < x + blw)
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   478
			click = ClkLtSymbol;
1540
e8a43c5bbc46 Upgrade to 6.0
Stiletto <blasux@blasux.ru>
parents: 1538 1539
diff changeset
   479
		else if(ev->x > selmon->ww - TEXTWM(stext))
1271
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   480
			click = ClkStatusText;
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   481
		else
c5ea09e8d2fc some bugfixes of the patch application yesterday
Anselm R Garbe <garbeam@gmail.com>
parents: 1270
diff changeset
   482
			click = ClkWinTitle;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   483
	}
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   484
	else if((c = wintoclient(ev->window))) {
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   485
		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
   486
		click = ClkClientWin;
1281
3e478379e74d minor fixes towards 5.0
Anselm R Garbe <garbeam@gmail.com>
parents: 1280
diff changeset
   487
	}
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
   488
	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
   489
		if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
   490
		&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
1351
3f66d2d2cd6e applied yiyus tagbar patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1349
diff changeset
   491
			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
   492
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   493
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   494
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   495
checkotherwm(void) {
1354
dced80b409d8 applied Martin Hurton's checkotherwm simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1353
diff changeset
   496
	xerrorxlib = XSetErrorHandler(xerrorstart);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   497
	/* this causes an error if some other window manager is running */
1077
51b8e0c21bcb proceeded with multihead/Xinerama support
anselm@anselm1
parents: 1076
diff changeset
   498
	XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   499
	XSync(dpy, False);
1354
dced80b409d8 applied Martin Hurton's checkotherwm simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1353
diff changeset
   500
	XSetErrorHandler(xerror);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   501
	XSync(dpy, False);
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   502
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   503
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   504
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   505
cleanup(void) {
1319
fb29ceb5932a fixes using arg->i instead of arg->ui
Premysl Hruby <dfenze@gmail.com>
parents: 1318
diff changeset
   506
	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
   507
	Layout foo = { "", NULL };
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   508
	Monitor *m;
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
   509
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   510
	view(&a);
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
   511
	selmon->lt[selmon->sellt] = &foo;
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   512
	for(m = mons; m; m = m->next)
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   513
		while(m->stack)
1485
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
   514
			unmanage(m->stack, False);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   515
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   516
	XFreePixmap(dpy, dc.drawable);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   517
	XFreeGC(dpy, dc.gc);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   518
	XFreeCursor(dpy, cursor[CurNormal]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   519
	XFreeCursor(dpy, cursor[CurResize]);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   520
	XFreeCursor(dpy, cursor[CurMove]);
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   521
	while(mons)
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   522
		cleanupmon(mons);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   523
	XSync(dpy, False);
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   524
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   525
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   526
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   527
void
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   528
cleanupmon(Monitor *mon) {
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   529
	Monitor *m;
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   530
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   531
	if(mon == mons)
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   532
		mons = mons->next;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   533
	else {
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   534
		for(m = mons; m && m->next != mon; m = m->next);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   535
		m->next = mon->next;
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   536
	}
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   537
	XUnmapWindow(dpy, mon->barwin);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   538
	XDestroyWindow(dpy, mon->barwin);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
   539
	free(mon);
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   540
}
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   541
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   542
void
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   543
clearurgent(Client *c) {
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   544
	XWMHints *wmh;
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   545
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   546
	c->isurgent = False;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   547
	if(!(wmh = XGetWMHints(dpy, c->win)))
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   548
		return;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   549
	wmh->flags &= ~XUrgencyHint;
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   550
	XSetWMHints(dpy, c->win, wmh);
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   551
	XFree(wmh);
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   552
}
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   553
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
   554
void
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   555
clientmessage(XEvent *e) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   556
	XClientMessageEvent *cme = &e->xclient;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   557
	Client *c = wintoclient(cme->window);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   558
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   559
	if(!c)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   560
		return;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   561
	if(cme->message_type == netatom[NetWMState]) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   562
		if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen])
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   563
			setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD    */
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   564
			              || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   565
	}
1542
a699915c007f Make automatic tag switching optional
Stiletto <blasux@blasux.ru>
parents: 1541
diff changeset
   566
#ifdef SWITCH_TAG_ON_NETACTIVEWINDOW
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   567
	else if(cme->message_type == netatom[NetActiveWindow]) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   568
		if(!ISVISIBLE(c)) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   569
			c->mon->seltags ^= 1;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   570
			c->mon->tagset[c->mon->seltags] = c->tags;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   571
		}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   572
		pop(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   573
	}
1542
a699915c007f Make automatic tag switching optional
Stiletto <blasux@blasux.ru>
parents: 1541
diff changeset
   574
#endif
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   575
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   576
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   577
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   578
configure(Client *c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   579
	XConfigureEvent ce;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   580
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   581
	ce.type = ConfigureNotify;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   582
	ce.display = dpy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   583
	ce.event = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   584
	ce.window = c->win;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   585
	ce.x = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   586
	ce.y = c->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   587
	ce.width = c->w;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   588
	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
   589
	ce.border_width = c->bw;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   590
	ce.above = None;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   591
	ce.override_redirect = False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   592
	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   593
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   594
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   595
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   596
configurenotify(XEvent *e) {
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   597
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   598
	XConfigureEvent *ev = &e->xconfigure;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   599
	Bool dirty;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   600
1484
487ed0f2e51d always updategeom when root is configured
nsz@tpx
parents: 1483
diff changeset
   601
	if(ev->window == root) {
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   602
		dirty = (sw != ev->width);
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   603
		sw = ev->width;
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   604
		sh = ev->height;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   605
		if(updategeom() || dirty) {
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   606
			if(dc.drawable != 0)
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   607
				XFreePixmap(dpy, dc.drawable);
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   608
			dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   609
			XftDrawChange(dc.xftdrawable, dc.drawable);
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   610
			updatebars();
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   611
			for(m = mons; m; m = m->next)
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   612
				XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   613
			focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
   614
			arrange(NULL);
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
   615
		}
1155
25e7987c7b18 updated configurenotify
Anselm R Garbe <garbeam@gmail.com>
parents: 1154
diff changeset
   616
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   617
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   618
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   619
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   620
configurerequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   621
	Client *c;
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
   622
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   623
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   624
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   625
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   626
	if((c = wintoclient(ev->window))) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   627
		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
   628
			c->bw = ev->border_width;
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
   629
		else if(c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
   630
			m = c->mon;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   631
			if(ev->value_mask & CWX) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   632
				c->oldx = c->x;
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
   633
				c->x = m->mx + ev->x;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   634
			}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   635
			if(ev->value_mask & CWY) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   636
				c->oldy = c->y;
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
   637
				c->y = m->my + ev->y;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   638
			}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   639
			if(ev->value_mask & CWWidth) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   640
				c->oldw = c->w;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   641
				c->w = ev->width;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   642
			}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   643
			if(ev->value_mask & CWHeight) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   644
				c->oldh = c->h;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   645
				c->h = ev->height;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   646
			}
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
   647
			if((c->x + c->w) > m->mx + m->mw && c->isfloating)
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   648
				c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
   649
			if((c->y + c->h) > m->my + m->mh && c->isfloating)
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   650
				c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
1291
6a5c4371eb25 resize should apply if !banned
Anselm R Garbe <garbeam@gmail.com>
parents: 1290
diff changeset
   651
			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
   652
				configure(c);
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   653
			if(ISVISIBLE(c))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   654
				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
   655
		}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   656
		else
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   657
			configure(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   658
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   659
	else {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   660
		wc.x = ev->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   661
		wc.y = ev->y;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   662
		wc.width = ev->width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   663
		wc.height = ev->height;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   664
		wc.border_width = ev->border_width;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   665
		wc.sibling = ev->above;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   666
		wc.stack_mode = ev->detail;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   667
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   668
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   669
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   670
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   671
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   672
Monitor *
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   673
createmon(void) {
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   674
	Monitor *m;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   675
	unsigned int i;
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   676
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   677
	if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   678
		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   679
	m->tagset[0] = m->tagset[1] = 1;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   680
	m->mfact = mfact;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   681
	m->nmaster = nmaster;
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   682
	m->showbar = showbar;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   683
	m->topbar = topbar;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   684
	m->lt[0] = &layouts[0];
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   685
	m->lt[1] = &layouts[1 % LENGTH(layouts)];
1496
de4a2998e1f5 use buffer instead of pointer for mon->ltsymbol
Anselm R Garbe <garbeam@gmail.com>
parents: 1495
diff changeset
   686
	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   687
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   688
	/* pertag init */
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   689
	m->curtag = m->prevtag = 1;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   690
	for(i=0; i < LENGTH(tags) + 1 ; i++) {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   691
		m->mfacts[i] = mfact;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   692
		m->lts[i] = i ? &layouts[deflayouts[i-1]] : &layouts[0];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   693
		m->showbars[i] = m->showbar;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   694
	}
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   695
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   696
	return m;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   697
}
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
   698
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   699
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   700
destroynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   701
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   702
	XDestroyWindowEvent *ev = &e->xdestroywindow;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   703
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   704
	if((c = wintoclient(ev->window)))
1485
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
   705
		unmanage(c, True);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   706
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   707
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   708
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   709
detach(Client *c) {
1307
2c72f7c8826f simplified detach()
Anselm R Garbe <garbeam@gmail.com>
parents: 1306
diff changeset
   710
	Client **tc;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   711
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   712
	for(tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
1307
2c72f7c8826f simplified detach()
Anselm R Garbe <garbeam@gmail.com>
parents: 1306
diff changeset
   713
	*tc = c->next;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   714
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   715
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   716
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   717
detachstack(Client *c) {
1431
Anselm R Garbe <anselm@garbe.us>
parents: 1430
diff changeset
   718
	Client **tc, *t;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   719
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   720
	for(tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   721
	*tc = c->snext;
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   722
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   723
	if(c == c->mon->sel) {
1431
Anselm R Garbe <anselm@garbe.us>
parents: 1430
diff changeset
   724
		for(t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
Anselm R Garbe <anselm@garbe.us>
parents: 1430
diff changeset
   725
		c->mon->sel = t;
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   726
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   727
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   728
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   729
void
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   730
die(const char *errstr, ...) {
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   731
	va_list ap;
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   732
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   733
	va_start(ap, errstr);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   734
	vfprintf(stderr, errstr, ap);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   735
	va_end(ap);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   736
	exit(EXIT_FAILURE);
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   737
}
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   738
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   739
Monitor *
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   740
dirtomon(int dir) {
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   741
	Monitor *m = NULL;
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   742
1446
Anselm R Garbe <anselm@garbe.us>
parents: 1445
diff changeset
   743
	if(dir > 0) {
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   744
		if(!(m = selmon->next))
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   745
			m = mons;
1446
Anselm R Garbe <anselm@garbe.us>
parents: 1445
diff changeset
   746
	}
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   747
	else if(selmon == mons)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   748
		for(m = mons; m->next; m = m->next);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   749
	else
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   750
		for(m = mons; m->next != selmon; m = m->next);
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   751
	return m;
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   752
}
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   753
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   754
void
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   755
drawbar(Monitor *m) {
1318
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   756
	int x;
1491
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
   757
	unsigned int i, occ = 0, urg = 0;
1318
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   758
	unsigned long *col;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   759
	Client *c;
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   760
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   761
	for(c = m->clients; c; c = c->next) {
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   762
		occ |= c->tags;
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   763
		if(c->isurgent)
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   764
			urg |= c->tags;
1318
65c37b4be9cb applied Johannes Hofmann's patch, please test
anselm@anselm1
parents: 1317
diff changeset
   765
	}
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   766
	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
   767
	for(i = 0; i < LENGTH(tags); i++) {
1236
523ba822927f removed TEXTW
Anselm R Garbe <garbeam@gmail.com>
parents: 1235
diff changeset
   768
		dc.w = TEXTW(tags[i]);
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
   769
		col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   770
		drawtext(tags[i], col, urg & 1 << i, False);
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   771
		drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   772
		           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
   773
		dc.x += dc.w;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   774
	}
1491
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
   775
	dc.w = blw = TEXTW(m->ltsymbol);
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   776
	drawtext(m->ltsymbol, dc.norm, False, False);
1491
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
   777
	dc.x += dc.w;
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
   778
	x = dc.x;
1415
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   779
	if(m == selmon) { /* status is only drawn on selected monitor */
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   780
		dc.w = TEXTWM(stext);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   781
		dc.x = m->ww - dc.w;
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   782
		if(dc.x < x) {
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   783
			dc.x = x;
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   784
			dc.w = m->ww - x;
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   785
		}
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   786
		drawtext(stext, dc.norm, False, True);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   787
	}
1444
19dc2b0c61e2 removed some empty lines
Anselm R Garbe <anselm@garbe.us>
parents: 1443
diff changeset
   788
	else
1415
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   789
		dc.x = m->ww;
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   790
	if((dc.w = dc.x - x) > bh) {
1399
0decadd79fd5 several fixes through ISVISIBLE change (takes Monitor into account)
Anselm R Garbe <anselm@garbe.us>
parents: 1398
diff changeset
   791
		dc.x = x;
1415
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   792
		if(m->sel) {
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   793
			col = m == selmon ? dc.sel : dc.norm;
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   794
			drawtext(m->sel->name, col, False, False);
1415
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   795
			drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   796
		}
b2265afcdd4e fixed title rendering on non-active screen
Anselm R Garbe <garbeam@gmail.com>
parents: 1414
diff changeset
   797
		else
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   798
			drawtext(NULL, dc.norm, False, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   799
	}
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   800
	XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   801
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   802
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   803
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   804
void
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   805
drawbars(void) {
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   806
	Monitor *m;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   807
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   808
	for(m = mons; m; m = m->next)
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   809
		drawbar(m);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   810
}
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   811
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   812
void
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   813
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
   814
	int x;
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   815
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   816
	XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   817
	x = (dc.font.ascent + dc.font.descent + 2) / 4;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   818
	if(filled)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   819
		XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   820
	else if(empty)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   821
		XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x);
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   822
}
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   823
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
   824
void
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   825
drawtext(const char *text, unsigned long col[ColLast], Bool invert, Bool markup) {
1332
Anselm R Garbe <garbeam@gmail.com>
parents: 1331
diff changeset
   826
	char buf[256];
1254
d04ee4e2336d applied nsz's patches (many thanks!)
arg@suckless.org
parents: 1253
diff changeset
   827
	int i, x, y, h, len, olen;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   828
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   829
	XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   830
	XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   831
	if(!text)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   832
		return;
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   833
	olen = strlen(text);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   834
	h = dc.font.ascent + dc.font.descent;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   835
	//y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   836
	y = dc.y;
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   837
	x = dc.x + (h / 2);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   838
	/* shorten text if necessary */
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   839
	for(len = MIN(olen, sizeof buf); len && textnw(text, len, markup) > dc.w - h; len--);
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
   840
	if(!len)
1182
9940d125b703 applied dfenze drawtext simplifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1179
diff changeset
   841
		return;
1328
0fac6d3067d7 applied Martin Hurton's drawtext() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1327
diff changeset
   842
	memcpy(buf, text, len);
1250
1fa12fca6c0e Gottox' drawtext simplification
Anselm R Garbe <garbeam@gmail.com>
parents: 1249
diff changeset
   843
	if(len < olen)
1259
f0c900871c87 final version -- Gottox verified it using the test driver
arg@suckless.org
parents: 1258
diff changeset
   844
		for(i = len; i && i > len - 3; buf[--i] = '.');
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   845
	if (markup)
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   846
		pango_layout_set_markup(dc.plo, text, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   847
	else
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
   848
		pango_layout_set_text(dc.plo, text, len);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   849
	pango_xft_render_layout(dc.xftdrawable, (col==dc.norm?dc.xftnorm:dc.xftsel)+(invert?ColBG:ColFG), dc.plo, x * PANGO_SCALE, y * PANGO_SCALE);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   850
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   851
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   852
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   853
enternotify(XEvent *e) {
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   854
	Client *c;
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   855
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   856
	XCrossingEvent *ev = &e->xcrossing;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   857
1109
55e2f7e96b71 removed initags -- we autoselect the first tag in each view instead
anselm@anselm1
parents: 1108
diff changeset
   858
	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
   859
		return;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   860
	c = wintoclient(ev->window);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   861
	m = c ? c->mon : wintomon(ev->window);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   862
	if(m != selmon) {
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   863
		unfocus(selmon->sel, True);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   864
		selmon = m;
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   865
	}
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   866
	else if(!c || c == selmon->sel)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   867
		return;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   868
	focus(c);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   869
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   870
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   871
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   872
expose(XEvent *e) {
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   873
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   874
	XExposeEvent *ev = &e->xexpose;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   875
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
   876
	if(ev->count == 0 && (m = wintomon(ev->window)))
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   877
		drawbar(m);
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
   878
}
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
   879
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   880
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   881
focus(Client *c) {
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   882
	if(!c || !ISVISIBLE(c))
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   883
		for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   884
	/* was if(selmon->sel) */
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   885
	if(selmon->sel && selmon->sel != c)
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   886
		unfocus(selmon->sel, False);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   887
	if(c) {
1416
e802c6186f6c some focus fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1415
diff changeset
   888
		if(c->mon != selmon)
e802c6186f6c some focus fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1415
diff changeset
   889
			selmon = c->mon;
1366
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   890
		if(c->isurgent)
335301ed102f integrated yiyus clearurgent refactoring
Anselm R Garbe <garbeam@gmail.com>
parents: 1365
diff changeset
   891
			clearurgent(c);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   892
		detachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   893
		attachstack(c);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   894
		grabbuttons(c, True);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
   895
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   896
		setfocus(c);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   897
	}
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
   898
	else
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
   899
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   900
	selmon->sel = c;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   901
	drawbars();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   902
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   903
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   904
void
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   905
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
   906
	XFocusChangeEvent *ev = &e->xfocus;
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   907
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   908
	if(selmon->sel && ev->window != selmon->sel->win)
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   909
		setfocus(selmon->sel);
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   910
}
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   911
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   912
void
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   913
focusmon(const Arg *arg) {
1526
64eb02a74f2b applied Hiltjo's tiny cleanup patch, thanks!
Anselm R Garbe <anselm@garbe.us>
parents: 1525
diff changeset
   914
	Monitor *m;
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
   915
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
   916
	if(!mons->next)
1427
f8ea02f86861 some cleanup handling for index based mon search
Anselm R Garbe <anselm@garbe.us>
parents: 1426
diff changeset
   917
		return;
1510
e9c916f6ea15 more debug output, experimental focus optimisation
Anselm R Garbe <anselm@garbe.us>
parents: 1509
diff changeset
   918
	if((m = dirtomon(arg->i)) == selmon)
e9c916f6ea15 more debug output, experimental focus optimisation
Anselm R Garbe <anselm@garbe.us>
parents: 1509
diff changeset
   919
		return;
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   920
	unfocus(selmon->sel, True);
1427
f8ea02f86861 some cleanup handling for index based mon search
Anselm R Garbe <anselm@garbe.us>
parents: 1426
diff changeset
   921
	selmon = m;
f8ea02f86861 some cleanup handling for index based mon search
Anselm R Garbe <anselm@garbe.us>
parents: 1426
diff changeset
   922
	focus(NULL);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   923
}
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   924
1067
d6d3085307d8 fixed focus steeling bug done by clients like opera
Anselm R. Garbe <garbeam@gmail.com>
parents: 1066
diff changeset
   925
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   926
focusstack(const Arg *arg) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   927
	Client *c = NULL, *i;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   928
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   929
	if(!selmon->sel)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   930
		return;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   931
	if(arg->i > 0) {
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   932
		for(c = selmon->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
   933
		if(!c)
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   934
			for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   935
	}
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   936
	else {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
   937
		for(i = selmon->clients; i != selmon->sel; i = i->next)
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   938
			if(ISVISIBLE(i))
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   939
				c = i;
1268
fc7dd1b14093 removed trailing spaces reported by Soleen
Anselm R Garbe <garbeam@gmail.com>
parents: 1267
diff changeset
   940
		if(!c)
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   941
			for(; i; i = i->next)
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
   942
				if(ISVISIBLE(i))
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
   943
					c = i;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   944
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   945
	if(c) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   946
		focus(c);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
   947
		restack(selmon);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   948
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   949
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   950
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   951
Atom
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   952
getatomprop(Client *c, Atom prop) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   953
	int di;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   954
	unsigned long dl;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   955
	unsigned char *p = NULL;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   956
	Atom da, atom = None;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   957
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   958
	if(XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   959
	                      &da, &di, &dl, &dl, &p) == Success && p) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   960
		atom = *(Atom *)p;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   961
		XFree(p);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   962
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   963
	return atom;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   964
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   965
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   966
unsigned long
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   967
getcolor(const char *colstr, XftColor *color) {
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   968
	Colormap cmap = DefaultColormap(dpy, screen);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   969
	Visual *vis = DefaultVisual(dpy, screen);
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   970
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   971
	if(!XftColorAllocName(dpy,vis,cmap,colstr, color))
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
   972
		die("error, cannot allocate color '%s'\n", colstr);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
   973
	return color->pixel;
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   974
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
   975
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   976
Bool
1450
b2d18a052137 some minor changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1449
diff changeset
   977
getrootptr(int *x, int *y) {
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   978
	int di;
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   979
	unsigned int dui;
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   980
	Window dummy;
1444
19dc2b0c61e2 removed some empty lines
Anselm R Garbe <anselm@garbe.us>
parents: 1443
diff changeset
   981
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   982
	return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   983
}
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
   984
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
   985
long
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   986
getstate(Window w) {
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   987
	int format;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   988
	long result = -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   989
	unsigned char *p = NULL;
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
   990
	unsigned long n, extra;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   991
	Atom real;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   992
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   993
	if(XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
   994
	                      &real, &format, &n, &extra, (unsigned char **)&p) != Success)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   995
		return -1;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   996
	if(n != 0)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   997
		result = *p;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   998
	XFree(p);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
   999
	return result;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1000
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1001
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1002
Bool
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1003
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
  1004
	char **list = NULL;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1005
	int n;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1006
	XTextProperty name;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1007
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
  1008
	if(!text || size == 0)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1009
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1010
	text[0] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1011
	XGetTextProperty(dpy, w, &name, atom);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1012
	if(!name.nitems)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1013
		return False;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1014
	if(name.encoding == XA_STRING)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1015
		strncpy(text, (char *)name.value, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1016
	else {
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1017
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1018
			strncpy(text, *list, size - 1);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1019
			XFreeStringList(list);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1020
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1021
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1022
	text[size - 1] = '\0';
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1023
	XFree(name.value);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1024
	return True;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1025
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1026
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1027
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1028
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
  1029
	updatenumlockmask();
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1030
	{
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1031
		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
  1032
		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
  1033
		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
  1034
		if(focused) {
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1035
			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
  1036
				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
  1037
					for(j = 0; j < LENGTH(modifiers); j++)
1395
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1038
						XGrabButton(dpy, buttons[i].button,
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1039
						            buttons[i].mask | modifiers[j],
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1040
						            c->win, False, BUTTONMASK,
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1041
						            GrabModeAsync, GrabModeSync, None, None);
1447
4fff5050c835 some cleanups
Anselm R Garbe <anselm@garbe.us>
parents: 1446
diff changeset
  1042
		}
4fff5050c835 some cleanups
Anselm R Garbe <anselm@garbe.us>
parents: 1446
diff changeset
  1043
		else
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1044
			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
  1045
			            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
  1046
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1047
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1048
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1049
void
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1050
grabkeys(void) {
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1051
	updatenumlockmask();
1444
19dc2b0c61e2 removed some empty lines
Anselm R Garbe <anselm@garbe.us>
parents: 1443
diff changeset
  1052
	{
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1053
		unsigned int i, j;
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
  1054
		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
  1055
		KeyCode code;
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
  1056
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
  1057
		XUngrabKey(dpy, AnyKey, AnyModifier, root);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1058
		for(i = 0; i < LENGTH(keys); i++)
1352
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
  1059
			if((code = XKeysymToKeycode(dpy, keys[i].keysym)))
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
  1060
				for(j = 0; j < LENGTH(modifiers); j++)
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
  1061
					XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
eb1eb9811706 applied Gottox' grabkey patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1351
diff changeset
  1062
						 True, GrabModeAsync, GrabModeAsync);
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1063
	}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1064
}
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1065
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1066
void
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1067
incnmaster(const Arg *arg) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1068
	selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1069
	arrange(selmon);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1070
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1071
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1072
void
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1073
initfont(const char *fontstr) {
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1074
	PangoFontMetrics *metrics;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1075
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1076
	dc.pgc = pango_xft_get_context(dpy, screen);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1077
	dc.pfd = pango_font_description_from_string(fontstr);
1462
7997ebe5484f some stylistic changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1460
diff changeset
  1078
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1079
	metrics = pango_context_get_metrics(dc.pgc, dc.pfd, pango_language_from_string(setlocale(LC_CTYPE, "")));
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1080
	dc.font.ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1081
	dc.font.descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1082
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1083
	pango_font_metrics_unref(metrics);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1084
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1085
	dc.plo = pango_layout_new(dc.pgc);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1086
	pango_layout_set_font_description(dc.plo, dc.pfd);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1087
	dc.font.height = dc.font.ascent + dc.font.descent;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1088
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1089
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1090
#ifdef XINERAMA
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1091
static Bool
1530
072c62ed10f2 applied anonymous patch, I don't think the reversed array access has semantic side-effects
Anselm R Garbe <anselm@garbe.us>
parents: 1528
diff changeset
  1092
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
072c62ed10f2 applied anonymous patch, I don't think the reversed array access has semantic side-effects
Anselm R Garbe <anselm@garbe.us>
parents: 1528
diff changeset
  1093
	while(n--)
072c62ed10f2 applied anonymous patch, I don't think the reversed array access has semantic side-effects
Anselm R Garbe <anselm@garbe.us>
parents: 1528
diff changeset
  1094
		if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
072c62ed10f2 applied anonymous patch, I don't think the reversed array access has semantic side-effects
Anselm R Garbe <anselm@garbe.us>
parents: 1528
diff changeset
  1095
		&& unique[n].width == info->width && unique[n].height == info->height)
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1096
			return False;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1097
	return True;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1098
}
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1099
#endif /* XINERAMA */
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1100
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1101
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1102
keypress(XEvent *e) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1103
	unsigned int i;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1104
	KeySym keysym;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1105
	XKeyEvent *ev;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1106
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1107
	ev = &e->xkey;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1108
	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
  1109
	for(i = 0; i < LENGTH(keys); i++)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1110
		if(keysym == keys[i].keysym
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1111
		&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1112
		&& keys[i].func)
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1113
			keys[i].func(&(keys[i].arg));
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1114
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1115
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1116
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1117
killclient(const Arg *arg) {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1118
	if(!selmon->sel)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1119
		return;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1120
	if(!sendevent(selmon->sel, wmatom[WMDelete])) {
1488
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1121
		XGrabServer(dpy);
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1122
		XSetErrorHandler(xerrordummy);
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1123
		XSetCloseDownMode(dpy, DestroyAll);
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1124
		XKillClient(dpy, selmon->sel->win);
1488
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1125
		XSync(dpy, False);
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1126
		XSetErrorHandler(xerror);
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1127
		XUngrabServer(dpy);
e10cbf276218 hard-core destruction
Anselm R Garbe <garbeam@gmail.com>
parents: 1487
diff changeset
  1128
	}
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1129
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1130
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1131
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1132
manage(Window w, XWindowAttributes *wa) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1133
	Client *c, *t = NULL;
1333
5be4e277ed7c using None instead of 0 for trans
Anselm R Garbe <garbeam@gmail.com>
parents: 1332
diff changeset
  1134
	Window trans = None;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1135
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1136
1528
b4f5309d6253 applied Hiltjo's cleanup patch
Anselm R Garbe <anselm@garbe.us>
parents: 1527
diff changeset
  1137
	if(!(c = calloc(1, sizeof(Client))))
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
  1138
		die("fatal: could not malloc() %u bytes\n", sizeof(Client));
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1139
	c->win = w;
1459
a5eecc6d674f fixing updatetitle
anselm@x200s.config
parents: 1458
diff changeset
  1140
	updatetitle(c);
1526
64eb02a74f2b applied Hiltjo's tiny cleanup patch, thanks!
Anselm R Garbe <anselm@garbe.us>
parents: 1525
diff changeset
  1141
	if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
1432
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1142
		c->mon = t->mon;
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1143
		c->tags = t->tags;
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1144
	}
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1145
	else {
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1146
		c->mon = selmon;
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1147
		applyrules(c);
dda54561d777 fixed order of transient monitor applicaion and rule application
Anselm R Garbe <anselm@garbe.us>
parents: 1431
diff changeset
  1148
	}
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
  1149
	/* geometry */
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1150
	c->x = c->oldx = wa->x;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1151
	c->y = c->oldy = wa->y;
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1152
	c->w = c->oldw = wa->width;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1153
	c->h = c->oldh = 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
  1154
	c->oldbw = wa->border_width;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1155
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1156
	if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1157
		c->x = c->mon->mx + c->mon->mw - WIDTH(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1158
	if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1159
		c->y = c->mon->my + c->mon->mh - HEIGHT(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1160
	c->x = MAX(c->x, c->mon->mx);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1161
	/* only fix client y-offset, if the client center might cover the bar */
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1162
	c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1163
	           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1164
	c->bw = borderpx;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1165
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
  1166
	wc.border_width = c->bw;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1167
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1168
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1169
	configure(c); /* propagates border_width, if size doesn't change */
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1170
	updatewindowtype(c);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1171
	updatesizehints(c);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1172
	updatewmhints(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
  1173
	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1174
	grabbuttons(c, False);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1175
	if(!c->isfloating)
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1176
		c->isfloating = c->oldstate = trans != None || c->isfixed;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1177
	if(c->isfloating)
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1178
		XRaiseWindow(dpy, c->win);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1179
	attach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1180
	attachstack(c);
1297
20481c9d647c does this fix anything?
Anselm R Garbe <garbeam@gmail.com>
parents: 1295
diff changeset
  1181
	XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1182
	setclientstate(c, NormalState);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1183
	if (c->mon == selmon)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1184
		unfocus(selmon->sel, False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1185
	c->mon->sel = c;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1186
	arrange(c->mon);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1187
	XMapWindow(dpy, c->win);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1188
	focus(NULL);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1189
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1190
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1191
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1192
mappingnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1193
	XMappingEvent *ev = &e->xmapping;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1194
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1195
	XRefreshKeyboardMapping(ev);
1340
15d159526e5e changed grabkeys, removed initmodmap
Anselm R Garbe <garbeam@gmail.com>
parents: 1339
diff changeset
  1196
	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
  1197
		grabkeys();
996
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
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1201
maprequest(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1202
	static XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1203
	XMapRequestEvent *ev = &e->xmaprequest;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1204
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1205
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1206
		return;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1207
	if(wa.override_redirect)
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1208
		return;
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1209
	if(!wintoclient(ev->window))
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1210
		manage(ev->window, &wa);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1211
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1212
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1213
void
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1214
monocle(Monitor *m) {
1491
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
  1215
	unsigned int n = 0;
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1216
	Client *c;
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1217
1491
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
  1218
	for(c = m->clients; c; c = c->next)
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
  1219
		if(ISVISIBLE(c))
4754e7889841 implemented dynamic layout symbol stuff
Anselm R Garbe <garbeam@gmail.com>
parents: 1489
diff changeset
  1220
			n++;
1496
de4a2998e1f5 use buffer instead of pointer for mon->ltsymbol
Anselm R Garbe <garbeam@gmail.com>
parents: 1495
diff changeset
  1221
	if(n > 0) /* override layout symbol */
de4a2998e1f5 use buffer instead of pointer for mon->ltsymbol
Anselm R Garbe <garbeam@gmail.com>
parents: 1495
diff changeset
  1222
		snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1223
	for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1224
		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1225
}
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1226
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1227
void
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1228
motionnotify(XEvent *e) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1229
	static Monitor *mon = NULL;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1230
	Monitor *m;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1231
	XMotionEvent *ev = &e->xmotion;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1232
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1233
	if(ev->window != root)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1234
		return;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1235
	if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1236
		selmon = m;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1237
		focus(NULL);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1238
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1239
	mon = m;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1240
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1241
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1242
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
  1243
movemouse(const Arg *arg) {
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1244
	int x, y, ocx, ocy, nx, ny;
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
  1245
	Client *c;
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1246
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1247
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1248
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1249
	if(!(c = selmon->sel))
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
  1250
		return;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1251
	restack(selmon);
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1252
	ocx = c->x;
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1253
	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
  1254
	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
  1255
	None, cursor[CurMove], CurrentTime) != GrabSuccess)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1256
		return;
1450
b2d18a052137 some minor changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1449
diff changeset
  1257
	if(!getrootptr(&x, &y))
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1258
		return;
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1259
	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
  1260
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1261
		switch(ev.type) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1262
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1263
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1264
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1265
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1266
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1267
		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
  1268
			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
  1269
			ny = ocy + (ev.xmotion.y - y);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1270
			if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1271
			&& ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
1397
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1272
				if(abs(selmon->wx - nx) < snap)
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1273
					nx = selmon->wx;
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1274
				else if(abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1275
					nx = selmon->wx + selmon->ww - WIDTH(c);
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1276
				if(abs(selmon->wy - ny) < snap)
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1277
					ny = selmon->wy;
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1278
				else if(abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1279
					ny = selmon->wy + selmon->wh - HEIGHT(c);
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1280
				if(!c->isfloating && selmon->lt[selmon->sellt]->arrange
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1281
				&& (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
  1282
					togglefloating(NULL);
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
  1283
			}
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1284
			if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1285
				resize(c, nx, ny, c->w, c->h, True);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1286
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1287
		}
1462
7997ebe5484f some stylistic changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1460
diff changeset
  1288
	} while(ev.type != ButtonRelease);
1334
6f9cf8bcc4a7 applied Martin Hurton's movemouse() patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1333
diff changeset
  1289
	XUngrabPointer(dpy, CurrentTime);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1290
	if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1291
		sendmon(c, m);
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1292
		selmon = m;
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1293
		focus(NULL);
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1294
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1295
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1296
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1297
Client *
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1298
nexttiled(Client *c) {
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1299
	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
  1300
	return c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1301
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1302
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1303
void
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1304
pop(Client *c) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1305
	detach(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1306
	attach(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1307
	focus(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1308
	arrange(c->mon);
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1309
}
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1310
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1311
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1312
propertynotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1313
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1314
	Window trans;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1315
	XPropertyEvent *ev = &e->xproperty;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1316
1385
85a8eff4c123 fix of typo, thx to Enno Gottox Boland
Premysl Hruby <dfenze@gmail.com>
parents: 1383
diff changeset
  1317
	if((ev->window == root) && (ev->atom == XA_WM_NAME))
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1318
		updatestatus();
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1319
	else if(ev->state == PropertyDelete)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1320
		return; /* ignore */
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1321
	else if((c = wintoclient(ev->window))) {
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1322
		switch(ev->atom) {
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1323
		default: break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1324
		case XA_WM_TRANSIENT_FOR:
1526
64eb02a74f2b applied Hiltjo's tiny cleanup patch, thanks!
Anselm R Garbe <anselm@garbe.us>
parents: 1525
diff changeset
  1325
			if(!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) &&
1527
406003e3a01f applied Hiltjo's tiny cleanup fix
Anselm R Garbe <anselm@garbe.us>
parents: 1526
diff changeset
  1326
			   (c->isfloating = (wintoclient(trans)) != NULL))
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1327
				arrange(c->mon);
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1328
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1329
		case XA_WM_NORMAL_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1330
			updatesizehints(c);
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1331
			break;
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1332
		case XA_WM_HINTS:
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1333
			updatewmhints(c);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1334
			drawbars();
1093
5170cc8c078e made restack, drawbar also Monitor-related only
Anselm R Garbe <garbeam@gmail.com>
parents: 1092
diff changeset
  1335
			break;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1336
		}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1337
		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
  1338
			updatetitle(c);
1482
d4137ac1d940 also update title if the client is on an unfocused monitor
Anselm R Garbe <garbeam@gmail.com>
parents: 1480
diff changeset
  1339
			if(c == c->mon->sel)
1483
63e19dad219c another small optimisation
Anselm R Garbe <garbeam@gmail.com>
parents: 1482
diff changeset
  1340
				drawbar(c->mon);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1341
		}
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1342
		if(ev->atom == netatom[NetWMWindowType])
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1343
			updatewindowtype(c);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1344
	}
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1345
}
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1346
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1347
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1348
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
  1349
	running = False;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1350
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1351
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1352
Monitor *
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1353
recttomon(int x, int y, int w, int h) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1354
	Monitor *m, *r = selmon;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1355
	int a, area = 0;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1356
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1357
	for(m = mons; m; m = m->next)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1358
		if((a = INTERSECT(x, y, w, h, m)) > area) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1359
			area = a;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1360
			r = m;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1361
		}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1362
	return r;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1363
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1364
1070
dc37f0e022f7 implemented reapply for re-applying the tagging rules during runtime, Mod-r
Anselm R. Garbe <garbeam@gmail.com>
parents: 1067
diff changeset
  1365
void
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1366
resize(Client *c, int x, int y, int w, int h, Bool interact) {
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1367
	if(applysizehints(c, &x, &y, &w, &h, interact))
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1368
		resizeclient(c, x, y, w, h);
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1369
}
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1370
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1371
void
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1372
resizeclient(Client *c, int x, int y, int w, int h) {
1024
17a935c3017f removed two spaces reported by Soleen
Anselm R. Garbe <garbeam@gmail.com>
parents: 1023
diff changeset
  1373
	XWindowChanges wc;
1090
09f1bf0e12ee resize handles offscreen issues
Anselm R Garbe <garbeam@gmail.com>
parents: 1089
diff changeset
  1374
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1375
	c->oldx = c->x; c->x = wc.x = x;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1376
	c->oldy = c->y; c->y = wc.y = y;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1377
	c->oldw = c->w; c->w = wc.width = w;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1378
	c->oldh = c->h; c->h = wc.height = h;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1379
	wc.border_width = c->bw;
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1380
	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1381
	configure(c);
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1382
	XSync(dpy, False);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1383
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
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
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
  1386
resizemouse(const Arg *arg) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1387
	int ocx, ocy;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1388
	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
  1389
	Client *c;
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1390
	Monitor *m;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1391
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1392
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1393
	if(!(c = selmon->sel))
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
  1394
		return;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1395
	restack(selmon);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1396
	ocx = c->x;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1397
	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
  1398
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1399
	                None, cursor[CurResize], CurrentTime) != GrabSuccess)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1400
		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
  1401
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
1335
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1402
	do {
1337
c4ecef7983b8 Martin Hurtons typo fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1336
diff changeset
  1403
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1404
		switch(ev.type) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1405
		case ConfigureRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1406
		case Expose:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1407
		case MapRequest:
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1408
			handler[ev.type](&ev);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1409
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1410
		case MotionNotify:
1380
add6eb26ebaa spotted missing spaces
a@null
parents: 1379
diff changeset
  1411
			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
add6eb26ebaa spotted missing spaces
a@null
parents: 1379
diff changeset
  1412
			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1413
			if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1414
			&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1415
			{
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1416
				if(!c->isfloating && selmon->lt[selmon->sellt]->arrange
1464
555070221577 final style fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1463
diff changeset
  1417
				&& (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
1213
368a80dcf5bd only snap within window area
Anselm R Garbe <garbeam@gmail.com>
parents: 1212
diff changeset
  1418
					togglefloating(NULL);
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1419
			}
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1420
			if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1421
				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
  1422
			break;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1423
		}
1462
7997ebe5484f some stylistic changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1460
diff changeset
  1424
	} while(ev.type != ButtonRelease);
1335
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1425
	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
  1426
	XUngrabPointer(dpy, CurrentTime);
83da51dfedd3 applied Martin Hurtons resizemouse patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1334
diff changeset
  1427
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1428
	if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1429
		sendmon(c, m);
1428
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1430
		selmon = m;
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1431
		focus(NULL);
2245e2b88983 applied a collection of Christof Musik patches, and fixed an issue reported by waistcoats on IRC
Anselm R Garbe <garbeam@gmail.com>
parents: 1427
diff changeset
  1432
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1433
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1434
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1435
void
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1436
restack(Monitor *m) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1437
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1438
	XEvent ev;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1439
	XWindowChanges wc;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1440
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1441
	drawbar(m);
1412
2bc44743117e some restack fixes, still odd behavior if n>1 on unmanaging clients
Anselm R Garbe <anselm@garbe.us>
parents: 1411
diff changeset
  1442
	if(!m->sel)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1443
		return;
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1444
	if(m->sel->isfloating || !m->lt[m->sellt]->arrange)
1412
2bc44743117e some restack fixes, still odd behavior if n>1 on unmanaging clients
Anselm R Garbe <anselm@garbe.us>
parents: 1411
diff changeset
  1445
		XRaiseWindow(dpy, m->sel->win);
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1446
	if(m->lt[m->sellt]->arrange) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1447
		wc.stack_mode = Below;
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1448
		wc.sibling = m->barwin;
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1449
		for(c = m->stack; c; c = c->snext)
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1450
			if(!c->isfloating && ISVISIBLE(c)) {
1183
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1451
				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1452
				wc.sibling = c->win;
b20561489ffb applied yiyus fgeom patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1182
diff changeset
  1453
			}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1454
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1455
	XSync(dpy, False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1456
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1457
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1458
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1459
void
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1460
run(void) {
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1461
	XEvent ev;
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1462
	/* main event loop */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1463
	XSync(dpy, False);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1464
	while(running && !XNextEvent(dpy, &ev))
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1465
		if(handler[ev.type])
1462
7997ebe5484f some stylistic changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1460
diff changeset
  1466
			handler[ev.type](&ev); /* call handler */
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1467
}
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  1468
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1469
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1470
scan(void) {
1310
1d52b420daa4 reverted uint redefinition
Anselm R Garbe <garbeam@gmail.com>
parents: 1309
diff changeset
  1471
	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
  1472
	Window d1, d2, *wins = NULL;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1473
	XWindowAttributes wa;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1474
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1475
	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
  1476
		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
  1477
			if(!XGetWindowAttributes(dpy, wins[i], &wa)
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1478
			|| 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
  1479
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1480
			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
  1481
				manage(wins[i], &wa);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1482
		}
1087
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1483
		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
  1484
			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
  1485
				continue;
197bfedb953c removed Monitor->root, since we do not support classical multihead
Anselm R Garbe <garbeam@gmail.com>
parents: 1086
diff changeset
  1486
			if(XGetTransientForHint(dpy, wins[i], &d1)
1195
33ba827ee84e applied nsz's style.diff patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1194
diff changeset
  1487
			&& (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
  1488
				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
  1489
		}
1330
06677766e7aa applied Martin Hurton's scan() patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1329
diff changeset
  1490
		if(wins)
06677766e7aa applied Martin Hurton's scan() patch with slight modifications
Anselm R Garbe <garbeam@gmail.com>
parents: 1329
diff changeset
  1491
			XFree(wins);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1492
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1493
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1494
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1495
void
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1496
sendmon(Client *c, Monitor *m) {
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1497
	if(c->mon == m)
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1498
		return;
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1499
	unfocus(c, True);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1500
	detach(c);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1501
	detachstack(c);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1502
	c->mon = m;
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1503
	c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1504
	attach(c);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1505
	attachstack(c);
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1506
	focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1507
	arrange(NULL);
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1508
}
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1509
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  1510
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1511
setclientstate(Client *c, long state) {
1447
4fff5050c835 some cleanups
Anselm R Garbe <anselm@garbe.us>
parents: 1446
diff changeset
  1512
	long data[] = { state, None };
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1513
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1514
	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1515
			PropModeReplace, (unsigned char *)data, 2);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1516
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1517
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1518
Bool
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1519
sendevent(Client *c, Atom proto) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1520
	int n;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1521
	Atom *protocols;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1522
	Bool exists = False;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1523
	XEvent ev;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1524
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1525
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1526
		while(!exists && n--)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1527
			exists = protocols[n] == proto;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1528
		XFree(protocols);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1529
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1530
	if(exists) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1531
		ev.type = ClientMessage;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1532
		ev.xclient.window = c->win;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1533
		ev.xclient.message_type = wmatom[WMProtocols];
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1534
		ev.xclient.format = 32;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1535
		ev.xclient.data.l[0] = proto;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1536
		ev.xclient.data.l[1] = CurrentTime;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1537
		XSendEvent(dpy, c->win, False, NoEventMask, &ev);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1538
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1539
	return exists;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1540
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1541
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1542
void
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1543
setfocus(Client *c) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1544
	if(!c->neverfocus)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1545
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1546
	sendevent(c, wmatom[WMTakeFocus]);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1547
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1548
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1549
void
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1550
setfullscreen(Client *c, Bool fullscreen) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1551
	if(fullscreen) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1552
		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1553
		                PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1554
		c->isfullscreen = True;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1555
		c->oldstate = c->isfloating;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1556
		c->oldbw = c->bw;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1557
		c->bw = 0;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1558
		c->isfloating = True;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1559
		resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1560
		XRaiseWindow(dpy, c->win);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1561
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1562
	else {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1563
		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1564
		                PropModeReplace, (unsigned char*)0, 0);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1565
		c->isfullscreen = False;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1566
		c->isfloating = c->oldstate;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1567
		c->bw = c->oldbw;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1568
		c->x = c->oldx;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1569
		c->y = c->oldy;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1570
		c->w = c->oldw;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1571
		c->h = c->oldh;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1572
		resizeclient(c, c->x, c->y, c->w, c->h);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1573
		arrange(c->mon);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1574
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1575
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1576
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1577
void
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1578
setlayout(const Arg *arg) {
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1579
	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
1397
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  1580
		selmon->sellt ^= 1;
1502
15761ac5e2f1 applied Ryan Zheng's patch and re-releasing 5.7.2
Anselm R Garbe <anselm@garbe.us>
parents: 1500
diff changeset
  1581
	if(arg && arg->v)
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1582
		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
1502
15761ac5e2f1 applied Ryan Zheng's patch and re-releasing 5.7.2
Anselm R Garbe <anselm@garbe.us>
parents: 1500
diff changeset
  1583
	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1584
	if(selmon->sel)
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1585
		arrange(selmon);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1586
	else
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1587
		drawbar(selmon);
1289
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1588
}
064cfe1e8f84 untested monocle
Anselm R Garbe <garbeam@gmail.com>
parents: 1288
diff changeset
  1589
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1590
/* arg > 1.0 will set mfact absolutly */
1160
bf37ef388dd6 revival of mfact and setmfact
Anselm R Garbe <garbeam@gmail.com>
parents: 1159
diff changeset
  1591
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1592
setmfact(const Arg *arg) {
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1593
	float f;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1594
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  1595
	if(!arg || !selmon->lt[selmon->sellt]->arrange)
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1596
		return;
1400
a5312d498a58 some minor fixes regarding the new xinerama support
Anselm R Garbe <anselm@garbe.us>
parents: 1399
diff changeset
  1597
	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1598
	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
  1599
		return;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1600
	selmon->mfact = selmon->mfacts[selmon->curtag] = f;
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1601
	arrange(selmon);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1602
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1603
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1604
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1605
setup(void) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1606
	XSetWindowAttributes wa;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1607
1478
cf5bb4e72804 added merged patch of anydot and Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1477
diff changeset
  1608
	/* clean up any zombies immediately */
cf5bb4e72804 added merged patch of anydot and Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1477
diff changeset
  1609
	sigchld(0);
cf5bb4e72804 added merged patch of anydot and Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1477
diff changeset
  1610
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1611
	/* init screen */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1612
	screen = DefaultScreen(dpy);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1613
	root = RootWindow(dpy, screen);
1275
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1614
	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
  1615
	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
  1616
	sh = DisplayHeight(dpy, screen);
1275
e121660425a0 removed font and color definitions
Anselm R Garbe <garbeam@gmail.com>
parents: 1273
diff changeset
  1617
	bh = dc.h = dc.font.height + 2;
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1618
	updategeom();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1619
	/* init atoms */
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1620
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1621
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1622
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1623
	wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1624
	netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1625
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1626
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
1514
2a8d8d41e50b applied Sylvain Laurent's EWMH fullscreen state patch, simplified his patch a bit
anselm@garbe.us
parents: 1511
diff changeset
  1627
	netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1628
	netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1629
	netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1630
	netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1631
	/* init cursors */
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1632
	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1633
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1634
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1635
	/* init appearance */
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1636
	dc.norm[ColBorder] = getcolor(normbordercolor, dc.xftnorm+ColBorder);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1637
	dc.norm[ColBG] = getcolor(normbgcolor, dc.xftnorm+ColBG);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1638
	dc.norm[ColFG] = getcolor(normfgcolor, dc.xftnorm+ColFG);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1639
	dc.sel[ColBorder] = getcolor(selbordercolor, dc.xftsel+ColBorder);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1640
	dc.sel[ColBG] = getcolor(selbgcolor, dc.xftsel+ColBG);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1641
	dc.sel[ColFG] = getcolor(selfgcolor, dc.xftsel+ColFG);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1642
	dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
1389
b4e7c220422d some NULL fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1388
diff changeset
  1643
	dc.gc = XCreateGC(dpy, root, 0, NULL);
1088
06fbc117e7d8 removed Monitor->dc, unnecessary
Anselm R Garbe <garbeam@gmail.com>
parents: 1087
diff changeset
  1644
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1645
	dc.xftdrawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy,screen), DefaultColormap(dpy,screen));
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1646
	if(!dc.xftdrawable)
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1647
		printf("error, cannot create drawable\n");
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1648
	updatebars();
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  1649
	updatestatus();
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1650
	/* EWMH support per view */
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1651
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1652
			PropModeReplace, (unsigned char *) netatom, NetLast);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1653
	/* select for events */
1403
9bfeee8174c2 hotfixes
Anselm R Garbe <anselm@garbe.us>
parents: 1402
diff changeset
  1654
	wa.cursor = cursor[CurNormal];
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1655
	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1656
	                |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
1114
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1657
	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
31b3935773cb removed View cruft, now back to the roots
anselm@anselm1
parents: 1112
diff changeset
  1658
	XSelectInput(dpy, root, wa.event_mask);
1060
9df583e2c03c Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!
Anselm R. Garbe <garbeam@gmail.com>
parents: 1059
diff changeset
  1659
	grabkeys();
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1660
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1661
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1662
void
1393
deaa276abac1 applied Marc Andre Tanners showhide patch, the removal of ntiled
Anselm R Garbe <garbeam@gmail.com>
parents: 1392
diff changeset
  1663
showhide(Client *c) {
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1664
	if(!c)
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1665
		return;
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1666
	if(ISVISIBLE(c)) { /* show clients top down */
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1667
		XMoveWindow(dpy, c->win, c->x, c->y);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1668
		if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1669
			resize(c, c->x, c->y, c->w, c->h, False);
1393
deaa276abac1 applied Marc Andre Tanners showhide patch, the removal of ntiled
Anselm R Garbe <garbeam@gmail.com>
parents: 1392
diff changeset
  1670
		showhide(c->snext);
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1671
	}
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1672
	else { /* hide clients bottom up */
1393
deaa276abac1 applied Marc Andre Tanners showhide patch, the removal of ntiled
Anselm R Garbe <garbeam@gmail.com>
parents: 1392
diff changeset
  1673
		showhide(c->snext);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1674
		XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
1356
d2658eac8ff9 I prefer doing the check in showhide
Anselm R Garbe <garbeam@gmail.com>
parents: 1355
diff changeset
  1675
	}
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1676
}
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1677
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1678
void
1478
cf5bb4e72804 added merged patch of anydot and Neale
Anselm R Garbe <garbeam@gmail.com>
parents: 1477
diff changeset
  1679
sigchld(int unused) {
1479
31cb815bac41 applied Jukka's sigchld patch
Anselm R Garbe <anselm@garbe.us>
parents: 1478
diff changeset
  1680
	if(signal(SIGCHLD, sigchld) == SIG_ERR)
31cb815bac41 applied Jukka's sigchld patch
Anselm R Garbe <anselm@garbe.us>
parents: 1478
diff changeset
  1681
		die("Can't install SIGCHLD handler");
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1682
	while(0 < waitpid(-1, NULL, WNOHANG));
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1683
}
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1684
1355
9172f2200001 applied Donald Chai's showhide patch in slightly modified ways
Anselm R Garbe <garbeam@gmail.com>
parents: 1354
diff changeset
  1685
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1686
spawn(const Arg *arg) {
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
  1687
	if(fork() == 0) {
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1688
		if(dpy)
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1689
			close(ConnectionNumber(dpy));
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1690
		setsid();
1537
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1691
		if (munlockall())
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1692
		    perror("munlockall()");
1371
fcdbbc9c39de re-applied Neale's spawn patch, credited Neale in LICENSE
a@null
parents: 1370
diff changeset
  1693
		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
  1694
		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
  1695
		perror(" failed");
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1696
		exit(EXIT_SUCCESS);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1697
	}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1698
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1699
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1700
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1701
tag(const Arg *arg) {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1702
	if(selmon->sel && arg->ui & TAGMASK) {
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1703
		selmon->sel->tags = arg->ui & TAGMASK;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1704
		focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1705
		arrange(selmon);
1224
47496de04028 applied Gottox bitmask + void *arg patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1223
diff changeset
  1706
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1707
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1708
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1709
void
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1710
tagmon(const Arg *arg) {
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
  1711
	if(!selmon->sel || !mons->next)
1446
Anselm R Garbe <anselm@garbe.us>
parents: 1445
diff changeset
  1712
		return;
1445
4ad1f24d38ec changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Anselm R Garbe <anselm@garbe.us>
parents: 1444
diff changeset
  1713
	sendmon(selmon->sel, dirtomon(arg->i));
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1714
}
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1715
1257
cd74054c01b0 applied nsz' textnw patch thank you
arg@suckless.org
parents: 1256
diff changeset
  1716
int
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1717
textnw(const char *text, unsigned int len, Bool markup) {
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1718
	PangoRectangle r;
1536
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1719
	if (markup)
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1720
		pango_layout_set_markup(dc.plo, text, len);
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1721
	else {
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1722
		pango_layout_set_attributes(dc.plo, NULL);
932900ff8dbb Don't interpret markup in window titles
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  1723
		pango_layout_set_text(dc.plo, text, len);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1724
	}
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1725
	pango_layout_get_extents(dc.plo, &r, 0);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1726
	return r.width / PANGO_SCALE;
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1727
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1728
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1729
void
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1730
tile(Monitor *m) {
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1731
	unsigned int i, n, h, mw, my, ty;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1732
	Client *c;
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1733
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  1734
	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1735
	if(n == 0)
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1736
		return;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1737
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1738
	if(n > m->nmaster)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1739
		mw = m->nmaster ? m->ww * m->mfact : 0;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1740
	else
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1741
		mw = m->ww;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1742
	for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1743
		if(i < m->nmaster) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1744
			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1745
			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1746
			my += HEIGHT(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1747
		}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1748
		else {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1749
			h = (m->wh - ty) / (n - i);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1750
			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1751
			ty += HEIGHT(c);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1752
		}
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1753
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1754
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  1755
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1756
togglebar(const Arg *arg) {
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1757
	selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
1404
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1758
	updatebarpos(selmon);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1759
	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1760
	arrange(selmon);
1209
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1761
}
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1762
c2dc0bd92158 recent changes, introduced togglebar, changed some defines into variable declarations where possible
Anselm R Garbe <garbeam@gmail.com>
parents: 1207
diff changeset
  1763
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1764
togglefloating(const Arg *arg) {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1765
	if(!selmon->sel)
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1766
		return;
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1767
	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1768
	if(selmon->sel->isfloating)
1443
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1769
		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
dabe14ecb5e9 interactive resizals allow display dimensions again
Anselm R Garbe <anselm@garbe.us>
parents: 1440
diff changeset
  1770
		       selmon->sel->w, selmon->sel->h, False);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1771
	arrange(selmon);
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1772
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1773
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1774
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1775
toggletag(const Arg *arg) {
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1776
	unsigned int newtags;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1777
	unsigned int i;
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1778
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  1779
	if(!selmon->sel)
1338
04c5619da581 applied fix of toggletag by Jan Kaliszewski
Premysl Hruby <dfenze@gmail.com>
parents: 1337
diff changeset
  1780
		return;
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1781
	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1782
	if(newtags) {
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1783
		selmon->sel->tags = newtags;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1784
		if(newtags == ~0) {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1785
			selmon->prevtag = selmon->curtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1786
			selmon->curtag = 0;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1787
		}
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1788
		if(!(newtags & 1 << (selmon->curtag - 1))) {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1789
			selmon->prevtag = selmon->curtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1790
			for (i=0; !(newtags & 1 << i); i++);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1791
			selmon->curtag = i + 1;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1792
		}
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1793
		selmon->sel->tags = newtags;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1794
		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1795
		selmon->mfact = selmon->mfacts[selmon->curtag];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1796
		if (selmon->showbar != selmon->showbars[selmon->curtag])
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1797
			togglebar(NULL);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1798
		focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1799
		arrange(selmon);
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1800
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1801
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1802
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1803
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  1804
toggleview(const Arg *arg) {
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1805
	unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1806
1480
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1807
	if(newtagset) {
a52339f25d95 applied Jukka's cosmetic patch
Anselm R Garbe <anselm@garbe.us>
parents: 1479
diff changeset
  1808
		selmon->tagset[selmon->seltags] = newtagset;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1809
		focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1810
		arrange(selmon);
1288
2b839f9998c8 non-zero
Anselm R Garbe <garbeam@gmail.com>
parents: 1285
diff changeset
  1811
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1812
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1813
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1814
void
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1815
unfocus(Client *c, Bool setfocus) {
1417
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1816
	if(!c)
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1817
		return;
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1818
	grabbuttons(c, False);
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1819
	XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
1519
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1820
	if(setfocus)
72272822ddf2 implemented better fullscreen handling, please test
Anselm R Garbe <anselm@garbe.us>
parents: 1517
diff changeset
  1821
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
1417
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1822
}
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1823
8d447b21ca19 several other focus fixes, introduced unfocus()
Anselm R Garbe <anselm@garbe.us>
parents: 1416
diff changeset
  1824
void
1487
430ebd3c0050 renaming isdestroyed into destroyed
Anselm R Garbe <garbeam@gmail.com>
parents: 1486
diff changeset
  1825
unmanage(Client *c, Bool destroyed) {
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1826
	Monitor *m = c->mon;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1827
	XWindowChanges wc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1828
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1829
	/* The server grab construct avoids race conditions. */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1830
	detach(c);
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1831
	detachstack(c);
1487
430ebd3c0050 renaming isdestroyed into destroyed
Anselm R Garbe <garbeam@gmail.com>
parents: 1486
diff changeset
  1832
	if(!destroyed) {
1485
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1833
		wc.border_width = c->oldbw;
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1834
		XGrabServer(dpy);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1835
		XSetErrorHandler(xerrordummy);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1836
		XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1837
		XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1838
		setclientstate(c, WithdrawnState);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1839
		XSync(dpy, False);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1840
		XSetErrorHandler(xerror);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1841
		XUngrabServer(dpy);
3cde8e2dc511 added isdestroyed flag to unmanage
Anselm R Garbe <garbeam@gmail.com>
parents: 1484
diff changeset
  1842
	}
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1843
	free(c);
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1844
	focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  1845
	arrange(m);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1846
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1847
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1848
void
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1849
unmapnotify(XEvent *e) {
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1850
	Client *c;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1851
	XUnmapEvent *ev = &e->xunmap;
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1852
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1853
	if((c = wintoclient(ev->window))) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1854
		if(ev->send_event)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1855
			setclientstate(c, WithdrawnState);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1856
		else
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1857
			unmanage(c, False);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1858
	}
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1859
}
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  1860
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  1861
void
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1862
updatebars(void) {
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1863
	Monitor *m;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1864
	XSetWindowAttributes wa = {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1865
		.override_redirect = True,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1866
		.background_pixmap = ParentRelative,
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1867
		.event_mask = ButtonPressMask|ExposureMask
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  1868
	};
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1869
	for(m = mons; m; m = m->next) {
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1870
		m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1871
		                          CopyFromParent, DefaultVisual(dpy, screen),
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1872
		                          CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1873
		XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1874
		XMapRaised(dpy, m->barwin);
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1875
	}
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1876
}
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1877
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1878
void
1404
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1879
updatebarpos(Monitor *m) {
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1880
	m->wy = m->my;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1881
	m->wh = m->mh;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1882
	if(m->showbar) {
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1883
		m->wh -= bh;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1884
		m->by = m->topbar ? m->wy : m->wy + m->wh;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1885
		m->wy = m->topbar ? m->wy + bh : m->wy;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1886
	}
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1887
	else
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1888
		m->by = -bh;
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1889
}
2fd482e3405b some more refactoring, bar toggle fixes
Anselm R Garbe <anselm@garbe.us>
parents: 1403
diff changeset
  1890
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
  1891
Bool
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1892
updategeom(void) {
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1893
	Bool dirty = False;
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1894
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1895
#ifdef XINERAMA
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1896
	if(XineramaIsActive(dpy)) {
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1897
		int i, j, n, nn;
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1898
		Client *c;
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1899
		Monitor *m;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1900
		XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1901
		XineramaScreenInfo *unique = NULL;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1902
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1903
		for(n = 0, m = mons; m; m = m->next, n++);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1904
		/* only consider unique geometries as separate screens */
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1905
		if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1906
			die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1907
		for(i = 0, j = 0; i < nn; i++)
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1908
			if(isuniquegeom(unique, j, &info[i]))
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1909
				memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1910
		XFree(info);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1911
		nn = j;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1912
		if(n <= nn) {
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1913
			for(i = 0; i < (nn - n); i++) { /* new monitors available */
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1914
				for(m = mons; m && m->next; m = m->next);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1915
				if(m)
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1916
					m->next = createmon();
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1917
				else
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1918
					mons = createmon();
1492
62a601261c8b new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Anselm R Garbe <anselm@garbe.us>
parents: 1491
diff changeset
  1919
			}
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1920
			for(i = 0, m = mons; i < nn && m; m = m->next, i++)
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1921
				if(i >= n
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1922
				|| (unique[i].x_org != m->mx || unique[i].y_org != m->my
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1923
				    || unique[i].width != m->mw || unique[i].height != m->mh))
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1924
				{
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1925
					dirty = True;
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1926
					m->num = i;
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1927
					m->mx = m->wx = unique[i].x_org;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1928
					m->my = m->wy = unique[i].y_org;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1929
					m->mw = m->ww = unique[i].width;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1930
					m->mh = m->wh = unique[i].height;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1931
					updatebarpos(m);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1932
				}
1311
47b3dbd9a7d3 got rid of compile time xidx configuration, querying mouse pointer instead
Anselm R Garbe <garbeam@gmail.com>
parents: 1310
diff changeset
  1933
		}
1497
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1934
		else { /* less monitors available nn < n */
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1935
			for(i = nn; i < n; i++) {
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1936
				for(m = mons; m && m->next; m = m->next);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1937
				while(m->clients) {
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1938
					dirty = True;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1939
					c = m->clients;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1940
					m->clients = c->next;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1941
					detachstack(c);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1942
					c->mon = mons;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1943
					attach(c);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1944
					attachstack(c);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1945
				}
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1946
				if(m == selmon)
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1947
					selmon = mons;
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1948
				cleanupmon(m);
20de01c5ff82 implemented nn < n case, k-zed please recheck
Anselm R Garbe <anselm@garbe.us>
parents: 1496
diff changeset
  1949
			}
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1950
		}
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1951
		free(unique);
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
  1952
	}
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
  1953
	else
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  1954
#endif /* XINERAMA */
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1955
	/* default monitor setup */
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
  1956
	{
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1957
		if(!mons)
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1958
			mons = createmon();
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1959
		if(mons->mw != sw || mons->mh != sh) {
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1960
			dirty = True;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1961
			mons->mw = mons->ww = sw;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1962
			mons->mh = mons->wh = sh;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1963
			updatebarpos(mons);
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1964
		}
1402
d0721df4028c changes monitor structure to be a list
Anselm R Garbe <garbeam@gmail.com>
parents: 1401
diff changeset
  1965
	}
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1966
	if(dirty) {
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1967
		selmon = mons;
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1968
		selmon = wintomon(root);
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
  1969
	}
1494
e00cb20da182 implemented different version of updategeom
Anselm R Garbe <anselm@garbe.us>
parents: 1493
diff changeset
  1970
	return dirty;
1190
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1971
}
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1972
c8eaba1445a4 removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Anselm R Garbe <garbeam@gmail.com>
parents: 1188
diff changeset
  1973
void
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1974
updatenumlockmask(void) {
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1975
	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
  1976
	XModifierKeymap *modmap;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1977
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1978
	numlockmask = 0;
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1979
	modmap = XGetModifierMapping(dpy);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1980
	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
  1981
		for(j = 0; j < modmap->max_keypermod; j++)
1395
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1982
			if(modmap->modifiermap[i * modmap->max_keypermod + j]
a2c094196714 next version will be 5.6, shortened some very long lines
Anselm R Garbe <garbeam@gmail.com>
parents: 1393
diff changeset
  1983
			   == XKeysymToKeycode(dpy, XK_Num_Lock))
1344
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1984
				numlockmask = (1 << i);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1985
	XFreeModifiermap(modmap);
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1986
}
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1987
ba02dda36aee grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
Anselm R Garbe <garbeam@gmail.com>
parents: 1343
diff changeset
  1988
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1989
updatesizehints(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1990
	long msize;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1991
	XSizeHints size;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1992
1357
33591b7c6bf7 applied XGetWMNormalHints fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1356
diff changeset
  1993
	if(!XGetWMNormalHints(dpy, c->win, &size, &msize))
33591b7c6bf7 applied XGetWMNormalHints fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1356
diff changeset
  1994
		/* size is uninitialized, ensure that size.flags aren't used */
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  1995
		size.flags = PSize;
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  1996
	if(size.flags & PBaseSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1997
		c->basew = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1998
		c->baseh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  1999
	}
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  2000
	else if(size.flags & PMinSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2001
		c->basew = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2002
		c->baseh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2003
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2004
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2005
		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
  2006
	if(size.flags & PResizeInc) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2007
		c->incw = size.width_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2008
		c->inch = size.height_inc;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2009
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2010
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2011
		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
  2012
	if(size.flags & PMaxSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2013
		c->maxw = size.max_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2014
		c->maxh = size.max_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2015
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2016
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2017
		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
  2018
	if(size.flags & PMinSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2019
		c->minw = size.min_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2020
		c->minh = size.min_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2021
	}
1249
1fcb3350609d applied noviewprev.diff, fix.diff and unusedflags.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1248
diff changeset
  2022
	else if(size.flags & PBaseSize) {
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2023
		c->minw = size.base_width;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2024
		c->minh = size.base_height;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2025
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2026
	else
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2027
		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
  2028
	if(size.flags & PAspect) {
1466
aa47da304ae2 it's all nsz's hard investigation effort, hail nsz! ;)
Anselm R Garbe <garbeam@gmail.com>
parents: 1464
diff changeset
  2029
		c->mina = (float)size.min_aspect.y / size.min_aspect.x;
aa47da304ae2 it's all nsz's hard investigation effort, hail nsz! ;)
Anselm R Garbe <garbeam@gmail.com>
parents: 1464
diff changeset
  2030
		c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2031
	}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2032
	else
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  2033
		c->maxa = c->mina = 0.0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2034
	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
  2035
	             && c->maxw == c->minw && c->maxh == c->minh);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2036
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2037
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  2038
void
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2039
updatetitle(Client *c) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2040
	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
  2041
		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
1460
606761ddf6d6 mark broken clients as broken
anselm@x200s.config
parents: 1459
diff changeset
  2042
	if(c->name[0] == '\0') /* hack to mark broken clients */
606761ddf6d6 mark broken clients as broken
anselm@x200s.config
parents: 1459
diff changeset
  2043
		strcpy(c->name, broken);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2044
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2045
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2046
void
1425
120ed5f8018b fixed several issues with focus handling via mouse, also added sending clients to the right monitor they belong to after mouse moves/resizals
Anselm R Garbe <anselm@garbe.us>
parents: 1424
diff changeset
  2047
updatestatus(void) {
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  2048
	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
  2049
		strcpy(stext, "dwm-"VERSION);
1398
597063a22a73 experimental xinerama support, two new actions, Mod1-w/e and Mod1-Shift-w/e
Anselm R Garbe <anselm@garbe.us>
parents: 1397
diff changeset
  2050
	drawbar(selmon);
1370
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  2051
}
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  2052
6d6ed7a9183c applied Neale Pickett's xprop status reading patch, updated README and dwm.1 accordingly
a@null
parents: 1369
diff changeset
  2053
void
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2054
updatewindowtype(Client *c) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2055
	Atom state = getatomprop(c, netatom[NetWMState]);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2056
	Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2057
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2058
	if(state == netatom[NetWMFullscreen])
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2059
		setfullscreen(c, True);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2060
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2061
	if(wtype == netatom[NetWMWindowTypeDialog])
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2062
		c->isfloating = True;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2063
}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2064
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2065
void
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2066
updatewmhints(Client *c) {
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2067
	XWMHints *wmh;
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2068
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2069
	if((wmh = XGetWMHints(dpy, c->win))) {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  2070
		if(c == selmon->sel && wmh->flags & XUrgencyHint) {
1309
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  2071
			wmh->flags &= ~XUrgencyHint;
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  2072
			XSetWMHints(dpy, c->win, wmh);
3affae730034 applied anydot's urgency hint patch, thanks!
anselm@aab
parents: 1308
diff changeset
  2073
		}
1122
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  2074
		else
6f93af279e0a fixed urgent hint handling
Anselm R Garbe <garbeam@gmail.com>
parents: 1121
diff changeset
  2075
			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2076
		if(wmh->flags & InputHint)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2077
			c->neverfocus = !wmh->input;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2078
		else
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2079
			c->neverfocus = False;
1080
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2080
		XFree(wmh);
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2081
	}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2082
}
9bfb57c89407 implemented urgent hint handling (with multihead support)
anselm@aab
parents: 1079
diff changeset
  2083
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  2084
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  2085
view(const Arg *arg) {
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2086
	unsigned int i;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2087
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
  2088
	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
1304
ef3327d0517a minor fix to view()
Anselm R Garbe <garbeam@gmail.com>
parents: 1303
diff changeset
  2089
		return;
1397
4498d81938b0 introduction of Monitor for better Xinerama support, work in progress
Anselm R Garbe <anselm@garbe.us>
parents: 1396
diff changeset
  2090
	selmon->seltags ^= 1; /* toggle sel tagset */
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2091
	if(arg->ui & TAGMASK) {
1401
8cee6e329111 we need a tagset per monitor, removed tagset declaration from config.h
Anselm R Garbe <anselm@garbe.us>
parents: 1400
diff changeset
  2092
		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
1531
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2093
		selmon->prevtag = selmon->curtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2094
		if(arg->ui == ~0)
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2095
			selmon->curtag = 0;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2096
		else {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2097
			for (i=0; !(arg->ui & 1 << i); i++);
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2098
			selmon->curtag = i + 1;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2099
		}
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2100
	} else {
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2101
		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2102
		selmon->curtag^= selmon->prevtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2103
		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2104
	}
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2105
	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2106
	selmon->mfact = selmon->mfacts[selmon->curtag];
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2107
	if(selmon->showbar != selmon->showbars[selmon->curtag])
606ac98e35df Pango patch,
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2108
		togglebar(NULL);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2109
	focus(NULL);
1500
48c3f87c335d fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
Anselm R Garbe <anselm@garbe.us>
parents: 1497
diff changeset
  2110
	arrange(selmon);
1104
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  2111
}
167446962e09 simplified dwm
anselm@anselm1
parents: 1103
diff changeset
  2112
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2113
Client *
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2114
wintoclient(Window w) {
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2115
	Client *c;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2116
	Monitor *m;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2117
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2118
	for(m = mons; m; m = m->next)
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2119
		for(c = m->clients; c; c = c->next)
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2120
			if(c->win == w)
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2121
				return c;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2122
	return NULL;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2123
}
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2124
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2125
Monitor *
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2126
wintomon(Window w) {
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2127
	int x, y;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2128
	Client *c;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2129
	Monitor *m;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2130
1450
b2d18a052137 some minor changes
Anselm R Garbe <garbeam@gmail.com>
parents: 1449
diff changeset
  2131
	if(w == root && getrootptr(&x, &y))
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2132
		return recttomon(x, y, 1, 1);
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2133
	for(m = mons; m; m = m->next)
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2134
		if(w == m->barwin)
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2135
			return m;
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2136
	if((c = wintoclient(w)))
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2137
		return c->mon;
1438
9e3da779b59b minor fix
Anselm R Garbe <garbeam@gmail.com>
parents: 1437
diff changeset
  2138
	return selmon;
1430
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2139
}
c4b9f97e4bd7 several simplifications
Anselm R Garbe <anselm@garbe.us>
parents: 1429
diff changeset
  2140
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2141
/* 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
  2142
 * 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
  2143
 * 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
  2144
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2145
xerror(Display *dpy, XErrorEvent *ee) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2146
	if(ee->error_code == BadWindow
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2147
	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2148
	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2149
	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2150
	|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2151
	|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
1186
48ffaf800504 applied JUCE patch
Anselm R Garbe <garbeam@gmail.com>
parents: 1185
diff changeset
  2152
	|| (ee->request_code == X_GrabButton && ee->error_code == BadAccess)
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2153
	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2154
	|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2155
		return 0;
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2156
	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
  2157
			ee->request_code, ee->error_code);
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2158
	return xerrorxlib(dpy, ee); /* may call exit */
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2159
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2160
1001
2477f818215c made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
arg@suckless.org
parents: 1000
diff changeset
  2161
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
  2162
xerrordummy(Display *dpy, XErrorEvent *ee) {
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  2163
	return 0;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2164
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2165
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  2166
/* Startup Error handler to check if another window manager
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  2167
 * 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
  2168
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
  2169
xerrorstart(Display *dpy, XErrorEvent *ee) {
1528
b4f5309d6253 applied Hiltjo's cleanup patch
Anselm R Garbe <anselm@garbe.us>
parents: 1527
diff changeset
  2170
	die("dwm: another window manager is already running\n");
996
b4d47b6a8ba8 ordered all functions alphabetically
Anselm R. Garbe <garbeam@gmail.com>
parents: 995
diff changeset
  2171
	return -1;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2172
}
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2173
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  2174
void
1260
2d3d08d2dd19 applied anydot's patchset.diff
Anselm R Garbe <garbeam@gmail.com>
parents: 1259
diff changeset
  2175
zoom(const Arg *arg) {
1407
4cbf60555bd8 moved clients/stack/sel to Monitor, that's a per monitor structure from now on
Anselm R Garbe <anselm@garbe.us>
parents: 1406
diff changeset
  2176
	Client *c = selmon->sel;
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  2177
1448
d012c6babc13 applied Mate's patch, added Mate to LICENSE
Anselm R Garbe <anselm@garbe.us>
parents: 1447
diff changeset
  2178
	if(!selmon->lt[selmon->sellt]->arrange
1444
19dc2b0c61e2 removed some empty lines
Anselm R Garbe <anselm@garbe.us>
parents: 1443
diff changeset
  2179
	|| (selmon->sel && selmon->sel->isfloating))
1227
1f0e2de78c35 s/nextunfloating/nexttiled/, changed zoom() behavior
Anselm R Garbe <garbeam@gmail.com>
parents: 1226
diff changeset
  2180
		return;
1408
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  2181
	if(c == nexttiled(selmon->clients))
2215f7f11dd9 simplified ISVISBLE and nexttiled
Anselm R Garbe <anselm@garbe.us>
parents: 1407
diff changeset
  2182
		if(!c || !(c = nexttiled(c->next)))
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  2183
			return;
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2184
	pop(c);
1220
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  2185
}
6603d83d133d merged tile.c again into dwm.c
anselm@anselm1
parents: 1219
diff changeset
  2186
1072
5a06b4b69479 merged Christof Musik's Xinerama support patches, though this needs some polishing!
anselm@anselm1
parents: 1071
diff changeset
  2187
int
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2188
main(int argc, char *argv[]) {
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2189
	if(argc == 2 && !strcmp("-v", argv[1]))
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2190
		die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n");
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2191
	else if(argc != 1)
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
  2192
		die("usage: dwm [-v]\n");
1343
f4707b7bd3a2 reverted some resize() changes, reverted setlocale removal
Anselm R Garbe <garbeam@gmail.com>
parents: 1342
diff changeset
  2193
	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
1387
dbcd0ffca535 applied Gottox' adjustborder removal patch (thanks!)
Anselm R Garbe <garbeam@gmail.com>
parents: 1386
diff changeset
  2194
		fputs("warning: no locale support\n", stderr);
1389
b4e7c220422d some NULL fixes
Anselm R Garbe <garbeam@gmail.com>
parents: 1388
diff changeset
  2195
	if(!(dpy = XOpenDisplay(NULL)))
1308
978d14197052 renamed eprint die
Anselm R Garbe <garbeam@gmail.com>
parents: 1307
diff changeset
  2196
		die("dwm: cannot open display\n");
1537
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  2197
	if (mlockall(MCL_CURRENT | MCL_FUTURE))
Stiletto <blasux@blasux.ru>
parents: 1534
diff changeset
  2198
		perror("mlockall()");
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  2199
	checkotherwm();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2200
	setup();
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2201
	scan();
997
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  2202
	run();
8e721021e636 some more rearrangements
Anselm R. Garbe <garbeam@gmail.com>
parents: 996
diff changeset
  2203
	cleanup();
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2204
	XCloseDisplay(dpy);
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents: 1530
diff changeset
  2205
	return EXIT_SUCCESS;
990
70f6fcd100b7 micromizing dwm step 1
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
  2206
}