sway: for_window criteria are not executed when a window's floating state changes
Running Sway and i3 with the following config:
exec alacritty
for_window [floating] border pixel 2
for_window [tiling] border normal 2
i3 will change the border when changing the windows floating state. Sway will not (but will if the window title changes).
$ swaymsg -t get_version | jq -r .human_readable
1.6-rc2-a9563a37 (Mar 24 2021, branch 'makepkg')
Related: PR #5323, possibly others. There is a comment on that PR which is incorrect, as i3 does execute for_window criteria on window state changes. Example from the i3 user docs:
# makes the window floating as soon as I change
# directory to ~/work
for_window [title="x200: ~/work"] floating enable
However, both i3 and Sway will only apply each criteria once per window (which makes something like my sample config not as useful in either i3 or Sway).
Basically, for_window criteria are kind of broken and unintuitive in i3 anyway (trigger on window mapping or state change, but only if that criteria hasn’t yet been triggered for the given view).
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 12
- Comments: 18 (6 by maintainers)
I think I have a related issue. For many windows (browsers, terminals, etc.), I want them to tile by default, but I also float them pretty frequently, and would like to specify their floating size. Since criteria are only executed once,
for_window [app_id="firefox" floating] resize set 50 ppt 90 pptdoesn’t work, because the window was initially tiled. Similarly,
for_window [app_id="firefox"] floating enable, resize set 50 ppt 90 pptworks once, but if I tile the window and then re-float it, my size settings are lost.
Absent some form of persistent criteria checking, is there some other way I can specify a “default-size-when-floating”?
I’m having a similar problem, also with Chrome (but, I suspect this is common to any application that has tabs internally and re-titles the window to match the tab title):
I want Chrome to have
inhibit_idlewhen I’m using Google Meet, but not for any other tabs. If I do:My desired workflow is to join a meeting, move the tab to a new window (at which point I want
inhibit_idle) then close the window (and nothing should haveinhibit_idleanymore). It works correctly once, but, after that, theinhibit_idlegets “stuck” on the original chrome window, even if meet isn’t there.It’d be nice to have a way to design “reactive” settings like that, without having to spawn off another process to watch for changes.
I have the same issue with chromium screen sharing. The title is changed after the fact, so I can’t use for_window (that I can tell). It would be cool to do something like
always_for_windowinstead!Allowing the trigger to happen when the title changes would be very good, and would help with some softwares like slack that set a title and modify it a little later.
Slack will create a window with the title
Slackand a little later will change that to another pattern.For example for calls, slack will create a mini panel window; that window will contain the title
Slackand after a very short time it will change tomini panel, but at that point it is to late to apply the criteria.After some recent updates, part of the problem described here has come back. New LastPass Firefox window stays in tiled mode, taking up half the screen until focus changes and then it snaps into focused mode with size as configured above. Sometimes the window auto-closes before I can re-enter the LastPass master password. At least the buggy window size issue appears resolved. In other words: The buggy window contents draw issue is fixed.
Now it’s just that the window rules are not applying properly when it first appears. I suspect a race condition on the window title match causing the configured rules to not apply initially. Possibly due to the page load updating the title asynchronously, happening after the window match rules are applied. A new manual focus change event seems to trigger the rules after the title has been updated.
The affected system is currently running:
repo/packagesway1:1.10.1-2extra/swaywlroots0.18.2-1extra/wlrootswayland-protocols1.41-1extra/wayland-protocolsAffected windows are all from Firefox, running natively under Wayland/Sway (not
xwayland). Easy to reproduce with LastPass Firefox extension and configs above.I can confirm this. I think it might be useful to create a new issue to gain some traction since the problem that you’ve described seems different from what is written by OP.
This may also affect some browser extension windows. I’m not 100% sure, but could be related due to some rules applying on floating state change, sometimes… or else maybe this is another bug due to the additional redraw problems complicating it? I tested this with LastPass extension in Firefox (native sway windows) with the following setting checked: “
Open extension pages (like this one) in new dialog”. This setting causes most LastPass windows to open as full windows instead of browser tabs. The idea here was to set certain LastPass windows based on title to floating & specific sizes. However, the actual behavior of Sway seemed very buggy.The
for_windowrules tested were:The result is very buggy behavior, which could indicate some race condition with when
titleis set (or simply some coordinates or sizes are wrong on redraw?)floating disableis used infor_windowrule)floating enableis used instead for the "title="Extension.*LastPass.*Edit.*"rule:95 x 95pixels)600 x 400pixel resize occurs