Added ICCCM WM_HINTS

When the window is mapped, some ICCCM WM_HINTS are set.
The input field is set to true and state is set to NormalState.

To quote the spec, "The input field is used to communicate to the window
manager the input focus model used by the client" and "[c]lients with
the Passive and Locally Active models should set the input flag to
True". sxiv falls under the Passive Input model, since it expects keyboard
input, but only listens for key events on its single, top-level window instead
of subordinate windows (Locally Active) or the root window (Globally Active).

From the end users prospective, all EWMH/ICCCM compliant WMs (especially
the minimalistic ones) will allow the user to focus sxiv, which will
allow sxiv to receive key events. If the input field is not set, WMs are
allowed to assume that sxiv doesn't require focus.
This commit is contained in:
Arthur Williams 2020-06-22 22:52:54 -07:00 committed by Berke Kocaoğlu
parent 88f77bc59c
commit ba0d87fadf

View File

@ -154,6 +154,7 @@ void win_open(win_t *win)
Pixmap none; Pixmap none;
int gmask; int gmask;
XSizeHints sizehints; XSizeHints sizehints;
XWMHints hints;
e = &win->env; e = &win->env;
parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr);
@ -252,6 +253,11 @@ void win_open(win_t *win)
sizehints.y = win->y; sizehints.y = win->y;
XSetWMNormalHints(win->env.dpy, win->xwin, &sizehints); XSetWMNormalHints(win->env.dpy, win->xwin, &sizehints);
hints.flags = InputHint | StateHint;
hints.input = 1;
hints.initial_state = NormalState;
XSetWMHints(win->env.dpy, win->xwin, &hints);
win->h -= win->bar.h; win->h -= win->bar.h;
win->buf.w = e->scrw; win->buf.w = e->scrw;