diff --git a/Makefile.am b/Makefile.am index 4d7894e2..65890d2d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,8 @@ LAYOUTS += layouts/max.h LAYOUTS += layouts/fibonacci.c LAYOUTS += layouts/fibonacci.h +LAYOUTS += layouts/magnifier.c +LAYOUTS += layouts/magnifier.h WIDGETS = WIDGETS += widgets/taglist.c diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 5efb7236..cba1b389 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -18,7 +18,7 @@ terminal = "xterm" -- However, you can use another modifier like Mod1, but it may interact with others. modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. -layouts = { "tile", "tileleft", "tilebottom", "tiletop", "max", "spiral", "dwindle", "floating" } +layouts = { "tile", "tileleft", "tilebottom", "tiletop", "magnifier", "max", "spiral", "dwindle", "floating" } -- }}} -- {{{ Tags diff --git a/layouts/magnifier.c b/layouts/magnifier.c new file mode 100644 index 00000000..0493d556 --- /dev/null +++ b/layouts/magnifier.c @@ -0,0 +1,75 @@ +/* + * magnifier.c - magnifier layout + * + * Copyright © 2008 Julien Danjou + * + * 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. + * + */ + +#include "client.h" +#include "tag.h" +#include "screen.h" +#include "focus.h" +#include "layouts/magnifier.h" + +extern awesome_t globalconf; + +void +layout_magnifier(int screen) +{ + int n = 0; + client_t *c, *focus; + area_t geometry, area = screen_get_area(screen, + globalconf.screens[screen].statusbar, + &globalconf.screens[screen].padding); + + focus = focus_get_current_client(screen); + + /* 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) + return; + + geometry.width = area.width * 0.9; + geometry.height = area.height * 0.9; + geometry.x = area.x + (area.width - geometry.width) / 2; + geometry.y = area.y + (area.height - geometry.height) / 2; + client_resize(focus, geometry, globalconf.resize_hints); + + for(c = globalconf.clients; c; c = c->next) + if(IS_TILED(c, screen) && c != focus) + n++; + + geometry.x = area.x; + geometry.y = area.y; + geometry.height = area.height / n; + geometry.width = area.width; + + for(c = globalconf.clients; c; c = c->next) + if(IS_TILED(c, screen) && c != focus) + { + geometry.height -= 2 * c->border; + geometry.width -= 2 * c->border; + client_resize(c, geometry, globalconf.resize_hints); + geometry.height += 2 * c->border; + geometry.width += 2 * c->border; + geometry.y += geometry.height; + } +} +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/layouts/magnifier.h b/layouts/magnifier.h new file mode 100644 index 00000000..aaac0722 --- /dev/null +++ b/layouts/magnifier.h @@ -0,0 +1,30 @@ +/* + * magnifier.h - magnifier layout header + * + * Copyright © 2008 Julien Danjou + * + * 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. + * + */ + +#ifndef AWESOME_LAYOUTS_MAGNIFIER_H +#define AWESOME_LAYOUTS_MAGNIFIER_H + +#include "layout.h" + +layout_t layout_magnifier; + +#endif +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/tag.c b/tag.c index 898ef10d..d3a7b9cc 100644 --- a/tag.c +++ b/tag.c @@ -28,6 +28,7 @@ #include "ewmh.h" #include "widget.h" +#include "layouts/magnifier.h" #include "layouts/tile.h" #include "layouts/max.h" #include "layouts/floating.h"