2 * magnifier.c - magnifier layout
4 * Copyright © 2008 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.
27 #include "layouts/magnifier.h"
29 extern awesome_t globalconf
;
32 layout_magnifier(int screen
)
36 tag_t
**curtags
= tags_get_current(screen
);
37 area_t geometry
, area
= screen_area_get(screen
,
38 &globalconf
.screens
[screen
].wiboxes
,
39 &globalconf
.screens
[screen
].padding
,
42 focus
= globalconf
.screens
[screen
].client_focus
;
44 /* When the client is not tiled and it has a parent, focus on that parent. */
45 if (!IS_TILED(focus
, screen
) && focus
&& focus
->transient_for
)
46 focus
= focus
->transient_for
;
48 /* If focused window is not tiled, take the first one which is tiled. */
49 if(!IS_TILED(focus
, screen
))
50 for(focus
= globalconf
.clients
; focus
&& !IS_TILED(focus
, screen
); focus
= focus
->next
);
52 /* No windows is tiled, nothing to do. */
56 for(c
= client_list_prev_cycle(&globalconf
.clients
, focus
);
58 c
= client_list_prev_cycle(&globalconf
.clients
, c
))
59 if(IS_TILED(c
, screen
) && c
!= focus
)
64 geometry
.width
= area
.width
* sqrt(curtags
[0]->mwfact
);
65 geometry
.height
= area
.height
* sqrt(curtags
[0]->mwfact
);
66 geometry
.x
= area
.x
+ (area
.width
- geometry
.width
) / 2;
67 geometry
.y
= area
.y
+ (area
.height
- geometry
.height
) / 2;
71 /* No other clients. */
74 client_resize(focus
, geometry
, focus
->honorsizehints
);
77 /* bailout when there is only one window */
83 geometry
.height
= area
.height
/ n
;
84 geometry
.width
= area
.width
;
86 for(c
= client_list_prev_cycle(&globalconf
.clients
, focus
);
88 c
= client_list_prev_cycle(&globalconf
.clients
, c
))
89 if(IS_TILED(c
, screen
) && c
!= focus
)
91 geometry
.height
-= 2 * c
->border
;
92 geometry
.width
-= 2 * c
->border
;
93 client_resize(c
, geometry
, c
->honorsizehints
);
94 geometry
.height
+= 2 * c
->border
;
95 geometry
.width
+= 2 * c
->border
;
96 geometry
.y
+= geometry
.height
;
102 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80