thrombe / hyprkool

Hyprland plugin to replicate the feel of kde activities and desktop grid layout
MIT License
51 stars 4 forks source link

Windows don't always appear on proper workspaces #17

Open S0nter opened 1 week ago

S0nter commented 1 week ago

This is a strange behavior (might be a race condition) when I start an application, it starts but the window is nowhere to be found.

After checking hyprctl clients it turns out that the window spawned on a strange workspace like my-activity:(1 (no closing bracket).

Also it is possible to spawn a window on the overview workspace e. g. my-activity:(1 1):overview and it will be above overview.

Here are my scripts that help to workaround this bug:

~/.local/bin/fix_wrong.sh

#!/usr/bin/env bash

clients="$(hyprctl clients -j)"
active="$(hyprkool info workspaces 2> /dev/null | jq '.[].[]' --compact-output | grep '"focused":true' | jq '.name' --raw-output)"

for i in $(seq 0 $(( $(echo "$clients" | jq '.[].address' | wc -l) - 1)) ); do 
    workspace="$(echo "$clients" | jq ".[${i}].workspace.name" --raw-output)"
    address="$(echo "$clients" | jq ".[${i}].address" --raw-output)"
    name="$(echo "$clients" | jq ".[${i}].class" --raw-output)"
    args="name:${active},address:${address}"
    echo "$workspace" | grep ')' -q || (hyprctl dispatch movetoworkspacesilent "$args" && echo "Focused $name ($args) was on \"$workspace\"")
done

~/.local/bin/fix_wrong_daemon.sh

#!/usr/bin/env bash

# Execute the script every 1 second
while true; do
    ~/.local/bin/fix_wrong.sh
    sleep 1
done

In hyprland.conf:

exec-once = ~/.local/bin/fix_wrong_daemon.sh
thrombe commented 1 week ago

This is a strange behavior (might be a race condition) when I start an application, it starts but the window is nowhere to be found.

can you tell me how you are launching applications when this happens? this could happen because thers's a space in the name of the workspace. example: my-activity:(1 1), which might be ruining the day. but generally launching apps works properly in my env and the minimal virtual machines that i tested on.

thrombe commented 1 week ago

Also it is possible to spawn a window on the overview workspace e. g. my-activity:(1 1):overview and it will be above overview.

hmmm. it is supposed to disable overview as soon as any window is focused. this seems to be working correctly in a minimal test vm. how are you launching apps on this workspace again?

S0nter commented 6 days ago

can you tell me how you are launching applications when this happens?

Kate with a lot of files via a hyprland keybind, mpv Here is the output of my updated script in a case with Kate:

ok
Focused org.kde.kate (name:,address:0x5c7d9c472400), was on "my-default-activity:(3"
ok
Focused org.kde.kate (name:my-default-activity:(3 3),address:0x5c7d9c472400), was on "-1510"

hmmm. it is supposed to disable overview as soon as any window is focused. this seems to be working correctly in a minimal test vm. how are you launching apps on this workspace again?

This happened to me when one of the application spawned dialog window/popup when I was in the overview workspace (that application might have been focused so your code didn't detected anything). It is also possible to move a window there with hyprctl.

thrombe commented 5 days ago

Kate with a lot of files via a hyprland keybind

can you specify some keybinds that i can test? i can't fix this if i can't reproduce the bug.

This happened to me when one of the application spawned dialog window/popup

this should have triggered the check for window focus change. needs more investigation. do you have a way to reproduce this?

It is also possible to move a window there with hyprctl.

yes. that is expected. not a bug.

S0nter commented 4 days ago

Kate with a lot of files via a hyprland keybind

can you specify some keybinds that i can test? i can't fix this if i can't reproduce the bug.

Here you go:

~/.config/hypr/hyprland.conf:

bind  = SUPER, H, exec, bash -ic edit-hyprland

~/.bashrc:

edit-hyprland() {
    kate -b $(find ~/.config/hypr/ ~/.config/waybar/ ~/.config/rofi/ -type f) ~/.config/hypr/hyprland.conf
}

However, it seems like the actions that are happening during the launch make the difference. I can reproduce the bug with spamming hyprkool move-left (or similar) right after activating the keybind. I hasn't been able to reproduce this by a bash function, only with this hyprland keybind.

Steps to reproduce (there should be as little delay as possible between steps 3 and 4):

  1. Add the lines above to those files
  2. Open terminal emulator
  3. Press SUPER + H
  4. Run inside a terminal emulator:
    timeout 8 bash -c "while :; do hyprkool move-left -c; done"
  5. The window is not on any of the workspaces (doesn't work 100% of the time)

I hope this is enough. If not, I will try to create a script that opens a popup on the overview.

thrombe commented 4 days ago

okay i was able to reproduce this just using hyprctl. so this might be a bug in hyprland. i ran this command and spammed a keybind to launch dolphin

timeout 1 bash -c "while :; do hyprctl dispatch workspace 'name:issac:(1 1)'; hyprctl dispatch workspace 'name:issac:(2 1)'; done"

and sure here it is

$ hyprctl clients -j
...
...
},{
    "address": "0x7daedf0",
    "mapped": true,
    "hidden": false,
    "at": [1, 41],
    "size": [2558, 1558],
    "workspace": {
        "id": -1359,
        "name": "issac:(1"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 0,
    "class": "dolphin",
    "title": "Home — Dolphin",
    "initialClass": "dolphin",
    "initialTitle": "Home — Dolphin",
    "pid": 592391,
    "xwayland": true,
    "pinned": false,
    "fullscreen": 0,
    "fullscreenClient": 0,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 26
}]

what i find odd here is that this only breaks at the space.

thrombe commented 4 days ago

you might want to make an issue on hyprland's repo for this. the overview issue however might be a bug in hyprkool-plugin. i'll test that when i find a way to reproduce it.