Re: [dev] [st] no focus events inside tmux

From: <k0ga_AT_shike2.com>
Date: Wed, 30 Mar 2016 16:30:52 +0200

Hi,

> I'm glad someone finally tried it.:)


I'm sorry. I am setting my network now, and I cannot read
the mail as fast as I used to do it. BTW, the another
maintainer shold have to answer, but he is a bit lazy ...

> However, I wonder how you could receive this focus-in event:

I mistook, I didn't receive it.


> Let's make more detailed test case:
> $ sudo pacman -S st dwm # Actually: st-0.6.3, dwm-6.1-3
> $ cat ~/.tmux.conf
> set -g default-command /bin/bash
> set -g focus-events on
>
> In dwm:
> - A-S-<Enter> # to launch first _bare_ terminal
> $ st # to launch terminal from another
> $ tmux -L test # independent tmux server

At this point you get a \e[?1005h in the terminal because tmux
is trying to see what is the correct mode [1].

> $ printf "\e[?1004h"
> - <C-v>
> - A-j/k
>
> Results:
> - cursor slightly blinks, which indicates focus lost/gain
> - but nothing printed (no focus in/out events in tmux)
> - however on splitting tmux C-b % those events immediately shown
>

The code in st that handles it is very simpe:

                        case 1004: /* 1004: send focus events to tty */
                                MODBIT(term.mode, set, MODE_FOCUS);
                                break;
-----

        void
        focus(XEvent *ev)
        {
                XFocusChangeEvent *e = &ev->xfocus;
        
                if (e->mode == NotifyGrab)
                        return;
        
                if (ev->type == FocusIn) {
                        XSetICFocus(xw.xic);
                        xw.state |= WIN_FOCUSED;
                        xseturgency(0);
                        if (IS_SET(MODE_FOCUS))
                                ttywrite("\033[I", 3);
                } else {
                        XUnsetICFocus(xw.xic);
                        xw.state &= ~WIN_FOCUSED;
                        if (IS_SET(MODE_FOCUS))
                                ttywrite("\033[O", 3);
                }
        }

We can try to test if we are receiving the event or not.
The posibilities here are:

        - Mode is NotifyGrab
        - We do not receive the event

I am a bit busy at this moment, but I will look it as soon as
possible.
        
Regards,

[1] https://github.com/tmux/tmux/blob/master/input-keys.c#L252
Received on Wed Mar 30 2016 - 16:30:52 CEST

This archive was generated by hypermail 2.3.0 : Wed Mar 30 2016 - 16:36:13 CEST