diff --git a/default/hypr/apps/steam.lua b/default/hypr/apps/steam.lua index 5ebf812d6223..07afbd43080d 100644 --- a/default/hypr/apps/steam.lua +++ b/default/hypr/apps/steam.lua @@ -41,7 +41,7 @@ hl.on("window.open", function(window) -- Leave dialogs and windows that floated on their own alone, while still -- catching normal windows that a floating workspace rule floated. - if window.floating and not o.has_tag(window, "omarchy-mode-opened") then + if window.floating and not o.has_tag(window, "omarchy-mode-floated") then return end diff --git a/default/hypr/workspace-modes.lua b/default/hypr/workspace-modes.lua index e5957cfa3b93..af266d3be6ac 100644 --- a/default/hypr/workspace-modes.lua +++ b/default/hypr/workspace-modes.lua @@ -298,7 +298,11 @@ end -- size the mode gives it, so it pops in from its own middle the way a tiled -- window does, instead of opening tiled and shrinking into place. Modal -- dialogs, and apps with float rules of their own, float on their own account --- and are left to it, at their own size and outside the mode's claim. +-- and are left to it, at their own size and outside the mode's claim. So are +-- windows Hyprland floats before rules apply: X11 menus, tooltips, dialogs and +-- utility windows, transient and fixed-size windows, and Wayland child +-- toplevels. Sized and centered like an app window, a menu opens far from +-- where it was clicked. local function sync_open_rules() local ranges = floating_ranges() @@ -306,7 +310,7 @@ local function sync_open_rules() hl.window_rule({ name = OPEN_RULE .. i, enabled = true, - match = not_floating_on_their_own({ workspace = string.format("r[%d-%d]", range[1], range[2]), modal = false }), + match = not_floating_on_their_own({ workspace = string.format("r[%d-%d]", range[1], range[2]), modal = false, float = false }), float = true, size = OPEN_WIDTH .. " " .. OPEN_HEIGHT, move = open_position(), @@ -325,10 +329,11 @@ end -- exclusions current before their first window opens, including tag rules. o.floating_apps_changed = sync_open_rules --- A rule's tag leaves with the rule, so a window the open rule floated is --- claimed for good as it opens, and the mode tiles it again when it ends. A --- rule's tags are listed with a trailing "*", and a strict tag query passes --- them over, so the window's own list is read. +-- A rule's tag leaves with the rule, and the open rule stops matching a window +-- once it has floated it, so the window is claimed for good before it opens, +-- and the mode tiles it again when it ends. A rule's tags are listed with a +-- trailing "*", and a strict tag query passes them over, so the window's own +-- list is read. local function claim_opened(window) if o.has_tag(window, OPENED_TAG) then set_claimed(window, true) @@ -383,8 +388,9 @@ local function watch() watching = true + hl.on("window.open_early", claim_opened) + hl.on("window.open", function(window) - claim_opened(window) unmaximize_others(window) arrange({ window }) end) diff --git a/test/shell.d/hyprland-default-config-test.sh b/test/shell.d/hyprland-default-config-test.sh index de38c2e688bb..d9818098c13c 100644 --- a/test/shell.d/hyprland-default-config-test.sh +++ b/test/shell.d/hyprland-default-config-test.sh @@ -304,7 +304,7 @@ assert(#native == 3 and native[1].kind == "tag" and native[1].tag == "+steam-gam assert(native[2].kind == "tag" and native[2].tag == "+game", "native game not tagged as a game") assert(native[3].kind == "fullscreen" and native[3].mode == "fullscreen" and native[3].action == "set", "native game not fullscreened") -local on_float_ws = check({ class = "Gamedevtycoon64-bin", pid = game_pid, floating = true, fullscreen = 0, tags = { "omarchy-mode-opened*" } }) +local on_float_ws = check({ class = "Gamedevtycoon64-bin", pid = game_pid, floating = true, fullscreen = 0, tags = { "omarchy-mode-floated" } }) assert(#on_float_ws == 3 and on_float_ws[3].kind == "fullscreen", "native game on floating workspace not fullscreened") assert(#check({ class = "Gamedevtycoon64-bin", pid = game_pid, floating = true, fullscreen = 0, tags = {} }) == 0, "floating game dialog should stay floating") diff --git a/test/shell.d/hyprland-floating-workspaces-test.sh b/test/shell.d/hyprland-floating-workspaces-test.sh index c389a1051010..03619ea4ea47 100755 --- a/test/shell.d/hyprland-floating-workspaces-test.sh +++ b/test/shell.d/hyprland-floating-workspaces-test.sh @@ -491,9 +491,10 @@ fi pass "a window leaving fullscreen on a floating workspace floats" # A window opening on a floating workspace floats from its first frame through -# a window rule, which tags it the way rules do, with a trailing "*". The mode -# claims it as it opens, so it tiles again when the workspace stops floating, -# and the rule stops applying. +# a window rule, which tags it the way rules do, with a trailing "*". The rule +# stops matching the window it floated, so its tag is gone by window.open: the +# mode claims it before then, so it tiles again when the workspace stops +# floating, and the rule stops applying. printf 'o.workspace_mode({ workspace = "1", mode = "floating" })\n' >"$modes_dir/1.lua" if ! run_lua ' require("default.hypr.workspace-layouts") @@ -508,6 +509,8 @@ local rule = open_rule() assert(rule and rule.float and rule.enabled and rule.match.workspace == "r[1-1]", "no open rule floats windows on the floating workspace") local first_position = rule.move local opened = window("0x1", 1, { floating = true, tags = { "omarchy-mode-opened*" } }) +state().subscriptions["window.open_early"][1](opened) +table.remove(opened.tags, 1) state().subscriptions["window.open"][1](opened) assert(has_tag(opened, "omarchy-mode-floated"), "a window the open rule floated was not claimed by the mode") assert(open_rule().move ~= first_position, "the next window opens exactly on top of the last")