Typical situation is that I type something (worst case is my password) in some application, when some other application pops up a window and steals the focus, so my typing (password) goes to something else. I would like to prevent this, at least when I actively type something in an edit box. I always really hated this on Windows, but I never found a way to prevent this. I started using Ubuntu a while ago, and so far I was able to do everything I wanted, so I thought maybe this is also possible. Thanks in advance!

  • 4
    Try to change a setting with the terminal command gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'strict'. Let us know if that works in your case. To reset to default, give the command gsettings reset org.gnome.desktop.wm.preferences focus-new-windows – vanadium Oct 15 '18 at 20:13
  • 3
    Thanks. With this change the new windows appear in the background, but interstingly the focus is lost. So for example I start typing in the terminal, and meanwhile I start some application with starts up quite slowly. I click on the application on the left side in the favorites, click back to the terminal window to continue typing. In a few seconds the application starts, its window is put behind the terminal window (which is good) but I lose the focus, and cannot type until I click on the terminal window again. – Imre Major Oct 16 '18 at 15:26
  • A pity this did not work completely. It remains something that is difficult to control. Many related questions over the years unfortunatelly remained unanswered. – vanadium Oct 16 '18 at 16:05
  • It's not a bug, it's a feature! :( Another variation of this which affects my project is that when my app displays a pop-up (using yad) and the user clicks anywhere else, from then on that pop-up and all subsequent ones from the same app never get the focus back, even when they're on top! (The same thing would happen if another app displayed a window as in your case.) ... – Joe Oct 18 '18 at 3:55
  • ... I haven't tried it yet, but I'm thinking about writing another little app (that my main app can start in the background and subsequently stop when it no longer needs it) that just sits in the background looking for my pop-ups and gives the focus back to them. It appears to be easy enough to write using bash and xdotool, but a lot of things look simple before you try to implement them. This would have to know what windows it was looking for in advance, so it's not a generic solution to your issue. – Joe Oct 18 '18 at 4:01

The best recommendation I have for this issue is using "Always On Top" or "Always Below Other Windows" options for the window you need to remain (un)focused. Just right-click your title bar and check the option. I can promise, that window anyhow, will and/or will not lose focus for anything popping up.

You can also force certain windows to stay on a particular workspace. You could also divert the applications that have frequent notifications to workspace 1 and then operate from workspace 2.

| improve this answer | |

As you haven't accepted an answer yet, perhaps using this bug - a minimized always-on-top window to not even put on-demand new windows on top, would help.

| improve this answer | |
  • The bug you linked is for elementary OS and Gala. Not sure how useful it is for Ubuntu 18.04 with GNOME 3. – pomsky May 3 at 16:21
  1. Install CompizConfig Settings Manager

    • either from Ubuntu Software Center
    • or via terminal:

      sudo apt-get install compizconfig-settings-manager
  2. Open CompizConfig Settings Manager and go to General -> General options -> Focus and raise behaviour

  3. Change the 'Focus prevention level' from 'Low' to 'Normal'.

| improve this answer | |
  • Not applicable to Ubuntu 18.04 with GNOME 3, it doesn't even have Compiz. – pomsky May 3 at 16:18
  • @pomsky I just today did the above steps on my Ubuntu 18.04 and they worked. I don't remember having added Compiz individually, other than the mentioned package. How could it be working? – Vassilis Barzokas May 3 at 18:58
  • Is your system upgraded from an older Ubuntu release? – pomsky May 3 at 19:00
  • No, it was installed as 18.04.1 and has been upgraded just up to 18.04.4 and I can verify that my window manager is Gnome 3, so I haven't changed it. Have you tried the above steps on your Ubuntu 18.04 and didn't work? I wonder if adding CompizConfig Settings Manager also adds any prerequisite that make this requested feature working. In any case I only did the above and I am no longer experiencing the issue. – Vassilis Barzokas May 3 at 19:06
  • Okay, fair enough! – pomsky May 3 at 19:09

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.