Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
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 '12 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 '12 at 19:20

2 Answers 2

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.

share|improve this answer
    
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 '12 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! –  Aquarius Power Nov 18 at 19:45

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 -->
share|improve this answer
    
I installed openbox just to try this, but I think you forgot to say, in what file do you find those lines? –  Emanuel Berg Nov 5 '12 at 22:49
    
OK, found it: /etc/xdg/openbox/rc.xml –  Emanuel Berg Nov 5 '12 at 23:00
    
@MarkBooth. Try wmctrl -m –  Stéphane Chazelas Nov 6 '12 at 10:53
    
Thanks Stephane, I've updated my question. –  Mark Booth Nov 6 '12 at 11:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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