FocusIn/FocusOut not generated

2019-03-01 03:11发布

问题:

Can someone please clarify the default focus handling of the X11 server? My understanding is that the focus 'follows the mouse' and sure enough if I move the mouse between separate terminals I can see the cursor changing as each window aquires/loses the focus.

But when I run two xev windows and move the pointer between them, I see plenty of MotionNotify/EnterNotify/LeaveNotify as the pointer moves from one window to another - but FocusIn and FocusOut are nowhere to be seen. Is this an oddity in xev? Is there some special mask or property which needs to be applied in order for these events to be generated?

Many thanks, R.

While I do not fully understand the answer(s), I am grateful to parkydr, minitech and any others who may have stopped by.

Thanks again, R.

回答1:

Having focus refers to the window which receives keyboard input when you press a key.

The focus handling depends on your window manager. The most common mode is click to focus, which your window manager is set to, where you only get focus when you click on the window. An alternative is that the keyboard focus follows the mouse, which is what you are expecting.

There should be a setting to change this in your window manager settings.

The cursor changing does not indicate focus, just that the terminal has defined a different cursor.

To demonstrate, open a terminal and an xev window.

  • Click on the xev window and press a key, you will see key events.
  • Move the mouse to the terminal window, you'll see the motion and leave events
  • Press a key and you'll still see key events from xev
  • Click on the terminal window, xev will give a focus out event
  • Press a key, the characters will be displayed in the terminal window
  • Move the mouse over the xev window and press a key, the character will still come out in the terminal window


标签: x11