diff --git a/lib/awful/layout/suit/magnifier.lua.in b/lib/awful/layout/suit/magnifier.lua.in index ee1847621..f0a7d3268 100644 --- a/lib/awful/layout/suit/magnifier.lua.in +++ b/lib/awful/layout/suit/magnifier.lua.in @@ -26,28 +26,27 @@ local function magnifier(_, screen) local focus = capi.client.focus local t = tag.selected(screen) 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 focus = cls[1] + fidx = 1 end -- Abort if no clients are present - if not focus then - return - end - - -- Find parent of this window, if it has one. - while focus.transient_for do - focus = focus.transient_for - end + if not focus then return end -- If focused window is not tiled, take the first one which is tiled. if client.floating.get(focus) then focus = cls[1] + fidx = 1 end local geometry = {} - if #cls - 1 > 0 then + if #cls > 1 then geometry.width = area.width * math.sqrt(mwfact) geometry.height = area.height * math.sqrt(mwfact) geometry.x = area.x + (area.width - geometry.width) / 2 @@ -61,17 +60,19 @@ local function magnifier(_, screen) focus:geometry(geometry) focus:raise() - if #cls - 1 > 0 then + if #cls > 1 then geometry.x = area.x geometry.y = area.y geometry.height = area.height / (#cls - 1) geometry.width = area.width - local fidx - for k, c in ipairs(cls) do - if c == focus then - fidx = k - break + -- 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 end end