9

I am getting annoyed by windows under X opening and taking focus away from the current window which has focus. This is particularly annoying when you are typing a password into a password dialog and another application steals focus, so some of your keystrokes end up in the new application instead.

I've always been irritated by this in Windows, but there's little that can be done about it there, and I can't help but feel that this should be fixable on Unix.

I'm currently using Gnome as my desktop environment (on RHEL 5.8) and according to wmctrl -m I'm currently using Metacity as my window manager. While I would prefer to stick with these default options I would be happy to learn about window managers which don't exhibit this behaviour.

3
  • 1
    I don't use gnome, but there should be window manager settings and perhaps window tweaks tools that have a 'steal focus' based setting.
    – vgoff
    Nov 5, 2012 at 15:15
  • 3
    Gnome is not a window manager but an entire desktop environment, which may use any one of a variety of window managers.
    – jw013
    Nov 5, 2012 at 19:20
  • Be careful to what you wish for. I have the opposite problem in Gnome. ask.fedoraproject.org/en/question/112121/… The opposite behavior is more annoying that what you think.
    – alfC
    Feb 16, 2018 at 9:23

2 Answers 2

5

FWIW, with xterm, click on the left mouse button while holding the Ctrl key to bring a menu where you can select secure keyboard. which uses XGrabKeyboard to get exclusive usage of the keyboard.

You can also bind it to a key such as with:

xterm -xrm 'XTerm.VT100.translations: #override Shift <KeyPress> F2: secure()'

For Shift-F2. Though you'd rather want that in a resource file (either loaded by xterm like ~/.Xdefaults or stored in the X server with xrdb and queried by xterm) than on the command line.

2
  • That's very specific to xterm which I can't recall having used for years. I would have thought most people using Gnome would be using gnome-terminal.
    – Mark Booth
    Nov 6, 2012 at 10:29
  • I use xterm for many things, I have several open same time as being lightweight; never thought it could have such thing! thx! Nov 18, 2014 at 19:45
2

You're not saying which window manager you're using under gnome. Most common ones are metacity, compiz (and gnome-shell in new versions of gnome) though you can use any you like (though some integrate better with gnome than others).

For openbox, change your configuration file (something like ~/.config/openbox/rc.xml which you can copy from /etc/xdg/openbox/rc.xml) to:

<focus>
  <focusNew>no</focusNew>
  <!-- always try to focus new windows when they appear. other rules do
       apply -->
3
  • I installed openbox just to try this, but I think you forgot to say, in what file do you find those lines? Nov 5, 2012 at 22:49
  • OK, found it: /etc/xdg/openbox/rc.xml Nov 5, 2012 at 23:00
  • @MarkBooth. Try wmctrl -m Nov 6, 2012 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.