2008-11-25 17:01:06 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
|
|
|
local math = math
|
|
|
|
local tag = require("awful.tag")
|
|
|
|
local capi =
|
|
|
|
{
|
|
|
|
client = client,
|
|
|
|
screen = screen
|
|
|
|
}
|
|
|
|
local client = require("awful.client")
|
|
|
|
|
|
|
|
--- Magnifier layout module for awful
|
|
|
|
module("awful.layout.suit.magnifier")
|
|
|
|
|
2009-02-24 21:50:46 +01:00
|
|
|
function arrange(p)
|
2008-11-25 17:01:06 +01:00
|
|
|
-- Fullscreen?
|
2009-02-24 21:50:46 +01:00
|
|
|
local area = p.workarea
|
|
|
|
local cls = p.clients
|
2008-11-25 17:01:06 +01:00
|
|
|
local focus = capi.client.focus
|
2009-08-07 15:50:45 +02:00
|
|
|
local mwfact = tag.getmwfact(tag.selected(p.screen))
|
2009-03-13 22:23:35 +01:00
|
|
|
local fidx
|
2009-03-10 07:56:48 +01:00
|
|
|
|
|
|
|
-- Check that the focused window is on the right screen
|
2009-03-13 22:23:35 +01:00
|
|
|
if focus and focus.screen ~= p.screen then focus = nil end
|
2008-11-25 17:01:06 +01:00
|
|
|
|
|
|
|
if not focus and #cls > 0 then
|
|
|
|
focus = cls[1]
|
2009-03-10 07:56:48 +01:00
|
|
|
fidx = 1
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- If focused window is not tiled, take the first one which is tiled.
|
|
|
|
if client.floating.get(focus) then
|
|
|
|
focus = cls[1]
|
2009-03-10 07:56:48 +01:00
|
|
|
fidx = 1
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
2009-08-31 10:32:53 +02:00
|
|
|
-- Abort if no clients are present
|
|
|
|
if not focus then return end
|
|
|
|
|
2008-11-25 17:01:06 +01:00
|
|
|
local geometry = {}
|
2009-03-10 07:56:48 +01:00
|
|
|
if #cls > 1 then
|
2008-11-25 17:01:06 +01:00
|
|
|
geometry.width = area.width * math.sqrt(mwfact)
|
|
|
|
geometry.height = area.height * math.sqrt(mwfact)
|
|
|
|
geometry.x = area.x + (area.width - geometry.width) / 2
|
|
|
|
geometry.y = area.y + (area.height - geometry.height) /2
|
|
|
|
else
|
|
|
|
geometry.x = area.x
|
|
|
|
geometry.y = area.y
|
2008-12-12 00:01:43 +01:00
|
|
|
geometry.width = area.width
|
|
|
|
geometry.height = area.height
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
2008-12-12 00:01:43 +01:00
|
|
|
focus:geometry(geometry)
|
2008-11-25 17:01:06 +01:00
|
|
|
focus:raise()
|
|
|
|
|
2009-03-10 07:56:48 +01:00
|
|
|
if #cls > 1 then
|
2008-11-25 17:01:06 +01:00
|
|
|
geometry.x = area.x
|
|
|
|
geometry.y = area.y
|
|
|
|
geometry.height = area.height / (#cls - 1)
|
|
|
|
geometry.width = area.width
|
|
|
|
|
2009-03-10 07:56:48 +01:00
|
|
|
-- We don't know what the focus window index. Try to find it.
|
|
|
|
if not fidx then
|
|
|
|
for k, c in ipairs(cls) do
|
|
|
|
if c == focus then
|
|
|
|
fidx = k
|
|
|
|
break
|
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
end
|
2009-01-21 13:45:39 +01:00
|
|
|
|
|
|
|
-- First move clients that are before focused client.
|
|
|
|
for k = fidx + 1, #cls do
|
|
|
|
cls[k]:geometry(geometry)
|
|
|
|
geometry.y = geometry.y + geometry.height
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Then move clients that are after focused client.
|
|
|
|
-- So the next focused window will be the one at the top of the screen.
|
|
|
|
for k = 1, fidx - 1 do
|
|
|
|
cls[k]:geometry(geometry)
|
|
|
|
geometry.y = geometry.y + geometry.height
|
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-02-24 21:46:29 +01:00
|
|
|
name = "magnifier"
|