hyprland: click away from a scratchpad to dismiss it

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-17 09:53:29 +01:00
parent d4b76f2b13
commit a1deb77a04
2 changed files with 37 additions and 5 deletions

View file

@ -187,6 +187,11 @@ in
follow_mouse = 1;
accel_profile = "flat";
sensitivity = 0;
# An open special workspace otherwise swallows focus for the
# regular workspace underneath. Both scratchpads hold exactly one
# floating window, which is the case this unblocks — and the
# click-away handler below needs that focus change to fire.
special_fallthrough = true;
} // lib.optionalAttrs isMacbook {
touchpad = {
tap_to_click = true;
@ -306,6 +311,19 @@ in
if cmd and not shutting_down then hl.exec_cmd(cmd) end
end)
-- Click-away dismiss: focus landing on anything outside the open
-- special workspace slides it back out, so a scratchpad never has
-- to be toggled off by hand. Generic on purpose any special
-- workspace, not just these two.
hl.on("window.active", function(win)
local special = hl.get_active_special_workspace()
if not special then return end
if win and win.workspace and win.workspace.special then return end
-- Workspace name is "special:scratch"; toggle_special wants the
-- bare "scratch" (and "" for the unnamed "special" workspace).
hl.dispatch(hl.dsp.workspace.toggle_special(special.name:match("^special:(.*)$") or ""))
end)
-- Startup
hl.on("hyprland.start", function()
-- Ensure hyprland-session.target starts even if HM's