layout.c
author Anselm R. Garbe <arg@suckless.org>
Thu, 22 Feb 2007 12:15:48 +0100
changeset 826 d900a3f821a3
parent 825 bef1854ce739
child 829 f1ec35606dbc
permissions -rw-r--r--
small bugfix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
644
1ed8c40dde36 corrections
arg@mig29
parents: 643
diff changeset
     1
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     2
 * See LICENSE file for license details.
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     3
 */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     4
#include "dwm.h"
825
bef1854ce739 fixed some issues due to the Arg->const char * transition
Anselm R. Garbe <arg@suckless.org>
parents: 823
diff changeset
     5
#include <stdlib.h>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     6
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
     7
unsigned int blw = 0;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
     8
Layout *lt = NULL;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
     9
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    10
/* static */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    11
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    12
static unsigned int nlayouts = 0;
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
    13
static unsigned int masterw = MASTERWIDTH;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
    14
static unsigned int nmaster = NMASTER;
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
    15
784
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    16
static void
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    17
tile(void) {
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    18
	unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    19
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    20
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    21
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    22
		n++;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    23
	/* window geoms */
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    24
	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
    25
	mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    26
	th = (n > nmaster) ? wah / (n - nmaster) : 0;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    27
	tw = waw - mw;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    28
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    29
	for(i = 0, c = clients; c; c = c->next)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    30
		if(isvisible(c)) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    31
			if(c->isbanned)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    32
				XMoveWindow(dpy, c->win, c->x, c->y);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    33
			c->isbanned = False;
786
d9198e713310 renamed Client->versatile and Rule->versatile into Client->isversatile resp. Rule->isversatile
Anselm R. Garbe <arg@suckless.org>
parents: 785
diff changeset
    34
			if(c->isversatile)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    35
				continue;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    36
			c->ismax = False;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    37
			nx = wax;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    38
			ny = way;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    39
			if(i < nmaster) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    40
				ny += i * mh;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    41
				nw = mw - 2 * BORDERPX;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    42
				nh = mh - 2 * BORDERPX;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    43
			}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    44
			else {  /* tile window */
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    45
				nx += mw;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    46
				nw = tw - 2 * BORDERPX;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    47
				if(th > 2 * BORDERPX) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    48
					ny += (i - nmaster) * th;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    49
					nh = th - 2 * BORDERPX;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    50
				}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    51
				else /* fallback if th <= 2 * BORDERPX */
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    52
					nh = wah - 2 * BORDERPX;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    53
			}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    54
			resize(c, nx, ny, nw, nh, False);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    55
			i++;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    56
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    57
		else {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    58
			c->isbanned = True;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    59
			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    60
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    61
	if(!sel || !isvisible(sel)) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    62
		for(c = stack; c && !isvisible(c); c = c->snext);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    63
		focus(c);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    64
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    65
	restack();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    66
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    67
784
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    68
LAYOUTS
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    69
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    70
/* extern */
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    71
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    72
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
    73
focusnext(const char *arg) {
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    74
	Client *c;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    75
   
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    76
	if(!sel)
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    77
		return;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    78
	for(c = sel->next; c && !isvisible(c); c = c->next);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    79
	if(!c)
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    80
		for(c = clients; c && !isvisible(c); c = c->next);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    81
	if(c) {
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    82
		focus(c);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    83
		restack();
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    84
	}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    85
}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    86
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    87
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
    88
focusprev(const char *arg) {
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    89
	Client *c;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    90
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    91
	if(!sel)
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    92
		return;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    93
	for(c = sel->prev; c && !isvisible(c); c = c->prev);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    94
	if(!c) {
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    95
		for(c = clients; c && c->next; c = c->next);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    96
		for(; c && !isvisible(c); c = c->prev);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    97
	}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    98
	if(c) {
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    99
		focus(c);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   100
		restack();
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   101
	}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   102
}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   103
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   104
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   105
incmasterw(const char *arg) {
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   106
	int i;
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   107
	if(lt->arrange != tile)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   108
		return;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   109
	if(!arg)
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   110
		masterw = MASTERWIDTH;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   111
	else {
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   112
		i = atoi(arg);
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   113
		if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   114
		|| waw * (masterw + i) / 1000 <= 2 * BORDERPX)
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   115
			return;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   116
		masterw += i;
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   117
	}
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   118
	lt->arrange();
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   119
}
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   120
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   121
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   122
incnmaster(const char *arg) {
826
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   123
	int i;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   124
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   125
	if(!arg)
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   126
		nmaster = NMASTER;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   127
	else {
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   128
		i = atoi(arg);
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   129
		if((lt->arrange != tile) || (nmaster + i < 1)
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   130
		|| (wah / (nmaster + i) <= 2 * BORDERPX))
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   131
			return;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   132
		nmaster += i;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   133
	}
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   134
	if(sel)
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   135
		lt->arrange();
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   136
	else
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   137
		drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   138
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   139
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   140
void
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   141
initlayouts(void) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   142
	unsigned int i, w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   143
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   144
	lt = &layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   145
	nlayouts = sizeof layout / sizeof layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   146
	for(blw = i = 0; i < nlayouts; i++) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   147
		w = textw(layout[i].symbol);
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   148
		if(w > blw)
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   149
			blw = w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   150
	}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   151
}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   152
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   153
Client *
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   154
nexttiled(Client *c) {
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   155
	for(; c && (c->isversatile || !isvisible(c)); c = c->next);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   156
	return c;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   157
}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   158
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   159
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   160
restack(void) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   161
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   162
	XEvent ev;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   163
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   164
	drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   165
	if(!sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   166
		return;
786
d9198e713310 renamed Client->versatile and Rule->versatile into Client->isversatile resp. Rule->isversatile
Anselm R. Garbe <arg@suckless.org>
parents: 785
diff changeset
   167
	if(sel->isversatile || lt->arrange == versatile)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   168
		XRaiseWindow(dpy, sel->win);
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   169
	if(lt->arrange != versatile) {
786
d9198e713310 renamed Client->versatile and Rule->versatile into Client->isversatile resp. Rule->isversatile
Anselm R. Garbe <arg@suckless.org>
parents: 785
diff changeset
   170
		if(!sel->isversatile)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   171
			XLowerWindow(dpy, sel->win);
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   172
		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   173
			if(c == sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   174
				continue;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   175
			XLowerWindow(dpy, c->win);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   176
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   177
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   178
	XSync(dpy, False);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   179
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   180
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   181
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   182
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   183
setlayout(const char *arg) {
826
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   184
	int i;
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   185
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   186
	if(!arg) {
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   187
		for(i = 0; i < nlayouts && lt != &layout[i]; i++);
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   188
		if(i == nlayouts - 1)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   189
			lt = &layout[0];
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   190
		else
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   191
			lt = &layout[++i];
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   192
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   193
	else {
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   194
		i = atoi(arg);
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   195
		if(i < 0 || i >= nlayouts)
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   196
			return;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   197
		lt = &layout[i];
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   198
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   199
	if(sel)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   200
		lt->arrange();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   201
	else
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   202
		drawstatus();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   203
}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   204
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   205
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   206
togglemax(const char *arg) {
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   207
	XEvent ev;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   208
815
aca93bbd6e8d fixed exit condition in togglemax()
Anselm R. Garbe <arg@suckless.org>
parents: 813
diff changeset
   209
	if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed)
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   210
		return;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   211
	if((sel->ismax = !sel->ismax)) {
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   212
		sel->rx = sel->x;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   213
		sel->ry = sel->y;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   214
		sel->rw = sel->w;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   215
		sel->rh = sel->h;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   216
		resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   217
	}
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   218
	else
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   219
		resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
819
21562c2567a6 status needs update even in togglemax() - since we got an indicator for this
Anselm R. Garbe <arg@suckless.org>
parents: 815
diff changeset
   220
	drawstatus();
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   221
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   222
}
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   223
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   224
void
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   225
versatile(void) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   226
	Client *c;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   227
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   228
	for(c = clients; c; c = c->next) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   229
		if(isvisible(c)) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   230
			if(c->isbanned)
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   231
				XMoveWindow(dpy, c->win, c->x, c->y);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   232
			c->isbanned = False;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   233
			resize(c, c->x, c->y, c->w, c->h, True);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   234
		}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   235
		else {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   236
			c->isbanned = True;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   237
			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   238
		}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   239
	}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   240
	if(!sel || !isvisible(sel)) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   241
		for(c = stack; c && !isvisible(c); c = c->snext);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   242
		focus(c);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   243
	}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   244
	restack();
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   245
}
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   246
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   247
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   248
zoom(const char *arg) {
813
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   249
	unsigned int n;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   250
	Client *c;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   251
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   252
	if(!sel || lt->arrange != tile || sel->isversatile)
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   253
		return;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   254
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   255
		n++;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   256
	if((c = sel) == nexttiled(clients))
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   257
		if(!(c = nexttiled(c->next)))
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   258
			return;
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   259
	detach(c);
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   260
	attach(c);
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   261
	focus(c);
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   262
	lt->arrange();
0ed770c96e51 several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Anselm R. Garbe <arg@suckless.org>
parents: 799
diff changeset
   263
}