Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New window does not replace the existing window #1

Closed
WhyNotHugo opened this issue Sep 15, 2021 · 1 comment
Closed

New window does not replace the existing window #1

WhyNotHugo opened this issue Sep 15, 2021 · 1 comment

Comments

@WhyNotHugo
Copy link
Contributor

Say I have a vertical split like so:

| terminal | tabbed[multiple windows] |

If I run swayhide something on my terminal, the terminal disappears, and the
new window appears as a child of the container on the right.

I kind of expected swayhide to replace my current window with the new one,
rather than spawn the new one elsewhere.

I think this can be achieved by:

  • mark original window
  • split h
  • spawn new window
  • move marked to scratchpad
  • split none

The result is that the new window is dropped into the same place as the
original one, with affecting the exterior layout at all.

What are your thoughts on this? Does the idea/feature/change make sense?

@NomisIV
Copy link
Collaborator

NomisIV commented Sep 16, 2021

The ideal behavior is indeed to replace the window, but I haven't been able to figure out how to do it in all scenarios. Currently the program spawns the child command before hiding the terminal, which can lead to unpredictable behavior:

In one case, the new window may open before the terminal is hidden. In this case the window will spawn as a child of the terminal, since the terminal is still the focused window at spawn.

In the second case, the new window opens after the terminal is hidden. In this case the focused window will change to the other window group, since they are the only windows left. So when the new window spawns, it will spawn as a child to the other group, instead of being a child of the terminal itself.

I guess the real solution to this would be to wait until the child window has spawned, before hiding the terminal. Or perhaps moving the new window to the same mark as the one set by the old window.

Please let me know if I've got something wrong. I don't really know anything more about sway than I had to to write this program.

Also, feel free to send a PR if you manage to make something that works better. I might find some time to personally look into this again, but cannot leave any deadlines.

WhyNotHugo pushed a commit to WhyNotHugo/swayhide that referenced this issue Sep 22, 2021
This is not at all ready to be merged, but is an experiment trying to
implement rehanzo#1.

By converting the original window into a split, the newly-created window
is added to that split (which guarantees that they're adjacent). Since
the original window is then hidden, the new window effectively takes its
place.

This has a few caveats:

- There's a "wait 1s" hardcoded there:
  - If the new window is faster, this is weird and glitchy.
  - If the new window is slower, this doesn't work.
- When the new window _exits_, the swallowed window won't always take
  its place: it'll be placed relative to the last-focused window, and
  I can't think of any way around this other than continuously
  monitoring the tree to find our right position.

The timeout can we worked around by waiting for _any_ window to appear,
and assuming the first new window to spawn is the one we're creating.
This might be flaky, but I suspect it'd work 90% of the time.

An alternative implementation could also be using a new stacked/tabbed
layout, where the new window is a second in that container. If sway
allowed us to hide the stack/tab bar on that container, we'd be 100%
covered.
@NomisIV NomisIV closed this as completed Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants