diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index e3399e5..3aa4eee 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -270,22 +270,26 @@ end -- @param t tag object -- @param s Screen number function tag.setscreen(t, s) - local s = s or capi.mouse.screen + if t then + local s = s or capi.mouse.screen + local old_screen = tag.getproperty(t, "screen") - -- Keeping the old index make very little sense when changing screen - tag.setproperty(t, "index", nil) + if old_screen and old_screen ~= s then + -- Keeping the old index make very little sense when changing screen + tag.setproperty(t, "index", nil) - local old_screen = tag.getproperty(t,"screen") + -- Change the screen + tag.setproperty(t, "screen", s) - -- Change the screen - tag.setproperty(t, "screen", s) + -- Make sure the client's screen matches its tags + for _, c in ipairs(t:clients()) do + c.screen = s --Move all clients + c:tags({t}) + end - -- Make sure the client's screen matches its tags - for k,c in ipairs(t:clients()) do - c.screen = s --Move all clients - c:tags({t}) + tag.history.restore(old_screen, 1) + end end - tag.history.restore(old_screen,1) end --- Get a tag's screen