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 Tag
*curtag
= get_current_tag(awesomeconf
->tags
, awesomeconf
->ntags
);
36 Layout
*curlay
= curtag
->layout
;
38 if(!arg
|| (curlay
->arrange
!= layout_tile
&& curlay
->arrange
!= layout_tileleft
))
41 if((curtag
->nmaster
= (int) compute_new_value_from_arg(arg
, (double) curtag
->nmaster
)) < 0)
48 uicb_setncol(awesome_config
*awesomeconf
,
51 Tag
*curtag
= get_current_tag(awesomeconf
->tags
, awesomeconf
->ntags
);
52 Layout
*curlay
= curtag
->layout
;
54 if(!arg
|| (curlay
->arrange
!= layout_tile
&& curlay
->arrange
!= layout_tileleft
))
57 if((curtag
->ncol
= (int) compute_new_value_from_arg(arg
, (double) curtag
->ncol
)) < 1)
64 uicb_setmwfact(awesome_config
* awesomeconf
,
68 Tag
*curtag
= get_current_tag(awesomeconf
->tags
, awesomeconf
->ntags
);
69 Layout
*curlay
= curtag
->layout
;
71 if(!arg
|| (curlay
->arrange
!= layout_tile
&& curlay
->arrange
!= layout_tileleft
))
74 newarg
= a_strdup(arg
);
75 if(curlay
->arrange
== layout_tileleft
)
79 else if(arg
[0] == '-')
83 if((curtag
->mwfact
= compute_new_value_from_arg(newarg
, curtag
->mwfact
)) < 0.1)
85 else if(curtag
->mwfact
> 0.9)
93 _tile(awesome_config
*awesomeconf
, const Bool right
)
95 /* windows area geometry */
96 int wah
= 0, waw
= 0, wax
= 0, way
= 0;
98 unsigned int nx
, ny
, nw
, nh
;
100 unsigned int mw
= 0, mh
= 0;
101 int n
, i
, masterwin
= 0, otherwin
= 0;
102 int real_ncol
= 1, win_by_col
= 1, current_col
= 0;
103 ScreenInfo
*screens_info
= NULL
;
105 Tag
*curtag
= get_current_tag(awesomeconf
->tags
, awesomeconf
->ntags
);
107 screens_info
= get_screen_info(awesomeconf
->display
, awesomeconf
->screen
, &awesomeconf
->statusbar
);
109 for(n
= 0, c
= *awesomeconf
->clients
; c
; c
= c
->next
)
110 if(IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->tags
, awesomeconf
->ntags
))
113 wah
= screens_info
[awesomeconf
->screen
].height
;
114 waw
= screens_info
[awesomeconf
->screen
].width
;
115 wax
= screens_info
[awesomeconf
->screen
].x_org
;
116 way
= screens_info
[awesomeconf
->screen
].y_org
;
118 masterwin
= MIN(n
, curtag
->nmaster
);
120 otherwin
= n
- masterwin
;
127 mh
= masterwin
? wah
/ masterwin
: waw
;
128 mw
= otherwin
? waw
* curtag
->mwfact
: waw
;
133 real_ncol
= MIN(otherwin
, curtag
->ncol
);
135 for(i
= 0, c
= *awesomeconf
->clients
; c
; c
= c
->next
)
137 if(!IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->tags
, awesomeconf
->ntags
))
141 if(i
< curtag
->nmaster
)
144 nx
= wax
+ (right
? 0 : waw
- mw
);
145 client_resize(c
, nx
, ny
, mw
- 2 * c
->border
, mh
- 2 * c
->border
, awesomeconf
, awesomeconf
->resize_hints
, False
);
150 win_by_col
= otherwin
/ real_ncol
;
152 if((i
- curtag
->nmaster
) && (i
- curtag
->nmaster
) % win_by_col
== 0 && current_col
< real_ncol
- 1)
155 if(current_col
== real_ncol
- 1)
156 win_by_col
+= otherwin
% real_ncol
;
158 if(otherwin
<= real_ncol
)
159 nh
= wah
- 2 * c
->border
;
161 nh
= (wah
/ win_by_col
) - 2 * c
->border
;
163 nw
= (waw
- mw
) / real_ncol
- 2 * c
->border
;
165 if(i
== curtag
->nmaster
|| otherwin
<= real_ncol
|| (i
- curtag
->nmaster
) % win_by_col
== 0)
168 ny
= way
+ ((i
- curtag
->nmaster
) % win_by_col
) * (nh
+ 2 * c
->border
);
170 nx
= wax
+ current_col
* (nw
+ 2 * c
->border
) + (right
? mw
: 0);
171 client_resize(c
, nx
, ny
, nw
, nh
, awesomeconf
, awesomeconf
->resize_hints
, False
);
175 p_delete(&screens_info
);
179 layout_tile(awesome_config
*awesomeconf
)
181 _tile(awesomeconf
, True
);
185 layout_tileleft(awesome_config
*awesomeconf
)
187 _tile(awesomeconf
, False
);
189 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99