screen.c
author Anselm R. Garbe <arg@suckless.org>
Mon, 19 Feb 2007 18:33:15 +0100
changeset 788 a61fcdf7b4c1
parent 786 d9198e713310
permissions -rw-r--r--
replaced togglelayout with setlayout
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"
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
     5
#include <regex.h>
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
     6
#include <stdio.h>
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
     7
#include <stdlib.h>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     8
#include <string.h>
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
     9
#include <sys/types.h>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    10
#include <X11/Xutil.h>
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    11
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    12
unsigned int master = MASTER;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    13
unsigned int nmaster = NMASTER;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    14
unsigned int blw = 0;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    15
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
    16
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    17
/* static */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    18
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
    19
typedef struct {
774
9447a518cd85 renamed Rule members, renamed RReg into Regexps
Anselm R. Garbe <arg@suckless.org>
parents: 773
diff changeset
    20
	const char *prop;
9447a518cd85 renamed Rule members, renamed RReg into Regexps
Anselm R. Garbe <arg@suckless.org>
parents: 773
diff changeset
    21
	const char *tags;
786
d9198e713310 renamed Client->versatile and Rule->versatile into Client->isversatile resp. Rule->isversatile
Anselm R. Garbe <arg@suckless.org>
parents: 785
diff changeset
    22
	Bool isversatile;
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
    23
} Rule;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
    24
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
    25
typedef struct {
774
9447a518cd85 renamed Rule members, renamed RReg into Regexps
Anselm R. Garbe <arg@suckless.org>
parents: 773
diff changeset
    26
	regex_t *propregex;
9447a518cd85 renamed Rule members, renamed RReg into Regexps
Anselm R. Garbe <arg@suckless.org>
parents: 773
diff changeset
    27
	regex_t *tagregex;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    28
} Regs;
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
    29
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 144
diff changeset
    30
TAGS
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 144
diff changeset
    31
RULES
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 80
diff changeset
    32
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    33
static Regs *regs = NULL;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    34
static unsigned int nrules = 0;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    35
static unsigned int nlayouts = 0;
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
    36
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
    37
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
    38
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
    39
	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
    40
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    41
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    42
	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
    43
		n++;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    44
	/* window geoms */
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    45
	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    46
	mw = (n > nmaster) ? (waw * master) / 1000 : waw;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    47
	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
    48
	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
    49
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    50
	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
    51
		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
    52
			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
    53
				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
    54
			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
    55
			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
    56
				continue;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    57
			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
    58
			nx = wax;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    59
			ny = way;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    60
			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
    61
				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
    62
				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
    63
				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
    64
			}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    65
			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
    66
				nx += mw;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    67
				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
    68
				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
    69
					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
    70
					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
    71
				}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    72
				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
    73
					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
    74
			}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    75
			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
    76
			i++;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    77
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    78
		else {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    79
			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
    80
			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
    81
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    82
	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
    83
		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
    84
		focus(c);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    85
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    86
	restack();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    87
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    88
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
    89
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
    90
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
    91
/* 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
    92
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
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
    94
compileregs(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
    95
	unsigned int i;
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
    96
	regex_t *reg;
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
    97
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
    98
	if(regs)
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
    99
		return;
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
   100
	nrules = sizeof rule / sizeof rule[0];
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
   101
	regs = emallocz(nrules * sizeof(Regs));
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
   102
	for(i = 0; i < nrules; i++) {
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
   103
		if(rule[i].prop) {
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
   104
			reg = emallocz(sizeof(regex_t));
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
   105
			if(regcomp(reg, rule[i].prop, REG_EXTENDED))
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
   106
				free(reg);
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
   107
			else
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
   108
				regs[i].propregex = reg;
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
   109
		}
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
   110
		if(rule[i].tags) {
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
   111
			reg = emallocz(sizeof(regex_t));
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
   112
			if(regcomp(reg, rule[i].tags, REG_EXTENDED))
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
				free(reg);
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
			else
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
				regs[i].tagregex = reg;
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
   116
		}
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
   117
	}
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
   118
}
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
   119
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   120
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   121
incnmaster(Arg *arg) {
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
   122
	if((lt->arrange != tile) || (nmaster + arg->i < 1)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   123
	|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   124
		return;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   125
	nmaster += arg->i;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   126
	if(sel)
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   127
		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
   128
	else
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   129
		drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   130
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   131
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   132
void
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   133
initlayouts(void) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   134
	unsigned int i, w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   135
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   136
	lt = &layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   137
	nlayouts = sizeof layout / sizeof layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   138
	for(blw = i = 0; i < nlayouts; i++) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   139
		w = textw(layout[i].symbol);
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   140
		if(w > blw)
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   141
			blw = w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   142
	}
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
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   145
Bool
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   146
isvisible(Client *c) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   147
	unsigned int i;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   148
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   149
	for(i = 0; i < ntags; i++)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   150
		if(c->tags[i] && seltag[i])
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   151
			return True;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   152
	return False;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   153
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   154
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   155
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   156
resizemaster(Arg *arg) {
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
   157
	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
   158
		return;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   159
	if(arg->i == 0)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   160
		master = MASTER;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   161
	else {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   162
		if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   163
		|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   164
			return;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   165
		master += arg->i;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   166
	}
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   167
	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
   168
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   169
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   170
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   171
restack(void) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   172
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   173
	XEvent ev;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   174
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   175
	drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   176
	if(!sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   177
		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
   178
	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
   179
		XRaiseWindow(dpy, sel->win);
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   180
	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
   181
		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
   182
			XLowerWindow(dpy, sel->win);
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   183
		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
   184
			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
   185
				continue;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   186
			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
   187
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   188
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   189
	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
   190
	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
   191
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   192
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   193
void
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   194
setlayout(Arg *arg) {
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   195
	unsigned int i;
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   196
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   197
	if(arg->i == -1) {
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   198
		for(i = 0; i < nlayouts && lt != &layout[i]; i++);
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   199
		if(i == nlayouts - 1)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   200
			lt = &layout[0];
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
			lt = &layout[++i];
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
	else {
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   205
		if(arg->i < 0 || arg->i >= nlayouts)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   206
			return;
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   207
		lt = &layout[arg->i];
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   208
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   209
	if(sel)
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   210
		lt->arrange();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   211
	else
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   212
		drawstatus();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   213
}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   214
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   215
void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 441
diff changeset
   216
settags(Client *c, Client *trans) {
336
2a65e8b3d21a implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents: 327
diff changeset
   217
	char prop[512];
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
   218
	unsigned int i, j;
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
   219
	regmatch_t tmp;
431
a230e4432bb7 moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   220
	Bool matched = trans != NULL;
742
39b941868ce3 adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
   221
	XClassHint ch = { 0 };
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   222
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 742
diff changeset
   223
	if(matched)
431
a230e4432bb7 moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   224
		for(i = 0; i < ntags; i++)
a230e4432bb7 moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   225
			c->tags[i] = trans->tags[i];
742
39b941868ce3 adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
   226
	else {
39b941868ce3 adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
   227
		XGetClassHint(dpy, c->win, &ch);
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 573
diff changeset
   228
		snprintf(prop, sizeof prop, "%s:%s:%s",
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
   229
				ch.res_class ? ch.res_class : "",
336
2a65e8b3d21a implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents: 327
diff changeset
   230
				ch.res_name ? ch.res_name : "", c->name);
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   231
		for(i = 0; i < nrules; i++)
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   232
			if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
786
d9198e713310 renamed Client->versatile and Rule->versatile into Client->isversatile resp. Rule->isversatile
Anselm R. Garbe <arg@suckless.org>
parents: 785
diff changeset
   233
				c->isversatile = rule[i].isversatile;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   234
				for(j = 0; regs[i].tagregex && j < ntags; j++) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   235
					if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
191
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
   236
						matched = True;
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
   237
						c->tags[j] = True;
56fee1dc9d53 switched to regexp matching for Rules
arg@10ksloc.org
parents: 178
diff changeset
   238
					}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   239
				}
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 104
diff changeset
   240
			}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   241
		if(ch.res_class)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   242
			XFree(ch.res_class);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   243
		if(ch.res_name)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   244
			XFree(ch.res_name);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   245
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   246
	if(!matched)
261
d6fd632d861c implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents: 240
diff changeset
   247
		for(i = 0; i < ntags; i++)
262
d659a2dce2b5 implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature
Anselm R.Garbe <arg@10ksloc.org>
parents: 261
diff changeset
   248
			c->tags[i] = seltag[i];
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   249
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   250
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   251
void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 441
diff changeset
   252
tag(Arg *arg) {
284
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   253
	unsigned int i;
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   254
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   255
	if(!sel)
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   256
		return;
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   257
	for(i = 0; i < ntags; i++)
594
f7dcd3ac8d6f removed viewall(), replaced with view(-1); added tag(-1) to tag a client with all tags (new key combo MODKEY-Shift-0)
arg@mig29
parents: 581
diff changeset
   258
		sel->tags[i] = (arg->i == -1) ? True : False;
611
c7f84f23ec5a hotfix of a serious crashing bug
arg@mig29
parents: 609
diff changeset
   259
	if(arg->i >= 0 && arg->i < ntags)
c7f84f23ec5a hotfix of a serious crashing bug
arg@mig29
parents: 609
diff changeset
   260
		sel->tags[arg->i] = True;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   261
	lt->arrange();
284
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   262
}
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   263
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   264
void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 441
diff changeset
   265
toggletag(Arg *arg) {
284
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   266
	unsigned int i;
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   267
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   268
	if(!sel)
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   269
		return;
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   270
	sel->tags[arg->i] = !sel->tags[arg->i];
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   271
	for(i = 0; i < ntags && !sel->tags[i]; i++);
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   272
	if(i == ntags)
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   273
		sel->tags[arg->i] = True;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   274
	lt->arrange();
284
5f5c56e104de changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents: 277
diff changeset
   275
}
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   276
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   277
void
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   278
toggleversatile(Arg *arg) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   279
	if(!sel || lt->arrange == versatile)
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   280
		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
   281
	sel->isversatile = !sel->isversatile;
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   282
	lt->arrange();
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   283
}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   284
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   285
void
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   286
toggleview(Arg *arg) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   287
	unsigned int i;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   288
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   289
	seltag[arg->i] = !seltag[arg->i];
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   290
	for(i = 0; i < ntags && !seltag[i]; i++);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   291
	if(i == ntags)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   292
		seltag[arg->i] = True; /* cannot toggle last view */
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   293
	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
   294
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   295
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   296
void
785
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   297
versatile(void) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   298
	Client *c;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   299
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   300
	for(c = clients; c; c = c->next) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   301
		if(isvisible(c)) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   302
			if(c->isbanned)
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   303
				XMoveWindow(dpy, c->win, c->x, c->y);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   304
			c->isbanned = False;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   305
			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
   306
		}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   307
		else {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   308
			c->isbanned = True;
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   309
			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
   310
		}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   311
	}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   312
	if(!sel || !isvisible(sel)) {
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   313
		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
   314
		focus(c);
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   315
	}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   316
	restack();
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   317
}
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   318
179a71394e49 renames swim[ming] into versatile
Anselm R. Garbe <arg@suckless.org>
parents: 784
diff changeset
   319
void
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   320
view(Arg *arg) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   321
	unsigned int i;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   322
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   323
	for(i = 0; i < ntags; i++)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   324
		seltag[i] = (arg->i == -1) ? True : False;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   325
	if(arg->i >= 0 && arg->i < ntags)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   326
		seltag[arg->i] = True;
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
   327
	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
   328
}