sagb / alttab

The task switcher for minimalistic window managers or standalone X11 session
GNU General Public License v3.0
389 stars 45 forks source link

Enhancement: Immediately focus window before alttab exits #161

Closed orestisfl closed 8 months ago

orestisfl commented 8 months ago

Current behavior

The alttab menu has a list of windows which an icon and name. That's usually good enough information for identifying each window but sometimes e.g. with many browser windows or terminals it's hard to remember which window is which without focusing it.

Desired behavior

Optionally, alttab could immediately focus the selected window while still keeping the menu open. This way, switching windows can be faster for the user if they don't rely on reading the window information on the screen.

sagb commented 8 months ago

Duplicate: https://github.com/sagb/alttab/issues/158, https://github.com/sagb/alttab/issues/106, https://github.com/sagb/alttab/issues/135, https://github.com/sagb/alttab/issues/140,

orestisfl commented 8 months ago

Not strictly a duplicate, I am not talking about a preview of the window but directly focusing the selected window.

Something very naive like this already works for me locally:

diff --git a/src/gui.c b/src/gui.c
index 8292d66..38868ec 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -122,6 +122,7 @@ static void drawFr(GC gc, int f)
 //
 static void framesRedraw()
 {
+    setFocus(selNdx);
     int f;
     for (f = 0; f < g.maxNdx; f++) {
         if (f == selNdx)

of course, final patch would have to be polished

sagb commented 8 months ago

This approach will not work in most environments supported by alttab. It may function to some extent, but the outcomes will vary. For instance, I executed this in Ratpoison and observed that the alttab dialog did not appear, which contradicts your claim about maintaining the menu open.

Similarly, composite features are problematic for analogous reasons, which is why I categorize them collectively.