tag.c
author Anselm R. Garbe <arg@suckless.org>
Tue, 20 Feb 2007 10:49:53 +0100
changeset 790 48e7c3b45250
child 791 9ab130668f41
permissions -rw-r--r--
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
790
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     1
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     2
 * See LICENSE file for license details.
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     3
 */
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     4
#include "dwm.h"
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     5
#include <regex.h>
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     6
#include <stdio.h>
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     7
#include <X11/Xutil.h>
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     8
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     9
/* static */
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    10
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    11
typedef struct {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    12
	const char *prop;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    13
	const char *tags;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    14
	Bool isversatile;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    15
} Rule;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    16
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    17
typedef struct {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    18
	regex_t *propregex;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    19
	regex_t *tagregex;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    20
} Regs;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    21
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    22
TAGS
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    23
RULES
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    24
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    25
static Regs *regs = NULL;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    26
static unsigned int nrules = 0;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    27
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    28
/* extern */
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    29
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    30
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    31
compileregs(void) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    32
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    33
	regex_t *reg;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    34
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    35
	if(regs)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    36
		return;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    37
	nrules = sizeof rule / sizeof rule[0];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    38
	regs = emallocz(nrules * sizeof(Regs));
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    39
	for(i = 0; i < nrules; i++) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    40
		if(rule[i].prop) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    41
			reg = emallocz(sizeof(regex_t));
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    42
			if(regcomp(reg, rule[i].prop, REG_EXTENDED))
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    43
				free(reg);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    44
			else
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    45
				regs[i].propregex = reg;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    46
		}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    47
		if(rule[i].tags) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    48
			reg = emallocz(sizeof(regex_t));
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    49
			if(regcomp(reg, rule[i].tags, REG_EXTENDED))
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    50
				free(reg);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    51
			else
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    52
				regs[i].tagregex = reg;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    53
		}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    54
	}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    55
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    56
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    57
Bool
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    58
isvisible(Client *c) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    59
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    60
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    61
	for(i = 0; i < ntags; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    62
		if(c->tags[i] && seltag[i])
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    63
			return True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    64
	return False;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    65
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    66
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    67
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    68
settags(Client *c, Client *trans) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    69
	char prop[512];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    70
	unsigned int i, j;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    71
	regmatch_t tmp;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    72
	Bool matched = trans != NULL;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    73
	XClassHint ch = { 0 };
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    74
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    75
	if(matched)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    76
		for(i = 0; i < ntags; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    77
			c->tags[i] = trans->tags[i];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    78
	else {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    79
		XGetClassHint(dpy, c->win, &ch);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    80
		snprintf(prop, sizeof prop, "%s:%s:%s",
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    81
				ch.res_class ? ch.res_class : "",
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    82
				ch.res_name ? ch.res_name : "", c->name);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    83
		for(i = 0; i < nrules; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    84
			if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    85
				c->isversatile = rule[i].isversatile;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    86
				for(j = 0; regs[i].tagregex && j < ntags; j++) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    87
					if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    88
						matched = True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    89
						c->tags[j] = True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    90
					}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    91
				}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    92
			}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    93
		if(ch.res_class)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    94
			XFree(ch.res_class);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    95
		if(ch.res_name)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    96
			XFree(ch.res_name);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    97
	}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    98
	if(!matched)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    99
		for(i = 0; i < ntags; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   100
			c->tags[i] = seltag[i];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   101
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   102
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   103
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   104
tag(Arg *arg) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   105
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   106
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   107
	if(!sel)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   108
		return;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   109
	for(i = 0; i < ntags; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   110
		sel->tags[i] = (arg->i == -1) ? True : False;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   111
	if(arg->i >= 0 && arg->i < ntags)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   112
		sel->tags[arg->i] = True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   113
	lt->arrange();
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   114
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   115
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   116
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   117
toggletag(Arg *arg) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   118
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   119
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   120
	if(!sel)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   121
		return;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   122
	sel->tags[arg->i] = !sel->tags[arg->i];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   123
	for(i = 0; i < ntags && !sel->tags[i]; i++);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   124
	if(i == ntags)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   125
		sel->tags[arg->i] = True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   126
	lt->arrange();
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   127
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   128
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   129
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   130
toggleview(Arg *arg) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   131
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   132
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   133
	seltag[arg->i] = !seltag[arg->i];
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   134
	for(i = 0; i < ntags && !seltag[i]; i++);
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   135
	if(i == ntags)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   136
		seltag[arg->i] = True; /* cannot toggle last view */
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   137
	lt->arrange();
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   138
}
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   139
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   140
void
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   141
view(Arg *arg) {
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   142
	unsigned int i;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   143
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   144
	for(i = 0; i < ntags; i++)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   145
		seltag[i] = (arg->i == -1) ? True : False;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   146
	if(arg->i >= 0 && arg->i < ntags)
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   147
		seltag[arg->i] = True;
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   148
	lt->arrange();
48e7c3b45250 split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   149
}