2008-05-27 20:53:34 +02:00
|
|
|
/*
|
|
|
|
* magnifier.c - magnifier layout
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-08-22 22:09:51 +02:00
|
|
|
#include <math.h>
|
|
|
|
|
2008-05-27 20:53:34 +02:00
|
|
|
#include "client.h"
|
2008-06-09 21:43:09 +02:00
|
|
|
#include "tag.h"
|
2008-05-27 20:53:34 +02:00
|
|
|
#include "screen.h"
|
|
|
|
#include "layouts/magnifier.h"
|
|
|
|
|
|
|
|
extern awesome_t globalconf;
|
|
|
|
|
|
|
|
void
|
2008-06-09 21:43:09 +02:00
|
|
|
layout_magnifier(int screen)
|
2008-05-27 20:53:34 +02:00
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
client_t *c, *focus;
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t **curtags = tags_get_current(screen);
|
2008-09-03 22:15:14 +02:00
|
|
|
area_t geometry, area = screen_area_get(screen,
|
2008-09-24 12:13:21 +02:00
|
|
|
&globalconf.screens[screen].wiboxes,
|
2008-09-03 22:15:14 +02:00
|
|
|
&globalconf.screens[screen].padding,
|
|
|
|
true);
|
2008-05-27 20:53:34 +02:00
|
|
|
|
2008-07-31 15:51:28 +02:00
|
|
|
focus = globalconf.screens[screen].client_focus;
|
2008-05-27 20:53:34 +02:00
|
|
|
|
2008-11-21 19:48:08 +01:00
|
|
|
/* Find parent of this window, if it has one. */
|
2008-11-02 21:51:09 +01:00
|
|
|
if (!IS_TILED(focus, screen) && focus && focus->transient_for)
|
2008-11-21 19:48:08 +01:00
|
|
|
do {
|
|
|
|
focus = focus->transient_for;
|
|
|
|
} while (focus->transient_for != NULL);
|
2008-11-02 21:51:09 +01:00
|
|
|
|
2008-05-27 20:53:34 +02:00
|
|
|
/* If focused window is not tiled, take the first one which is tiled. */
|
|
|
|
if(!IS_TILED(focus, screen))
|
|
|
|
for(focus = globalconf.clients; focus && !IS_TILED(focus, screen); focus = focus->next);
|
|
|
|
|
|
|
|
/* No windows is tiled, nothing to do. */
|
|
|
|
if(!focus)
|
2008-06-09 21:43:09 +02:00
|
|
|
goto bailout;
|
2008-05-27 20:53:34 +02:00
|
|
|
|
2008-05-27 22:00:51 +02:00
|
|
|
for(c = client_list_prev_cycle(&globalconf.clients, focus);
|
|
|
|
c && c != focus;
|
|
|
|
c = client_list_prev_cycle(&globalconf.clients, c))
|
2008-05-27 20:53:34 +02:00
|
|
|
if(IS_TILED(c, screen) && c != focus)
|
|
|
|
n++;
|
|
|
|
|
2008-08-24 10:12:46 +02:00
|
|
|
if(n)
|
|
|
|
{
|
|
|
|
geometry.width = area.width * sqrt(curtags[0]->mwfact);
|
|
|
|
geometry.height = area.height * sqrt(curtags[0]->mwfact);
|
|
|
|
geometry.x = area.x + (area.width - geometry.width) / 2;
|
|
|
|
geometry.y = area.y + (area.height - geometry.height) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No other clients. */
|
|
|
|
geometry = area;
|
2008-11-17 14:58:01 +01:00
|
|
|
geometry.width -= 2 * focus->border;
|
|
|
|
geometry.height -= 2 * focus->border;
|
2008-08-24 10:12:46 +02:00
|
|
|
}
|
|
|
|
client_resize(focus, geometry, focus->honorsizehints);
|
|
|
|
client_raise(focus);
|
2008-05-27 21:28:29 +02:00
|
|
|
|
2008-11-02 21:50:34 +01:00
|
|
|
/* bailout when there is only one window */
|
|
|
|
if (!n)
|
|
|
|
goto bailout;
|
|
|
|
|
2008-05-27 20:53:34 +02:00
|
|
|
geometry.x = area.x;
|
|
|
|
geometry.y = area.y;
|
|
|
|
geometry.height = area.height / n;
|
|
|
|
geometry.width = area.width;
|
|
|
|
|
2008-05-27 22:00:51 +02:00
|
|
|
for(c = client_list_prev_cycle(&globalconf.clients, focus);
|
|
|
|
c && c != focus;
|
|
|
|
c = client_list_prev_cycle(&globalconf.clients, c))
|
2008-05-27 20:53:34 +02:00
|
|
|
if(IS_TILED(c, screen) && c != focus)
|
|
|
|
{
|
|
|
|
geometry.height -= 2 * c->border;
|
|
|
|
geometry.width -= 2 * c->border;
|
2008-06-25 15:42:07 +02:00
|
|
|
client_resize(c, geometry, c->honorsizehints);
|
2008-05-27 20:53:34 +02:00
|
|
|
geometry.height += 2 * c->border;
|
|
|
|
geometry.width += 2 * c->border;
|
|
|
|
geometry.y += geometry.height;
|
|
|
|
}
|
2008-06-09 21:43:09 +02:00
|
|
|
|
|
|
|
bailout:
|
|
|
|
p_delete(&curtags);
|
2008-05-27 20:53:34 +02:00
|
|
|
}
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|