Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion default/hypr/apps/steam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 13 additions & 7 deletions default/hypr/workspace-modes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,19 @@ 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()

for i, range in ipairs(ranges) do
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(),
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/shell.d/hyprland-default-config-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 6 additions & 3 deletions test/shell.d/hyprland-floating-workspaces-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down