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 extern Client
*sel
, *clients
;
35 uicb_setnmaster(Display
*disp
,
37 awesome_config
*awesomeconf
,
40 if(!arg
|| (!IS_ARRANGE(tile
) && !IS_ARRANGE(tileleft
)))
43 if((awesomeconf
->nmaster
= (int) compute_new_value_from_arg(arg
, (double) awesomeconf
->nmaster
)) < 0)
44 awesomeconf
->nmaster
= 0;
46 arrange(disp
, drawcontext
, awesomeconf
);
50 uicb_setncols(Display
*disp
,
52 awesome_config
*awesomeconf
,
55 if(!arg
|| (!IS_ARRANGE(tile
) && !IS_ARRANGE(tileleft
)))
58 if((awesomeconf
->ncols
= (int) compute_new_value_from_arg(arg
, (double) awesomeconf
->ncols
)) < 1)
59 awesomeconf
->ncols
= 1;
61 arrange(disp
, drawcontext
, awesomeconf
);
65 uicb_setmwfact(Display
*disp
,
67 awesome_config
* awesomeconf
,
70 if(!IS_ARRANGE(tile
) && !IS_ARRANGE(tileleft
))
73 if((awesomeconf
->mwfact
= compute_new_value_from_arg(arg
, awesomeconf
->mwfact
)) < 0.1)
74 awesomeconf
->mwfact
= 0.1;
75 else if(awesomeconf
->mwfact
> 0.9)
76 awesomeconf
->mwfact
= 0.9;
78 arrange(disp
, drawcontext
, awesomeconf
);
82 _tile(Display
*disp
, awesome_config
*awesomeconf
, const Bool right
)
84 /* windows area geometry */
85 int wah
= 0, waw
= 0, wax
= 0, way
= 0;
87 unsigned int nx
, ny
, nw
, nh
;
89 unsigned int mw
= 0, mh
= 0;
90 int n
, i
, li
, last_i
= 0, masterwin
= 0, otherwin
= 0;
91 int screen_numbers
= 1, use_screen
= -1;
92 int real_ncols
= 1, win_by_col
= 1, current_col
= 0;
93 ScreenInfo
*screens_info
= NULL
;
96 screens_info
= get_screen_info(disp
, awesomeconf
->screen
, awesomeconf
->statusbar
, &screen_numbers
);
98 for(n
= 0, c
= clients
; c
; c
= c
->next
)
99 if(IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
102 for(i
= 0, c
= clients
; c
; c
= c
->next
)
104 if(!IS_TILED(c
, awesomeconf
->screen
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
108 || (screen_numbers
> 1
110 && ((i
- last_i
) >= masterwin
+ otherwin
111 || n
== screen_numbers
)))
116 wah
= screens_info
[use_screen
].height
;
117 waw
= screens_info
[use_screen
].width
;
118 wax
= screens_info
[use_screen
].x_org
;
119 way
= screens_info
[use_screen
].y_org
;
121 if(n
>= awesomeconf
->nmaster
* screen_numbers
)
123 masterwin
= awesomeconf
->nmaster
;
124 otherwin
= (n
- (awesomeconf
->nmaster
* screen_numbers
)) / screen_numbers
;
126 otherwin
+= (n
- (awesomeconf
->nmaster
* screen_numbers
)) % screen_numbers
;
130 masterwin
= n
/ screen_numbers
;
131 /* first screen takes more master */
133 masterwin
+= n
% screen_numbers
;
137 if(awesomeconf
->nmaster
)
139 mh
= masterwin
? wah
/ masterwin
: waw
;
140 mw
= otherwin
? waw
* awesomeconf
->mwfact
: waw
;
148 if(otherwin
< awesomeconf
->ncols
)
149 real_ncols
= otherwin
;
151 real_ncols
= awesomeconf
->ncols
;
157 li
= last_i
? i
- last_i
: i
;
158 if(li
< awesomeconf
->nmaster
)
160 ny
= way
+ li
* (mh
+ 2 * c
->border
);
161 nx
= wax
+ (right
? 0 : waw
- (mw
+ 2 * c
->border
));
162 resize(c
, nx
, ny
, mw
, mh
, awesomeconf
->resize_hints
);
166 win_by_col
= otherwin
/ real_ncols
;
168 if((li
- awesomeconf
->nmaster
) && (li
- awesomeconf
->nmaster
) % win_by_col
== 0 && current_col
< real_ncols
- 1)
171 if(current_col
== real_ncols
- 1)
172 win_by_col
+= otherwin
% real_ncols
;
174 if(otherwin
<= real_ncols
)
175 nh
= wah
- 2 * c
->border
;
177 nh
= (wah
/ win_by_col
) - 2 * c
->border
;
179 nw
= (waw
- (mw
+ 2 * c
->border
)) / real_ncols
- 2 * c
->border
;
181 if(li
== awesomeconf
->nmaster
|| otherwin
<= real_ncols
|| (li
- awesomeconf
->nmaster
) % win_by_col
== 0)
184 ny
= way
+ ((li
- awesomeconf
->nmaster
) % win_by_col
) * (nh
+ 2 * c
->border
);
186 nx
= wax
+ current_col
* nw
+ (right
? mw
+ 2 * c
->border
: 0);
187 resize(c
, nx
, ny
, nw
, nh
, awesomeconf
->resize_hints
);
195 tile(Display
*disp
, awesome_config
*awesomeconf
)
197 _tile(disp
, awesomeconf
, True
);
201 tileleft(Display
*disp
, awesome_config
*awesomeconf
)
203 _tile(disp
, awesomeconf
, False
);