client: register floating geom if it comes from floating
[awesome.git] / layouts / magnifier.c
blob3a910e9b98715db35fc8a28d5c2004bc6bec3887
1 /*
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.
22 #include <math.h>
24 #include "client.h"
25 #include "tag.h"
26 #include "screen.h"
27 #include "layouts/magnifier.h"
29 extern awesome_t globalconf;
31 void
32 layout_magnifier(int screen)
34 int n = 0;
35 client_t *c, *focus;
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,
40 true);
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. */
53 if(!focus)
54 goto bailout;
56 for(c = client_list_prev_cycle(&globalconf.clients, focus);
57 c && c != focus;
58 c = client_list_prev_cycle(&globalconf.clients, c))
59 if(IS_TILED(c, screen) && c != focus)
60 n++;
62 if(n)
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;
69 else
71 /* No other clients. */
72 geometry = area;
74 client_resize(focus, geometry, focus->honorsizehints);
75 client_raise(focus);
77 /* bailout when there is only one window */
78 if (!n)
79 goto bailout;
81 geometry.x = area.x;
82 geometry.y = area.y;
83 geometry.height = area.height / n;
84 geometry.width = area.width;
86 for(c = client_list_prev_cycle(&globalconf.clients, focus);
87 c && c != 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;
99 bailout:
100 p_delete(&curtags);
102 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80