screen.c
author Anselm R. Garbe <garbeam@gmail.com>
Sat, 15 Sep 2007 13:16:54 +0200
changeset 988 aea51354bbe6
parent 987 ea0cef59c3a3
permissions -rw-r--r--
moved bar-related stuff to bar.c (merged draw.c into that)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     1
/* See LICENSE file for copyright and license details. */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     2
#include "dwm.h"
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     3
#include <regex.h>
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     4
#include <stdio.h>
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     5
#include <stdlib.h>
973
98750b173cd5 setlayout should perform strcmp's if arg != NULL, because Layout is local to screen.o
Anselm R. Garbe <garbeam@gmail.com>
parents: 971
diff changeset
     6
#include <string.h>
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     7
#include <X11/Xutil.h>
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     8
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
     9
/* static */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    10
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    11
typedef struct {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    12
	const char *symbol;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    13
	void (*arrange)(void);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    14
} Layout;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    15
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    16
typedef struct {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    17
	const char *prop;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    18
	const char *tags;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    19
	Bool isfloating;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    20
} Rule;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    21
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    22
typedef struct {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    23
	regex_t *propregex;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    24
	regex_t *tagregex;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    25
} Regs;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    26
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    27
TAGS
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    28
RULES
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    29
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    30
static unsigned int nrules = 0;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    31
static unsigned int nlayouts = 0;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    32
static unsigned int ltidx = 0; /* default */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    33
static Regs *regs = NULL;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    34
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    35
static unsigned int
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    36
idxoftag(const char *tag) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    37
	unsigned int i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    38
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    39
	for(i = 0; i < ntags; i++)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    40
		if(tags[i] == tag)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    41
			return i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    42
	return 0;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    43
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    44
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    45
static void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    46
floating(void) { /* default floating layout */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    47
	Client *c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    48
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    49
	for(c = clients; c; c = c->next)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    50
		if(isvisible(c))
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    51
			resize(c, c->x, c->y, c->w, c->h, True);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    52
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    53
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    54
LAYOUTS
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    55
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    56
/* extern */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    57
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    58
unsigned int blw = 0;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    59
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    60
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    61
applyrules(Client *c) {
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
    62
	static char buf[512];
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    63
	unsigned int i, j;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    64
	regmatch_t tmp;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    65
	Bool matched = False;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    66
	XClassHint ch = { 0 };
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    67
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    68
	/* rule matching */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    69
	XGetClassHint(dpy, c->win, &ch);
970
d5c3537ee3be renamed char prop[] into buf[]
Anselm R. Garbe <garbeam@gmail.com>
parents: 969
diff changeset
    70
	snprintf(buf, sizeof buf, "%s:%s:%s",
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    71
			ch.res_class ? ch.res_class : "",
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    72
			ch.res_name ? ch.res_name : "", c->name);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    73
	for(i = 0; i < nrules; i++)
970
d5c3537ee3be renamed char prop[] into buf[]
Anselm R. Garbe <garbeam@gmail.com>
parents: 969
diff changeset
    74
		if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) {
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    75
			c->isfloating = rules[i].isfloating;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    76
			for(j = 0; regs[i].tagregex && j < ntags; j++) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    77
				if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    78
					matched = True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    79
					c->tags[j] = True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    80
				}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    81
			}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    82
		}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    83
	if(ch.res_class)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    84
		XFree(ch.res_class);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    85
	if(ch.res_name)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    86
		XFree(ch.res_name);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    87
	if(!matched)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    88
		for(i = 0; i < ntags; i++)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    89
			c->tags[i] = seltags[i];
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    90
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    91
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    92
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    93
arrange(void) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    94
	Client *c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    95
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    96
	for(c = clients; c; c = c->next)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    97
		if(isvisible(c))
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    98
			unban(c);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
    99
		else
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   100
			ban(c);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   101
	layouts[ltidx].arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   102
	focus(NULL);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   103
	restack();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   104
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   105
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   106
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   107
compileregs(void) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   108
	unsigned int i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   109
	regex_t *reg;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   110
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   111
	if(regs)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   112
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   113
	nrules = sizeof rules / sizeof rules[0];
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   114
	regs = emallocz(nrules * sizeof(Regs));
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   115
	for(i = 0; i < nrules; i++) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   116
		if(rules[i].prop) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   117
			reg = emallocz(sizeof(regex_t));
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   118
			if(regcomp(reg, rules[i].prop, REG_EXTENDED))
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   119
				free(reg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   120
			else
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   121
				regs[i].propregex = reg;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   122
		}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   123
		if(rules[i].tags) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   124
			reg = emallocz(sizeof(regex_t));
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   125
			if(regcomp(reg, rules[i].tags, REG_EXTENDED))
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   126
				free(reg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   127
			else
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   128
				regs[i].tagregex = reg;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   129
		}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   130
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   131
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   132
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   133
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   134
focusnext(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   135
	Client *c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   136
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   137
	if(!sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   138
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   139
	for(c = sel->next; c && !isvisible(c); c = c->next);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   140
	if(!c)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   141
		for(c = clients; c && !isvisible(c); c = c->next);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   142
	if(c) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   143
		focus(c);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   144
		restack();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   145
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   146
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   147
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   148
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   149
focusprev(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   150
	Client *c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   151
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   152
	if(!sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   153
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   154
	for(c = sel->prev; c && !isvisible(c); c = c->prev);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   155
	if(!c) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   156
		for(c = clients; c && c->next; c = c->next);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   157
		for(; c && !isvisible(c); c = c->prev);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   158
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   159
	if(c) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   160
		focus(c);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   161
		restack();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   162
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   163
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   164
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   165
const char *
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   166
getsymbol(void)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   167
{
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   168
	return layouts[ltidx].symbol;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   169
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   170
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   171
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   172
initlayouts(void) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   173
	unsigned int i, w;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   174
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   175
	nlayouts = sizeof layouts / sizeof layouts[0];
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   176
	for(blw = i = 0; i < nlayouts; i++) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   177
		w = textw(layouts[i].symbol);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   178
		if(w > blw)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   179
			blw = w;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   180
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   181
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   182
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   183
Bool
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   184
isfloating(void) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   185
	return layouts[ltidx].arrange == floating;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   186
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   187
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   188
Bool
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   189
isarrange(void (*func)())
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   190
{
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   191
	return func == layouts[ltidx].arrange;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   192
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   193
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   194
Bool
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   195
isvisible(Client *c) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   196
	unsigned int i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   197
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   198
	for(i = 0; i < ntags; i++)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   199
		if(c->tags[i] && seltags[i])
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   200
			return True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   201
	return False;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   202
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   203
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   204
Client *
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   205
nexttiled(Client *c) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   206
	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   207
	return c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   208
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   209
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   210
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   211
restack(void) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   212
	Client *c;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   213
	XEvent ev;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   214
	XWindowChanges wc;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   215
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 976
diff changeset
   216
	drawbar();
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   217
	if(!sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   218
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   219
	if(sel->isfloating || isfloating())
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   220
		XRaiseWindow(dpy, sel->win);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   221
	if(!isfloating()) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   222
		wc.stack_mode = Below;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   223
		wc.sibling = barwin;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   224
		if(!sel->isfloating) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   225
			XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   226
			wc.sibling = sel->win;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   227
		}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   228
		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   229
			if(c == sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   230
				continue;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   231
			XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   232
			wc.sibling = c->win;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   233
		}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   234
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   235
	XSync(dpy, False);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   236
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   237
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   238
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   239
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   240
setlayout(const char *arg) {
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
   241
	unsigned int i;
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   242
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   243
	if(!arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   244
		if(++ltidx == nlayouts)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   245
			ltidx = 0;;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   246
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   247
	else {
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
   248
		for(i = 0; i < nlayouts; i++)
973
98750b173cd5 setlayout should perform strcmp's if arg != NULL, because Layout is local to screen.o
Anselm R. Garbe <garbeam@gmail.com>
parents: 971
diff changeset
   249
			if(!strcmp(arg, layouts[i].symbol))
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
   250
				break;
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
   251
		if(i == nlayouts)
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   252
			return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   253
		ltidx = i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   254
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   255
	if(sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   256
		arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   257
	else
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 976
diff changeset
   258
		drawbar();
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   259
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   260
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   261
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   262
tag(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   263
	unsigned int i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   264
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   265
	if(!sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   266
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   267
	for(i = 0; i < ntags; i++)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   268
		sel->tags[i] = arg == NULL;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   269
	i = idxoftag(arg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   270
	if(i >= 0 && i < ntags)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   271
		sel->tags[i] = True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   272
	arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   273
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   274
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   275
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   276
togglefloating(const char *arg) {
976
7c117df5d202 prepared 4.4.1 bugfix and minor feature enhancement release
Anselm R. Garbe <garbeam@gmail.com>
parents: 973
diff changeset
   277
	if(!sel)
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   278
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   279
	sel->isfloating = !sel->isfloating;
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 970
diff changeset
   280
	if(sel->isfloating)
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   281
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   282
	arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   283
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   284
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   285
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   286
togglemax(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   287
	XEvent ev;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   288
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   289
	if(!sel || (!isfloating() && !sel->isfloating) || sel->isfixed)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   290
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   291
	if((sel->ismax = !sel->ismax)) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   292
		sel->rx = sel->x;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   293
		sel->ry = sel->y;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   294
		sel->rw = sel->w;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   295
		sel->rh = sel->h;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   296
		resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   297
	}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   298
	else
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   299
		resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 976
diff changeset
   300
	drawbar();
967
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   301
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   302
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   303
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   304
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   305
toggletag(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   306
	unsigned int i, j;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   307
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   308
	if(!sel)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   309
		return;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   310
	i = idxoftag(arg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   311
	sel->tags[i] = !sel->tags[i];
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   312
	for(j = 0; j < ntags && !sel->tags[j]; j++);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   313
	if(j == ntags)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   314
		sel->tags[i] = True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   315
	arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   316
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   317
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   318
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   319
toggleview(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   320
	unsigned int i, j;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   321
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   322
	i = idxoftag(arg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   323
	seltags[i] = !seltags[i];
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   324
	for(j = 0; j < ntags && !seltags[j]; j++);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   325
	if(j == ntags)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   326
		seltags[i] = True; /* cannot toggle last view */
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   327
	arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   328
}
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   329
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   330
void
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   331
view(const char *arg) {
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   332
	unsigned int i;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   333
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   334
	for(i = 0; i < ntags; i++)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   335
		seltags[i] = arg == NULL;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   336
	i = idxoftag(arg);
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   337
	if(i >= 0 && i < ntags)
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   338
		seltags[i] = True;
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   339
	arrange();
66f17bf2c278 added screen.c, removed layout.c and tag.c
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff changeset
   340
}