view.c
author Anselm R. Garbe <arg@10kloc.org>
Fri, 29 Sep 2006 16:54:15 +0200
changeset 510 0dfa6b752aed
parent 508 ede48935f2b3
child 511 1599c953647b
permissions -rw-r--r--
small fix of a corner case
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     1
/*
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     2
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     3
 * See LICENSE file for license details.
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     4
 */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     5
#include "dwm.h"
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
     6
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
     7
/* static */
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
     8
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
     9
static Client *
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 486
diff changeset
    10
minclient(void) {
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    11
	Client *c, *min;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    12
443
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    13
	if((clients && clients->isfloat) || arrange == dofloat)
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    14
		return clients; /* don't touch floating order */
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    15
	for(min = c = clients; c; c = c->next)
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    16
		if(c->weight < min->weight)
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    17
			min = c;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    18
	return min;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    19
}
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    20
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    21
static Client *
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    22
nexttiled(Client *c) {
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    23
	for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    24
	return c;
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    25
}
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    26
442
056a5072c70a no this is better
Anselm R. Garbe <arg@10kloc.org>
parents: 437
diff changeset
    27
static void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 486
diff changeset
    28
reorder(void) {
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    29
	Client *c, *newclients, *tail;
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
    30
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    31
	newclients = tail = NULL;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    32
	while((c = minclient())) {
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
    33
		detach(c);
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    34
		if(tail) {
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    35
			c->prev = tail;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    36
			tail->next = c;
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    37
			tail = c;
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
    38
		}
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
    39
		else
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    40
			tail = newclients = c;
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
    41
	}
382
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    42
	clients = newclients;
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
    43
}
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
    44
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    45
static void
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    46
togglemax(Client *c)
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    47
{
481
arg@mmvi
parents: 480
diff changeset
    48
	XEvent ev;
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    49
	if((c->ismax = !c->ismax)) {
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    50
		c->rx = c->x; c->x = sx;
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    51
		c->ry = c->y; c->y = bh;
502
9aa3d06199cb applied Jukkas patch
Anselm R. Garbe <arg@10kloc.org>
parents: 488
diff changeset
    52
		c->rw = c->w; c->w = sw - 2 * BORDERPX;
9aa3d06199cb applied Jukkas patch
Anselm R. Garbe <arg@10kloc.org>
parents: 488
diff changeset
    53
		c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    54
	}
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    55
	else {
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    56
		c->x = c->rx;
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    57
		c->y = c->ry;
481
arg@mmvi
parents: 480
diff changeset
    58
		c->w = c->rw;
arg@mmvi
parents: 480
diff changeset
    59
		c->h = c->rh;
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    60
	}
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    61
	resize(c, True, TopLeft);
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
    62
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
430
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
    63
}
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
    64
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    65
/* extern */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    66
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    67
void (*arrange)(Arg *) = DEFMODE;
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
    68
Bool isvertical = VERTICALSTACK;
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
    69
StackPos stackpos = STACKPOS;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    70
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    71
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: 450
diff changeset
    72
detach(Client *c) {
378
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    73
	if(c->prev)
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    74
		c->prev->next = c->next;
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    75
	if(c->next)
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    76
		c->next->prev = c->prev;
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    77
	if(c == clients)
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    78
		clients = c->next;
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    79
	c->next = c->prev = NULL;
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    80
}
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    81
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    82
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: 450
diff changeset
    83
dofloat(Arg *arg) {
402
c7d5ff57998d removed unused vars
Anselm R. Garbe <arg@10kloc.org>
parents: 401
diff changeset
    84
	Client *c;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 397
diff changeset
    85
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    86
	for(c = clients; c; c = c->next) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    87
		if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    88
			resize(c, True, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    89
		}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    90
		else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    91
			ban(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    92
	}
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 443
diff changeset
    93
	if(!sel || !isvisible(sel)) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
    94
		for(c = stack; c && !isvisible(c); c = c->snext);
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
    95
		focus(c);
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 443
diff changeset
    96
	}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    97
	restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    98
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
    99
504
0cefc169ff67 renamed column into area
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   100
/* This algorithm is based on a (M)aster area and a (S)tacking area.
0cefc169ff67 renamed column into area
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   101
 * It supports following arrangements:
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   102
 * 	SSMMM	MMMMM	MMMSS
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   103
 * 	SSMMM	SSSSS	MMMSS
504
0cefc169ff67 renamed column into area
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   104
 */
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   105
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: 450
diff changeset
   106
dotile(Arg *arg) {
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   107
	int i, n, stackw, stackh, tw, th;
402
c7d5ff57998d removed unused vars
Anselm R. Garbe <arg@10kloc.org>
parents: 401
diff changeset
   108
	Client *c;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 397
diff changeset
   109
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
   110
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
   111
		n++;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   112
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   113
	if(stackpos == StackBottom) {
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   114
		stackw = sw;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   115
		stackh = sh - bh - master;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   116
	}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   117
	else {
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   118
		stackw = sw - master;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   119
		stackh = sh - bh;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   120
	}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   121
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
   122
	if(isvertical) {
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   123
		tw = stackw;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   124
		if(n > 1)
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   125
			th = stackh / (n - 1);
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   126
		else
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   127
			th = stackh;
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
   128
	}
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   129
	else {
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   130
		th = stackh;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   131
		if(n > 1)
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   132
			tw = stackw / (n - 1);
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   133
		else
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   134
			tw = stackw;
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
   135
	}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   136
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   137
	for(i = 0, c = clients; c; c = c->next) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   138
		if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   139
			if(c->isfloat) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   140
				resize(c, True, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   141
				continue;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   142
			}
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
   143
			c->ismax = False;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   144
			if(n == 1) { /* only 1 window */
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   145
				c->x = sx;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   146
				c->y = sy + bh;
502
9aa3d06199cb applied Jukkas patch
Anselm R. Garbe <arg@10kloc.org>
parents: 488
diff changeset
   147
				c->w = sw - 2 * BORDERPX;
9aa3d06199cb applied Jukkas patch
Anselm R. Garbe <arg@10kloc.org>
parents: 488
diff changeset
   148
				c->h = sh - 2 * BORDERPX - bh;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   149
			}
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   150
			else if(i == 0) { /* master window */
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   151
				switch(stackpos) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   152
				case StackLeft:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   153
					c->x = sx + stackw;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   154
					c->y = sy + bh;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   155
					c->w = master - 2 * BORDERPX;
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   156
					c->h = sh - bh - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   157
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   158
				case StackBottom:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   159
					c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   160
					c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   161
					c->w = sw - 2 * BORDERPX;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   162
					c->h = master - 2 * BORDERPX;
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   163
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   164
				case StackRight:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   165
					c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   166
					c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   167
					c->w = master - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   168
					c->h = sh - bh - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   169
					break;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   170
				}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   171
			}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   172
			else if((isvertical && th > bh) || (!isvertical && tw > MINW)) {
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   173
				/* tile window */
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   174
				c->w = tw - 2 * BORDERPX;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   175
				c->h = th - 2 * BORDERPX;
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   176
				switch(stackpos) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   177
				case StackLeft:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   178
					if(isvertical) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   179
						c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   180
						c->y = sy + (i - 1) * th + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   181
						if(i + 1 == n)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   182
							c->h = sh - c->y - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   183
					}
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   184
					else {
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   185
						c->x = sx + (i - 1) * tw;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   186
						c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   187
						if(i + 1 == n)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   188
							c->w = sx + stackw - c->x - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   189
					}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   190
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   191
				case StackBottom:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   192
					if(isvertical) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   193
						c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   194
						c->y = sy + master + (i - 1) * th + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   195
						if(i + 1 == n)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   196
							c->h = sh - c->y - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   197
					}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   198
					else {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   199
						c->x = sx + (i - 1) * tw;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   200
						c->y = sy + bh + master;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   201
						if(i + 1 == n)
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   202
							c->w = sw - c->x - 2 * BORDERPX;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   203
					}
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   204
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   205
				case StackRight:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   206
					if(isvertical) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   207
						c->x = sx + master;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   208
						c->y = sy + (i - 1) * th + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   209
						if(i + 1 == n)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   210
							c->h = sh - c->y - 2 * BORDERPX;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   211
					}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   212
					else {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   213
						c->x = sx + master + (i - 1) * tw;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   214
						c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   215
						if(i + 1 == n)
510
0dfa6b752aed small fix of a corner case
Anselm R. Garbe <arg@10kloc.org>
parents: 508
diff changeset
   216
							c->w = sw - c->x - 2 * BORDERPX;
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   217
					}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   218
					break;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   219
				}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   220
			}
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   221
			else { /* fallback if th < bh resp. tw < MINW */
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   222
				c->w = stackw - 2 * BORDERPX;
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   223
				c->h = stackh - 2 * BORDERPX;
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   224
				switch(stackpos) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   225
				case StackLeft:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   226
					c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   227
					c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   228
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   229
				case StackBottom:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   230
					c->x = sx;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   231
					c->y = sy + master;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   232
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   233
				case StackRight:
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   234
					c->x = sx + master;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   235
					c->y = sy + bh;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   236
					break;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   237
				}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   238
			}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   239
			resize(c, False, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   240
			i++;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   241
		}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   242
		else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   243
			ban(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   244
	}
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 443
diff changeset
   245
	if(!sel || !isvisible(sel)) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
   246
		for(c = stack; c && !isvisible(c); c = c->snext);
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
   247
		focus(c);
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 443
diff changeset
   248
	}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   249
	restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   250
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   251
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   252
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: 450
diff changeset
   253
focusnext(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   254
	Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   255
   
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   256
	if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   257
		return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   258
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   259
	if(!(c = getnext(sel->next)))
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   260
		c = getnext(clients);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   261
	if(c) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   262
		focus(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   263
		restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   264
	}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   265
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   266
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   267
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: 450
diff changeset
   268
focusprev(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   269
	Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   270
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   271
	if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   272
		return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   273
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   274
	if(!(c = getprev(sel->prev))) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   275
		for(c = clients; c && c->next; c = c->next);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   276
		c = getprev(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   277
	}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   278
	if(c) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   279
		focus(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   280
		restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   281
	}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   282
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   283
420
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   284
Bool
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: 450
diff changeset
   285
isvisible(Client *c) {
420
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   286
	unsigned int i;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   287
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   288
	for(i = 0; i < ntags; i++)
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   289
		if(c->tags[i] && seltag[i])
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   290
			return True;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   291
	return False;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   292
}
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
   293
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   294
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: 450
diff changeset
   295
resizecol(Arg *arg) {
423
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   296
	unsigned int n;
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   297
	Client *c;
418
Anselm R. Garbe <arg@10kloc.org>
parents: 417
diff changeset
   298
430
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
   299
	for(n = 0, c = clients; c; c = c->next)
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
   300
		if(isvisible(c) && !c->isfloat)
423
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   301
			n++;
486
8d564b9e3cd4 removed all dotile checks
arg@mmvi
parents: 485
diff changeset
   302
	if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   303
		return;
423
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   304
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   305
	if(sel == getnext(clients)) {
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   306
		if(master + arg->i > sw - MINW || master + arg->i < MINW)
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   307
			return;
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
   308
		master += arg->i;
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   309
	}
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   310
	else {
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
   311
		if(master - arg->i > sw - MINW || master - arg->i < MINW)
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   312
			return;
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 504
diff changeset
   313
		master -= arg->i;
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   314
	}
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   315
	arrange(NULL);
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   316
}
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
   317
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   318
void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 486
diff changeset
   319
restack(void) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   320
	Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   321
	XEvent ev;
481
arg@mmvi
parents: 480
diff changeset
   322
437
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
   323
	if(!sel) {
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
   324
		drawstatus();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   325
		return;
437
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
   326
	}
436
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   327
	if(sel->isfloat || arrange == dofloat) {
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   328
		XRaiseWindow(dpy, sel->win);
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   329
		XRaiseWindow(dpy, sel->twin);
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   330
	}
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 443
diff changeset
   331
	if(arrange != dofloat)
436
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   332
		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   333
			XLowerWindow(dpy, c->twin);
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
   334
			XLowerWindow(dpy, c->win);
414
c6ffcc201229 don't access sel in restack without checking for NULL (multihead crashing bug)
Anselm R. Garbe <arg@10kloc.org>
parents: 402
diff changeset
   335
		}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   336
	drawall();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   337
	XSync(dpy, False);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   338
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   339
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   340
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   341
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: 450
diff changeset
   342
togglemode(Arg *arg) {
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 327
diff changeset
   343
	arrange = (arrange == dofloat) ? dotile : dofloat;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   344
	if(sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   345
		arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   346
	else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   347
		drawstatus();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   348
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   349
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   350
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: 450
diff changeset
   351
toggleview(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   352
	unsigned int i;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   353
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   354
	seltag[arg->i] = !seltag[arg->i];
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   355
	for(i = 0; i < ntags && !seltag[i]; i++);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   356
	if(i == ntags)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   357
		seltag[arg->i] = True; /* cannot toggle last view */
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
   358
	reorder();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   359
	arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   360
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   361
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   362
void
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   363
togglestackdir(Arg *arg) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   364
	if(arrange == dofloat)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   365
		return;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   366
	isvertical = !isvertical;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   367
	arrange(NULL);
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   368
}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   369
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   370
void
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   371
togglestackpos(Arg *arg) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   372
	if(arrange == dofloat)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   373
		return;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   374
	if(stackpos == StackBottom)
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   375
		stackpos = STACKPOS;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   376
	else
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   377
		stackpos = StackBottom;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   378
	updatemaster();
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   379
	arrange(NULL);
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   380
}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   381
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   382
void
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   383
updatemaster(void) {
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   384
	master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   385
}
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   386
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   387
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: 450
diff changeset
   388
view(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   389
	unsigned int i;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   390
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   391
	for(i = 0; i < ntags; i++)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   392
		seltag[i] = False;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   393
	seltag[arg->i] = True;
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 380
diff changeset
   394
	reorder();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   395
	arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   396
}
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   397
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   398
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: 450
diff changeset
   399
viewall(Arg *arg) {
395
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   400
	unsigned int i;
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   401
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   402
	for(i = 0; i < ntags; i++)
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   403
		seltag[i] = True;
397
cb8a231610c7 reorder was misssing in Ross version of viewall
Anselm R. Garbe <arg@10kloc.org>
parents: 395
diff changeset
   404
	reorder();
395
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   405
	arrange(NULL);
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   406
}
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   407
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   408
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 507
diff changeset
   409
395
7528080beb0e added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents: 393
diff changeset
   410
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: 450
diff changeset
   411
zoom(Arg *arg) {
423
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   412
	unsigned int n;
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   413
	Client *c;
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   414
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   415
	if(!sel)
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   416
		return;
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   417
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   418
	if(sel->isfloat || (arrange == dofloat)) {
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
   419
		togglemax(sel);
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   420
		return;
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
   421
	}
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   422
430
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
   423
	for(n = 0, c = clients; c; c = c->next)
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
   424
		if(isvisible(c) && !c->isfloat)
423
6ba5dd429122 applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents: 422
diff changeset
   425
			n++;
486
8d564b9e3cd4 removed all dotile checks
arg@mmvi
parents: 485
diff changeset
   426
	if(n < 2 || (arrange == dofloat))
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   427
		return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   428
430
1e8aba00964e no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents: 429
diff changeset
   429
	if((c = sel) == nexttiled(clients))
433
a6b8994af164 small fix
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   430
		if(!(c = nexttiled(c->next)))
429
a31de8605f72 no, ordering floating clients at the end seems better
Anselm R. Garbe <arg@10kloc.org>
parents: 428
diff changeset
   431
			return;
443
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   432
	detach(c);
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   433
	if(clients)
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   434
		clients->prev = c;
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   435
	c->next = clients;
548084f8d92e this patch keeps track of global z-layer order of clients which are floating or if floating mode is enabled
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   436
	clients = c;
378
83576f5f0a90 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
   437
	focus(c);
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   438
	arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
   439
}