widget: remove button property
[awesome.git] / layouts / magnifier.c
blob4fba8f5222f161b3b44bca566daa91d8191a02ce
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 /* Find parent of this window, if it has one. */
45 if (!IS_TILED(focus, screen) && focus && focus->transient_for)
46 do {
47 focus = focus->transient_for;
48 } while (focus->transient_for != NULL);
50 /* If focused window is not tiled, take the first one which is tiled. */
51 if(!IS_TILED(focus, screen))
52 for(focus = globalconf.clients; focus && !IS_TILED(focus, screen); focus = focus->next);
54 /* No windows is tiled, nothing to do. */
55 if(!focus)
56 goto bailout;
58 for(c = client_list_prev_cycle(&globalconf.clients, focus);
59 c && c != focus;
60 c = client_list_prev_cycle(&globalconf.clients, c))
61 if(IS_TILED(c, screen) && c != focus)
62 n++;
64 if(n)
66 geometry.width = area.width * sqrt(curtags[0]->mwfact);
67 geometry.height = area.height * sqrt(curtags[0]->mwfact);
68 geometry.x = area.x + (area.width - geometry.width) / 2;
69 geometry.y = area.y + (area.height - geometry.height) / 2;
71 else
73 /* No other clients. */
74 geometry = area;
75 geometry.width -= 2 * focus->border;
76 geometry.height -= 2 * focus->border;
78 client_resize(focus, geometry, focus->honorsizehints);
79 client_raise(focus);
81 /* bailout when there is only one window */
82 if (!n)
83 goto bailout;
85 geometry.x = area.x;
86 geometry.y = area.y;
87 geometry.height = area.height / n;
88 geometry.width = area.width;
90 for(c = client_list_prev_cycle(&globalconf.clients, focus);
91 c && c != focus;
92 c = client_list_prev_cycle(&globalconf.clients, c))
93 if(IS_TILED(c, screen) && c != focus)
95 geometry.height -= 2 * c->border;
96 geometry.width -= 2 * c->border;
97 client_resize(c, geometry, c->honorsizehints);
98 geometry.height += 2 * c->border;
99 geometry.width += 2 * c->border;
100 geometry.y += geometry.height;
103 bailout:
104 p_delete(&curtags);
106 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80