layout.c
author Anselm R. Garbe <garbeam@gmail.com>
Mon, 13 Aug 2007 19:13:54 +0200
changeset 946 b938876de936
parent 944 bd5cf635c601
child 949 99ee5c370f94
permissions -rw-r--r--
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
910
c13cb8c6b7a5 referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents: 909
diff changeset
     1
/* See LICENSE file for copyright and license details. */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     2
#include "dwm.h"
825
bef1854ce739 fixed some issues due to the Arg->const char * transition
Anselm R. Garbe <arg@suckless.org>
parents: 823
diff changeset
     3
#include <stdlib.h>
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     4
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
     5
typedef struct {
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
     6
	const char *symbol;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
     7
	void (*arrange)(void);
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
     8
} Layout;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
     9
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    10
unsigned int blw = 0;
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    11
static Layout *lt = NULL;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    12
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    13
/* static */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    14
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    15
static void
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    16
floating(void) {
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    17
	Client *c;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    18
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    19
	for(c = clients; c; c = c->next)
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    20
		if(isvisible(c))
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    21
			resize(c, c->x, c->y, c->w, c->h, True);
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    22
}
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    23
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    24
static unsigned int nlayouts = 0;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
    25
784
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    26
LAYOUTS
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    27
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    28
/* extern */
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    29
74722317b171 renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Anselm R. Garbe <arg@suckless.org>
parents: 782
diff changeset
    30
void
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    31
arrange(void) {
944
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    32
	Client *c;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    33
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    34
	for(c = clients; c; c = c->next)
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    35
		if(isvisible(c))
944
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    36
			unban(c);
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    37
		else
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    38
			ban(c);
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    39
	lt->arrange();
944
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    40
	focus(NULL);
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    41
	restack();
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    42
}
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    43
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
    44
void
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    45
focusclient(const char *arg) {
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    46
	Client *c;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    47
   
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    48
	if(!sel || !arg)
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    49
		return;
831
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    50
	if(atoi(arg) < 0) {
829
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    51
		for(c = sel->prev; c && !isvisible(c); c = c->prev);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    52
		if(!c) {
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    53
			for(c = clients; c && c->next; c = c->next);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    54
			for(; c && !isvisible(c); c = c->prev);
f1ec35606dbc merged focus{prev.next} into focusclient(1/-1)
Anselm R. Garbe <arg@suckless.org>
parents: 826
diff changeset
    55
		}
831
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    56
	}
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    57
	else {
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    58
		for(c = sel->next; c && !isvisible(c); c = c->next);
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    59
		if(!c)
8b84189854dc simplified focusclient()
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
    60
			for(c = clients; c && !isvisible(c); c = c->next);
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    61
	}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    62
	if(c) {
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    63
		focus(c);
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    64
		restack();
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    65
	}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    66
}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    67
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    68
const char *
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    69
getsymbol(void)
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    70
{
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    71
	return lt->symbol;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    72
}
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    73
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    74
Bool
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    75
isfloating(void) {
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    76
	return lt->arrange == floating;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    77
}
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    78
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    79
Bool
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    80
isarrange(void (*func)())
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    81
{
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    82
	return func == lt->arrange;
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    83
}
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
    84
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    85
void
782
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    86
initlayouts(void) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    87
	unsigned int i, w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    88
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    89
	lt = &layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    90
	nlayouts = sizeof layout / sizeof layout[0];
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    91
	for(blw = i = 0; i < nlayouts; i++) {
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    92
		w = textw(layout[i].symbol);
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    93
		if(w > blw)
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    94
			blw = w;
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    95
	}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    96
}
92862ab407d5 introduced Layout struct
Anselm R. Garbe <arg@suckless.org>
parents: 780
diff changeset
    97
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    98
Client *
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
    99
nexttiled(Client *c) {
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   100
	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
799
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   101
	return c;
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   102
}
30ec8b96a7f6 moved focus{next,prev} and nexttiled from client.c to layout.c (because those are not client-specific), moved toggleversatile() from layout.c to client.c (because those are client-specific)
Anselm R. Garbe <arg@suckless.org>
parents: 790
diff changeset
   103
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   104
void
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   105
restack(void) {
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   106
	Client *c;
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   107
	XEvent ev;
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   108
	XWindowChanges wc;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   109
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   110
	drawstatus();
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   111
	if(!sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   112
		return;
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   113
	if(sel->isfloating || lt->arrange == floating)
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   114
		XRaiseWindow(dpy, sel->win);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 831
diff changeset
   115
	if(lt->arrange != floating) {
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   116
		wc.stack_mode = Below;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   117
		wc.sibling = barwin;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   118
		if(!sel->isfloating) {
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   119
			XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   120
			wc.sibling = sel->win;
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   121
		}
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   122
		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   123
			if(c == sel)
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   124
				continue;
918
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   125
			XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
7c556b28f1f6 applied restack patch of anydot, with slight changes
Anselm R. Garbe <arg@suckless.org>
parents: 915
diff changeset
   126
			wc.sibling = c->win;
773
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   127
		}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   128
	}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   129
	XSync(dpy, False);
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   130
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   131
}
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   132
81c5237a53b8 merged tag.c, view.c and tile.c to manage.c
Anselm R. Garbe <arg@suckless.org>
parents: 769
diff changeset
   133
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   134
setlayout(const char *arg) {
826
d900a3f821a3 small bugfix
Anselm R. Garbe <arg@suckless.org>
parents: 825
diff changeset
   135
	int i;
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   136
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   137
	if(!arg) {
891
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   138
		lt++;
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   139
		if(lt == layout + nlayouts)
b940ac76c22f applied Szabolcs proposal to simplify setlayout()
Anselm R. Garbe <arg@suckless.org>
parents: 889
diff changeset
   140
			lt = layout;
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   141
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   142
	else {
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   143
		i = atoi(arg);
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   144
		if(i < 0 || i >= nlayouts)
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   145
			return;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 819
diff changeset
   146
		lt = &layout[i];
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   147
	}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   148
	if(sel)
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
   149
		arrange();
788
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   150
	else
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   151
		drawstatus();
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   152
}
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   153
a61fcdf7b4c1 replaced togglelayout with setlayout
Anselm R. Garbe <arg@suckless.org>
parents: 786
diff changeset
   154
void
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   155
togglebar(const char *arg) {
887
44755dcf1ad4 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 883
diff changeset
   156
	if(bpos == BarOff)
44755dcf1ad4 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 883
diff changeset
   157
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
883
2cbf1010be11 using BarTop as fallback if BARPOS is set to BarOff as default for toggling
Anselm R. Garbe <arg@suckless.org>
parents: 880
diff changeset
   158
	else
2cbf1010be11 using BarTop as fallback if BARPOS is set to BarOff as default for toggling
Anselm R. Garbe <arg@suckless.org>
parents: 880
diff changeset
   159
		bpos = BarOff;
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   160
	updatebarpos();
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 944
diff changeset
   161
	arrange();
878
d2ae55f83f9f made bar togglalble
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   162
}
944
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   163
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   164
void
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   165
togglemax(const char *arg) {
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   166
	XEvent ev;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   167
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   168
	if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   169
		return;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   170
	if((sel->ismax = !sel->ismax)) {
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   171
		sel->rx = sel->x;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   172
		sel->ry = sel->y;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   173
		sel->rw = sel->w;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   174
		sel->rh = sel->h;
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   175
		resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   176
	}
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   177
	else
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   178
		resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   179
	drawstatus();
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   180
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
bd5cf635c601 moved floating to layout.c, kept tile.c outside
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   181
}