zeroxoneafour / kwin-autotile

Autotile script for kwin
https://store.kde.org/p/2003956
MIT License
44 stars 1 forks source link

Strange issues with emacs comming up behind others #10

Closed peterhoeg closed 1 year ago

peterhoeg commented 1 year ago

I have a basic vertical split in the middle.

If I launch konsole it takes the full screen. If I launch a 2nd konsole, they split nicely.

But at some point things started going wrong with emacs, where the emacs window opens behind. So this is what happens:

  1. On a blank desktop
  2. Open konsole through shortcut
  3. Konsole takes the whole screen
  4. From konsole, launch emacsclient
  5. The emacs window then opens full screen behind konsole
  6. I cannot even do Alt-Tba to switch between them as the emacs window has "Keep below others" set (not by me)
  7. If I unset it, I can alt-tab but force retile still doesn't split the screen and I'm left with 2 full-screen windows

FYI, running with "Debug Mode" enabled gives no output in the journal

peterhoeg commented 1 year ago

A restart “fixed” it, but I have seen it a few times, so I’m leaving debug mode enabled to help find out what is going on, the next time it happens.

I wasn’t getting data in the journal after enabling debug mode as I hadn’t restarted plasma (maybe make a note about that in the settings?)

zeroxoneafour commented 1 year ago

None of the settings apply until restarting KWin, despite having a signal attached to reload options upon editing settings.

I just installed emacs and tried to replicate this bug and everything worked correctly with and without debug mode enabled.

There are lots of race conditions in the code due to the way KWin works internally and there's nothing I can do about that. You may have just been on the unlucky end of one and it caused a bug.

zeroxoneafour commented 1 year ago

Do you think any emacs plugins you have might have done something to cause this bug?

peterhoeg commented 1 year ago

As mentioned, after rebooting, everything worked again, but hopefully something will be revealed through the journal when I next experience this.

Thanks for kwin-autotile!

zeroxoneafour commented 1 year ago

You're welcome! I hope that the bug does not come up again, maybe it could be caused by debug mode changing the delay between the signals and stopping the race condition bug? As long as it works.

peterhoeg commented 1 year ago

I’m able to reproduce the error and it has nothing to do with emacs as such.

  1. on a blank desktop
  2. create a single vertical split with Meta-T
  3. launch konsole
    1. it goes full screen
    2. it has “keep below others” set
  4. launch konsole
    1. the screen splits correctly into 2
    2. it has “keep below others” set
  5. launch konsole
    1. the new konsole is full screen hiding konsoles 1 and 2
    2. it does not have “keep below others” set

I can now not alt-tab to konsoles 1 or 2 as although the get focus (I can see that from the task manager), it’s still only konsole 3 being shown presumably due to the “keep below others” bit.

zeroxoneafour commented 1 year ago

I know what this issue is, the third konsole window is not tiled. If there is no space in the layout left, new windows are not tiled. The reason the konsole window appears so big is because it keeps the geometry that it had before it was tiled, even if it is closed.

To be clear, this is a feature of the script and not a bug. The konsole window on top should also have a titlebar unless titlebars are set to completely disabled in the settings. Therefore, you should be able to move it and tile it if you have more space in your layout.

The solution here is simply to add more available tiles to your layout through the KWin ui.

peterhoeg commented 1 year ago

If there is no space in the layout left, new windows are not tiled.

And that’s totally OK.

To be clear, this is a feature of the script and not a bug.

I would argue that the other windows should have “keep below others” unset, so that it’s possible to alt-tab between them.

My workflow is as follows.

Most of the time, I’m running with a single application maximized for a given desktop. In some cases I open a 2nd (hence the vertical split).

If a 3rd window is launched it’s always temporary but I will need to jump back and forth until I’m done with the 3rd and it’s closed again.

zeroxoneafour commented 1 year ago

I do enjoy having floating windows always on top, but I can see how it could be necessary for that to not always be the case. I'll add a toggle for this feature in the settings.

I also should probably document somewhere that you need to restart KWin for changes to take effect in the script.

peterhoeg commented 1 year ago

I’ll add a toggle for this feature in the settings.

Thank you!

I also should probably document somewhere that you need to restart KWin for changes to take effect in the script.

Maybe just in the settings panel itself?