treesheets icon indicating copy to clipboard operation
treesheets copied to clipboard

Treesheets when used with XMonad

Open CMCDragonkai opened this issue 3 years ago • 6 comments

I'm running XMonad on NixOS.

When running treesheets there seems to be a very weird problem.

It keeps taking focus away from my other windows. No matter what.

This prevents me from using other windows while having treesheets open.

Treesheets is the only GUI program I've used that has this problem, no other GUI programs I've used on Linux/NixOS/XMonad seems to keep taking window focus away.

CMCDragonkai avatar Jun 24 '21 03:06 CMCDragonkai

That is certainly odd, there's no code in TreeSheets that forces focus of the main window.

TreeSheets is built on wxWidgets, have you used any other apps built with that?

aardappel avatar Jun 24 '21 04:06 aardappel

Don't know, but I couldn't click on any other windows, it would always jump back to the treesheet window.

I also couldn't click on any buttons as I have to use the keyboard to actually hit enter for some reason.

CMCDragonkai avatar Jun 24 '21 04:06 CMCDragonkai

I confirm same behavior in Sway (can't switch away). Slightly less intrusive in Notion, where it just keeps marked red when you leave application. But in case of Notion it can be worked around by switching to another tab in same frame where app is in without loosing its focus.

ony avatar Nov 13 '21 21:11 ony

Narrowed it down to ReFocus. With small patch I can leave app window now:

# ~/.config/nixpkgs/overlays/patches.nix
self: super:
{
  treesheets = super.treesheets.overrideAttrs (attrs: {
    postPatch = ''
      sed -ri '/void ReFocus/,+2s/.*SetFocus/\/\/ &/' src/myframe.h
      ${if attrs ? postPatch then attrs.postPatch else ""}
    '';
  });
}

# for 2.4: nix run --impure nixpkgs\#treesheets

Note that I'm on NixOS 21.05 with treesheets-1.0.1.

I would expect that manual management of focus is needed only in case of some exotic transitions. Otherwise toolkit should handle it including WM/compositor notifications about activation/deactivation.

Not sure why there is a need to ReFocus in various OnColor and others. Maybe something got broken in result. But so far everything seems to work (I'm 2nd day user). When I leave window and return, focus is preserved where it was left.

https://github.com/aardappel/treesheets/blob/82d4b22cc16ff31da6ec5642309c13081a7572d8/src/myframe.h#L999-L1029

ony avatar Nov 13 '21 22:11 ony

I'm running XMonad on NixOS.

When running treesheets there seems to be a very weird problem.

It keeps taking focus away from my other windows. No matter what.

This prevents me from using other windows while having treesheets open.

Treesheets is the only GUI program I've used that has this problem, no other GUI programs I've used on Linux/NixOS/XMonad seems to keep taking window focus away.

I get the exact same behaviour with i3wm on NixOS.

aidalgol avatar Jun 14 '22 23:06 aidalgol

Narrowed it down to ReFocus. With small patch I can leave app window now:

# ~/.config/nixpkgs/overlays/patches.nix
self: super:
{
  treesheets = super.treesheets.overrideAttrs (attrs: {
    postPatch = ''
      sed -ri '/void ReFocus/,+2s/.*SetFocus/\/\/ &/' src/myframe.h
      ${if attrs ? postPatch then attrs.postPatch else ""}
    '';
  });
}

# for 2.4: nix run --impure nixpkgs\#treesheets

Note that I'm on NixOS 21.05 with treesheets-1.0.1.

I would expect that manual management of focus is needed only in case of some exotic transitions. Otherwise toolkit should handle it including WM/compositor notifications about activation/deactivation.

Not sure why there is a need to ReFocus in various OnColor and others. Maybe something got broken in result. But so far everything seems to work (I'm 2nd day user). When I leave window and return, focus is preserved where it was left.

https://github.com/aardappel/treesheets/blob/82d4b22cc16ff31da6ec5642309c13081a7572d8/src/myframe.h#L999-L1029

This patch works for me, as well. I will continue using treesheets for a while before submitting a pull request for this patch.

aidalgol avatar Jun 14 '22 23:06 aidalgol