diff --git a/layout.lua b/layout.lua index d1ff077..6f1a895 100644 --- a/layout.lua +++ b/layout.lua @@ -132,6 +132,38 @@ local function get_machi_tag_string(tag) return tag.machi_tag_string end +local function sanitize_geometry(geo, parent_area) + local x = geo.x + local width = geo.width + + if x + width > parent_area.x + parent_area.width then + x = parent_area.x + parent_area.width - width + end + if x < parent_area.x then + x = parent_area.x + end + if x + width > parent_area.x + parent_area.width then + width = parent_area.x + parent_area.width - x + end + geo.x = x + geo.width = width + + local y = geo.y + local height = geo.height + if y + height > parent_area.y + parent_area.height then + y = parent_area.y + parent_area.height - height + end + if y < parent_area.y then + y = parent_area.y + end + if y + height > parent_area.y + parent_area.height then + height = parent_area.y + parent_area.height - y + end + geo.y = y + geo.height = height +end + + function module.create(args_or_name, editor, default_cmd) local args if type(args_or_name) == "string" then @@ -284,6 +316,12 @@ function module.create(args_or_name, editor, default_cmd) height = c.height + c.border_width * 2, } + if not c.machi_no_sanitize_geometry then + sanitize_geometry(geo, screen.workarea) + else + c.machi_no_sanitize_geometry = nil + end + if not cd[c].placement and new_placement_cb then cd[c].placement = true new_placement_cb(c, instance, areas, geo) diff --git a/switcher.lua b/switcher.lua index 5e8328a..da5ee32 100644 --- a/switcher.lua +++ b/switcher.lua @@ -478,6 +478,7 @@ function module.start(c, exit_keys) end c:emit_signal("request::activate", "mouse.move", {raise=false}) c:raise() + c.machi_no_sanitize_geometry = true awful.layout.arrange(screen) tablist = nil