suit.magnifier: fix focused window handling in multi screen

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-03-10 07:56:48 +01:00
parent fce7f17915
commit b07857b4f6
1 changed files with 16 additions and 15 deletions

View File

@ -26,28 +26,27 @@ local function magnifier(_, screen)
local focus = capi.client.focus local focus = capi.client.focus
local t = tag.selected(screen) local t = tag.selected(screen)
local mwfact = tag.getmwfact(t) local mwfact = tag.getmwfact(t)
local fidx -- Focus client index in cls table
-- Check that the focused window is on the right screen
if focus and focus.screen ~= screen then focus = nil end
if not focus and #cls > 0 then if not focus and #cls > 0 then
focus = cls[1] focus = cls[1]
fidx = 1
end end
-- Abort if no clients are present -- Abort if no clients are present
if not focus then if not focus then return end
return
end
-- Find parent of this window, if it has one.
while focus.transient_for do
focus = focus.transient_for
end
-- If focused window is not tiled, take the first one which is tiled. -- If focused window is not tiled, take the first one which is tiled.
if client.floating.get(focus) then if client.floating.get(focus) then
focus = cls[1] focus = cls[1]
fidx = 1
end end
local geometry = {} local geometry = {}
if #cls - 1 > 0 then if #cls > 1 then
geometry.width = area.width * math.sqrt(mwfact) geometry.width = area.width * math.sqrt(mwfact)
geometry.height = area.height * math.sqrt(mwfact) geometry.height = area.height * math.sqrt(mwfact)
geometry.x = area.x + (area.width - geometry.width) / 2 geometry.x = area.x + (area.width - geometry.width) / 2
@ -61,17 +60,19 @@ local function magnifier(_, screen)
focus:geometry(geometry) focus:geometry(geometry)
focus:raise() focus:raise()
if #cls - 1 > 0 then if #cls > 1 then
geometry.x = area.x geometry.x = area.x
geometry.y = area.y geometry.y = area.y
geometry.height = area.height / (#cls - 1) geometry.height = area.height / (#cls - 1)
geometry.width = area.width geometry.width = area.width
local fidx -- We don't know what the focus window index. Try to find it.
for k, c in ipairs(cls) do if not fidx then
if c == focus then for k, c in ipairs(cls) do
fidx = k if c == focus then
break fidx = k
break
end
end end
end end