swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.51k stars 1.11k forks source link

"move workspace" does not behave as expected for an empty workspace #5388

Open revulent opened 4 years ago

revulent commented 4 years ago

sway version 1.4 If an empty workspace exists, such as on another monitor, attempting to move the workspace via IPC to another output does not work. The workspace stays on that output.

this can be tested with my script meant to swap workspaces on outputs. This works as expected as long as the target workspace is not empty. If it is empty, the workspace never changes outputs. The behavior is the same if I use swaymsg via wofi on an empty workspace

#!/usr/bin/env python
import asyncio
from i3ipc.aio import Connection
from sys import argv
async def main():
    i3 =  await Connection().connect()
    outputs = await i3.get_outputs()
    workspaces = await i3.get_workspaces()
    target_workspace = None

    for output in outputs:
        if output.focused == True:
            focused_output = output
    for workspace in workspaces:
        if str(workspace.num) == argv[1]:
            target_workspace = workspace
        if workspace.output == focused_output.name:
            prev_workspace = workspace

    # if the target workspace doesn't exist, create it
    if target_workspace == None:
        await i3.command('workspace ' + argv[1])
    else:
        # Move target workspace to focused output
        await i3.command('workspace ' + str(target_workspace.num) + '; move workspace to output ' + focused_output.name + '; workspace ' + str(target_workspace.num))
    # move previous workspace to target workspace's output
        await i3.command ('workspace ' + str(prev_workspace.num) + '; move workspace to output ' + target_workspace.output + '; workspace ' + str(prev_workspace.num))
    # focus target workspace at the new output
        await i3.command ('workspace ' + str(target_workspace.num))

asyncio.run(main())
jameswalmsley commented 2 years ago

Can confirm this issue still exists in sway v1.7. I'll check the latest HEAD, and try to make a PR if its still a problem.

awwaiid commented 3 months ago

I'm seeing this too, iiuc -- Is this the expected behavior?