layout.c
author Anselm R. Garbe <garbeam@gmail.com>
Sat, 04 Aug 2007 10:57:56 +0200
changeset 934 1e8e98b7544d
parent 933 f7619f63380a
child 935 2032654a0c6d
permissions -rw-r--r--
small fix of static function order
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
910
c13cb8c6b7a5 referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents: 909
diff changeset
     1
/* See LICENSE file for copyright and license details. */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     2
#include "dwm.h"
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
     3
#include <stdio.h>
825
bef1854ce739 fixed some issues due to the Arg->const char * transition
Anselm R. Garbe <arg@suckless.org>
parents: 823
diff changeset
     4
#include <stdlib.h>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     5
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
     6
unsigned int blw = 0;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
     7
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
     8
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
     9
/* static */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    10
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    11
static double hratio = HRATIO;
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    12
static double vratio = VRATIO;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    13
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
    14
static unsigned int nmaster = NMASTER;
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
    15
932
df47d77ec9a6 removed a C++ style comment
Anselm R. Garbe <garbeam@gmail.com>
parents: 931
diff changeset
    16
static double /* simple pow() */
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    17
spow(double x, double y)
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    18
{
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    19
	if(y == 0)
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    20
		return 1;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    21
	while(--y)
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    22
		x *= x;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    23
	return x;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    24
}
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    25
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
    26
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
    27
tile(void) {
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    28
	double mscale = 0, tscale = 0, sum = 0;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    29
	unsigned int i, n, nx, ny, nw, nh, mw, tw;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    30
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    31
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    32
	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
    33
		n++;
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    34
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    35
	mw = (n <= nmaster) ? waw :  waw / (1 + hratio);
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    36
	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
    37
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    38
	if(n > 0) {
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    39
		if(n < nmaster) {
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    40
			for(i = 0; i < n; i++)
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    41
				sum += spow(vratio, i);
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    42
			mscale = wah / sum;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    43
		}
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    44
		else {
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    45
			for(i = 0; i < nmaster; i++)
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    46
				sum += spow(vratio, i);
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    47
			mscale = wah / sum;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    48
			for(sum = 0, i = 0; i < (n - nmaster); i++)
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    49
				sum += spow(vratio, i);
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    50
			tscale = wah / sum;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    51
		}
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    52
	}
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    53
	nx = wax;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    54
	ny = way;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    55
	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
    56
		if(isvisible(c)) {
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
    57
			unban(c);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
    58
			if(c->isfloating)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    59
				continue;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    60
			c->ismax = False;
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    61
			if(i < nmaster) { /* master window */
861
55691060ffa3 changed border handling
Anselm R. Garbe <arg@suckless.org>
parents: 858
diff changeset
    62
				nw = mw - 2 * c->border;
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    63
				if(i + 1 == n || i + 1 == nmaster)
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    64
					nh = (way + wah) - ny - (2 * c->border);
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    65
				else
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    66
					nh = (mscale * spow(vratio, i)) - (2 * c->border);
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    67
			}
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    68
			else { /* tile window */
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    69
				if(i == nmaster) {
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    70
					ny = way;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    71
					nx = wax + mw;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    72
				}
861
55691060ffa3 changed border handling
Anselm R. Garbe <arg@suckless.org>
parents: 858
diff changeset
    73
				nw = tw - 2 * c->border;
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    74
				if(i + 1 == n)
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    75
					nh = (way + wah) - ny - (2 * c->border);
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    76
				else
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
    77
					nh = (tscale * spow(vratio, i - nmaster)) - (2 * c->border);
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    78
			}
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    79
			if(nh < bh) {
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    80
				nh = bh;
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    81
				ny = way + wah - nh;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    82
			}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    83
			resize(c, nx, ny, nw, nh, False);
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
    84
			ny += nh;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    85
			i++;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    86
		}
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
    87
		else
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
    88
			ban(c);
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
    89
	focus(NULL);
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    90
	restack();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    91
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    92
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
    93
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
    94
934
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
    95
static void
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
    96
incratio(const char *arg, double *ratio, double def) {
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
    97
	double delta;
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
    98
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
    99
	if(lt->arrange != tile)
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   100
		return;
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   101
	if(!arg)
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   102
		*ratio = def;
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   103
	else {
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   104
		if(1 == sscanf(arg, "%lf", &delta)) {
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   105
			if(delta + (*ratio) < .1 || delta + (*ratio) > 1.9)
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   106
				return;
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   107
			*ratio += delta;
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   108
		}
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   109
	}
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   110
	lt->arrange();
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   111
}
1e8e98b7544d small fix of static function order
Anselm R. Garbe <garbeam@gmail.com>
parents: 933
diff changeset
   112
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
   113
/* 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
   114
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
   115
void
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   116
floating(void) {
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   117
	Client *c;
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   118
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
   119
	for(c = clients; c; c = c->next)
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   120
		if(isvisible(c)) {
914
dad36921af06 applied anudots [un]ban repair patch
Anselm R. Garbe <arg@suckless.org>
parents: 912
diff changeset
   121
			unban(c);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   122
			resize(c, c->x, c->y, c->w, c->h, True);
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   123
		}
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
   124
		else
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
   125
			ban(c);
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 901
diff changeset
   126
	focus(NULL);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   127
	restack();
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   128
}
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   129
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   130
void
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   131
focusclient(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
   132
	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
   133
   
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   134
	if(!sel || !arg)
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   135
		return;
831
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   136
	if(atoi(arg) < 0) {
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   137
		for(c = sel->prev; c && !isvisible(c); c = c->prev);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   138
		if(!c) {
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   139
			for(c = clients; c && c->next; c = c->next);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   140
			for(; c && !isvisible(c); c = c->prev);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
   141
		}
831
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   142
	}
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   143
	else {
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   144
		for(c = sel->next; c && !isvisible(c); c = c->next);
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   145
		if(!c)
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   146
			for(c = clients; c && !isvisible(c); c = c->next);
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
   147
	}
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
   148
	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
   149
		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
   150
		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
   151
	}
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
   152
}
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
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
void
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   155
inchratio(const char *arg) {
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   156
	incratio(arg, &hratio, HRATIO);
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   157
}
931
8ff0f913999e implemented ratio tile as described on the mailinglist
Anselm R. Garbe <garbeam@gmail.com>
parents: 918
diff changeset
   158
933
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   159
void
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   160
incvratio(const char *arg) {
f7619f63380a I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves like in dwm-4.3, config.arg.h shows how I prefer the ratio being handled (for the future I plan to change const char *arg into ..., and renaming Client into Win.)
Anselm R. Garbe <garbeam@gmail.com>
parents: 932
diff changeset
   161
	incratio(arg, &vratio, VRATIO);
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
   162
}
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
   163
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
   164
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
   165
incnmaster(const char *arg) {
826
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   166
	int i;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   167
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   168
	if(!arg)
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   169
		nmaster = NMASTER;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   170
	else {
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   171
		i = atoi(arg);
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   172
		if((lt->arrange != tile) || (nmaster + i < 1)
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   173
		|| (wah / (nmaster + i) <= 2 * BORDERPX))
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   174
			return;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   175
		nmaster += i;
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   176
	}
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   177
	if(sel)
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   178
		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
   179
	else
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   180
		drawstatus();
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
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   183
void
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   184
initlayouts(void) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   185
	unsigned int i, w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   186
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   187
	lt = &layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   188
	nlayouts = sizeof layout / sizeof layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   189
	for(blw = i = 0; i < nlayouts; i++) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   190
		w = textw(layout[i].symbol);
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   191
		if(w > blw)
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   192
			blw = w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   193
	}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   194
}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   195
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
   196
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
   197
nexttiled(Client *c) {
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   198
	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
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
   199
	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
   200
}
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
   201
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   202
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   203
restack(void) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   204
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   205
	XEvent ev;
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   206
	XWindowChanges wc;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   207
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   208
	drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   209
	if(!sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   210
		return;
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   211
	if(sel->isfloating || lt->arrange == floating)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   212
		XRaiseWindow(dpy, sel->win);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   213
	if(lt->arrange != floating) {
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   214
		wc.stack_mode = Below;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   215
		wc.sibling = barwin;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   216
		if(!sel->isfloating) {
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   217
			XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   218
			wc.sibling = sel->win;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   219
		}
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   220
		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
   221
			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
   222
				continue;
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   223
			XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   224
			wc.sibling = c->win;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   225
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   226
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   227
	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
   228
	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
   229
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   230
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   231
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
   232
setlayout(const char *arg) {
826
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   233
	int i;
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   234
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
   235
	if(!arg) {
891
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   236
		lt++;
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   237
		if(lt == layout + nlayouts)
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   238
			lt = layout;
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   239
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   240
	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
   241
		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
   242
		if(i < 0 || i >= nlayouts)
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   243
			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
   244
		lt = &layout[i];
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   245
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   246
	if(sel)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   247
		lt->arrange();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   248
	else
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   249
		drawstatus();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   250
}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   251
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   252
void
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   253
togglebar(const char *arg) {
887
44755dcf1ad4 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 883
diff changeset
   254
	if(bpos == BarOff)
44755dcf1ad4 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 883
diff changeset
   255
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
883
2cbf1010be11 using BarTop as fallback if BARPOS is set to BarOff as default for toggling
Anselm R. Garbe <arg@suckless.org>
parents: 880
diff changeset
   256
	else
2cbf1010be11 using BarTop as fallback if BARPOS is set to BarOff as default for toggling
Anselm R. Garbe <arg@suckless.org>
parents: 880
diff changeset
   257
		bpos = BarOff;
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   258
	updatebarpos();
880
f330be522eca another fix, call lt->arrange() in togglebar only
Anselm R. Garbe <arg@suckless.org>
parents: 878
diff changeset
   259
	lt->arrange();
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   260
}
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   261
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   262
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
   263
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
   264
	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
   265
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   266
	if(!sel || (lt->arrange != floating && !sel->isfloating) || 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
   267
		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
   268
	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
   269
		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
   270
		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
   271
		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
   272
		sel->rh = sel->h;
912
f7b26d6efc9f replaced BORDERPX with sel->border in togglemax(), in other places this is not possible.
Anselm R. Garbe <arg@suckless.org>
parents: 910
diff changeset
   273
		resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
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
   274
	}
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
   275
	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
   276
		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
   277
	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
   278
	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
   279
}
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
   280
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
   281
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
   282
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
   283
	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
   284
892
42bf8e618d52 applied Szabolcs proposal for zoom() as well
Anselm R. Garbe <arg@suckless.org>
parents: 891
diff changeset
   285
	if(!sel || lt->arrange == floating || sel->isfloating)
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
   286
		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
   287
	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
   288
		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
   289
			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
   290
	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
   291
	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
   292
	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
   293
	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
   294
}