4 * Copyright © 2007 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "layouts/tile.h"
32 uicb_setnmaster(awesome_config
*awesomeconf
,
35 if(!arg
|| (!IS_ARRANGE(0, layout_tile
) && !IS_ARRANGE(0, layout_tileleft
)))
39 if((awesomeconf
->nmaster
= (int) compute_new_value_from_arg(arg
, (double) awesomeconf
->nmaster
)) < 0)
40 awesomeconf
->nmaster
= 0;
46 uicb_setncol(awesome_config
*awesomeconf
,
49 if(!arg
|| (!IS_ARRANGE(0, layout_tile
) && !IS_ARRANGE(0, layout_tileleft
)))
52 if((awesomeconf
->ncol
= (int) compute_new_value_from_arg(arg
, (double) awesomeconf
->ncol
)) < 1)
53 awesomeconf
->ncol
= 1;
59 uicb_setmwfact(awesome_config
* awesomeconf
,
64 if((!IS_ARRANGE(0, layout_tile
) && !IS_ARRANGE(0, layout_tileleft
)) || !arg
)
67 newarg
= a_strdup(arg
);
68 if(IS_ARRANGE(0, layout_tileleft
))
72 else if(arg
[0] == '-')
76 if((awesomeconf
->mwfact
= compute_new_value_from_arg(newarg
, awesomeconf
->mwfact
)) < 0.1)
77 awesomeconf
->mwfact
= 0.1;
78 else if(awesomeconf
->mwfact
> 0.9)
79 awesomeconf
->mwfact
= 0.9;
86 _tile(awesome_config
*awesomeconf
, const Bool right
)
88 /* windows area geometry */
89 int wah
= 0, waw
= 0, wax
= 0, way
= 0;
91 unsigned int nx
, ny
, nw
, nh
;
93 unsigned int mw
= 0, mh
= 0;
94 int n
, i
, masterwin
= 0, otherwin
= 0;
95 int real_ncol
= 1, win_by_col
= 1, current_col
= 0;
96 ScreenInfo
*screens_info
= NULL
;
99 screens_info
= get_screen_info(awesomeconf
->display
, awesomeconf
->screen
, &awesomeconf
->statusbar
);
101 for(n
= 0, c
= *awesomeconf
->clients
; c
; c
= c
->next
)
102 if(IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->tags
, awesomeconf
->ntags
))
105 wah
= screens_info
[awesomeconf
->screen
].height
;
106 waw
= screens_info
[awesomeconf
->screen
].width
;
107 wax
= screens_info
[awesomeconf
->screen
].x_org
;
108 way
= screens_info
[awesomeconf
->screen
].y_org
;
110 masterwin
= MIN(n
, awesomeconf
->nmaster
);
112 otherwin
= n
- masterwin
;
117 if(awesomeconf
->nmaster
)
119 mh
= masterwin
? wah
/ masterwin
: waw
;
120 mw
= otherwin
? waw
* awesomeconf
->mwfact
: waw
;
125 real_ncol
= MIN(otherwin
, awesomeconf
->ncol
);
127 for(i
= 0, c
= *awesomeconf
->clients
; c
; c
= c
->next
)
129 if(!IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->tags
, awesomeconf
->ntags
))
133 if(i
< awesomeconf
->nmaster
)
136 nx
= wax
+ (right
? 0 : waw
- mw
);
137 resize(c
, nx
, ny
, mw
- 2 * c
->border
, mh
- 2 * c
->border
, awesomeconf
, awesomeconf
->resize_hints
);
142 win_by_col
= otherwin
/ real_ncol
;
144 if((i
- awesomeconf
->nmaster
) && (i
- awesomeconf
->nmaster
) % win_by_col
== 0 && current_col
< real_ncol
- 1)
147 if(current_col
== real_ncol
- 1)
148 win_by_col
+= otherwin
% real_ncol
;
150 if(otherwin
<= real_ncol
)
151 nh
= wah
- 2 * c
->border
;
153 nh
= (wah
/ win_by_col
) - 2 * c
->border
;
155 nw
= (waw
- mw
) / real_ncol
- 2 * c
->border
;
157 if(i
== awesomeconf
->nmaster
|| otherwin
<= real_ncol
|| (i
- awesomeconf
->nmaster
) % win_by_col
== 0)
160 ny
= way
+ ((i
- awesomeconf
->nmaster
) % win_by_col
) * (nh
+ 2 * c
->border
);
162 nx
= wax
+ current_col
* (nw
+ 2 * c
->border
) + (right
? mw
: 0);
163 resize(c
, nx
, ny
, nw
, nh
, awesomeconf
, awesomeconf
->resize_hints
);
171 layout_tile(awesome_config
*awesomeconf
)
173 _tile(awesomeconf
, True
);
177 layout_tileleft(awesome_config
*awesomeconf
)
179 _tile(awesomeconf
, False
);
181 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99