1

On ubuntu 18.04.3, gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'strict' does not work if I open a CSV file from a web browser and an instance of LibreOffice is already open. Here is a step-by-step of what happens:

  1. I open an instance of LibreOffice Calc Version: 6.0.7.3 (or any instance of LibreOffice [Writer|Calc|Draw|Impress]).
  2. I open an instance of firefox version 72.0.1 (64-bit).
  3. In firefox, I load a web page that displays a link to a remote CSV file.
  4. I click on the link to download/open the CSV file.
  5. A pop-up displays, prompting me to do either of the following:

    • Open with LibreOffic Calc (default)
    • Save File the CSV file.
  6. I select Open with and nothing seems to happen (WHY?). I expected an instance of LibreOffice Calc to become the active window over the Firefox web page I was on, but it did not.

  7. I [Alt]+[Tab] to the pre-existing open instance of LibreOffice Calc and there is a pop-up dialogue prompting me to indicate what encoding to open the CSV file in. So, it seems a new instance of LibreOffice Calc opened for the CSV, but it is tied to the other, pre-existing instance of LibreOffice and, therefore, it does NOT steal the focus.

However, if do NOT have any instance of LibreOffice open and go through steps 2 through 6, then the strict does work (GOOD), meaning that an instance of LibreOffice Calc opens and steals focus.

So, why does strict not work if an instance of LibreOffice is already open and I open another instance from a web browser?

UPDATE: 2020-01-23 I recently learned that the two modes for a window are:

  • raise = raises a window to the top of a window stack (moves it to the front of the display)
  • focus (or active) = The window to which input is directed.

I also changed some gsettings and now it seems that gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'strict' does not behave according to my statements before this update. Instead, it seems that gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'smart' is the setting that raises and focuses the new window.

Here are my current gsettings...

$gsettings list-recursively | grep 'raise\|focus' | grep pref
org.gnome.desktop.wm.preferences focus-new-windows 'smart'
org.gnome.desktop.wm.preferences raise-on-click true
org.gnome.desktop.wm.preferences auto-raise true
org.gnome.desktop.wm.preferences focus-mode 'click'

And here are the results of my tests in terminal (opening gedit and also [Ctrl]+[Alt]+[T]) and nautilus (opening a CSV file in the file manager) to know whether the respective new windows are raised and/or focused...

-if org.gnome.desktop.wm.focus-new-windows=smart
    *In terminal, if there is NOT a pre-existing window, then the new window does raise (GOOD).
    *In terminal, if there is NOT a pre-existing window, then the new window does focus (GOOD).
    *In terminal, if there is a pre-existing window, then the new window does raise (GOOD).
    *In terminal, if there is a pre-existing window, then the new window does focus (GOOD).
    *In nautilus, if there is NOT a pre-existing window, then the new window does raise (GOOD).
    *In nautilus, if there is NOT a pre-existing window, then the new window does focus (GOOD).
    *In nautilus, if there is a pre-existing window, then the new window does raise (GOOD).
    *In nautilus, if there is a pre-existing window, then the new window does NOT focus (BAD). <---- I WANT THIS TO FOCUS.

-if org.gnome.desktop.wm.focus-new-windows=strict
    *In terminal, if there is NOT a pre-existing window, then the new window does NOT raise (BAD).
    *In terminal, if there is NOT a pre-existing window, then the new window does NOT focus (BAD).
    *In terminal, if there is a pre-existing window, then the new window does NOT raise (BAD).
    *In terminal, if there is a pre-existing window, then the new window does NOT focus (BAD).
    *In nautilus, if there is NOT a pre-existing window, then the new window does raise (GOOD).
    *In nautilus, if there is NOT a pre-existing window, then the new window does focus (GOOD).
    *In nautilus, if there is a pre-existing window, then the new window does raise (GOOD).
    *In nautilus, if there is a pre-existing window, then the new window does NOT focus (BAD).

It seems that the smart value gives the closest desired behavior, except if there is a pre-existing window (e.g., LibreOffice is already open), then the new window is raised (GOOD) but not focused (BAD). How can I focus the new window?

UPDATE 2020-02-22


One workaround that seems to work a little better is to make the following settings...

focus-mode='sloppy'
focus-new-windows='strict'

...Which will raise the window and, ONLY IF the mouse is already in the new window, then focus the window. The problem is if the window is raised and the mouse is not already in the new window, then the window is not focused.

The ideal situation would be for the new window to raise and focus, regardless of the mouse location.

2

The default behaviour of Gnome Shell indeed is rather obscure and unpredictable in that respect. To get rid of that issue, you can install a Gnome Shell extension appropriately named "No Annoyance", It is fully supported within a default Ubuntu install: you can install it with Software Center or with the command

apt get install gnome-shell-extension-no-annoyance

It will always bring the new windows in focus.

4
  • gnome-shell-extension-no-annoyance does not seem to change the behavior. Might be there be a conflict between it and my gsettings? – Arya Jan 23 '20 at 10:08
  • 1
    I cannot reproduce the issue. For me, opening a csv from a link does bring Calc in the foreground, whether or not it is already open. That is on 19.10, however, not 18.04 so it could be related to the version. – vanadium Jan 23 '20 at 10:30
  • What are your gsettings, if you have any? – Arya Jan 23 '20 at 10:33
  • 1
    Same except auto-raise false and I have an additional auto-raise-delay 500. Also, I run a gnome-session, not the default Ubuntu session. – vanadium Jan 24 '20 at 8:16

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.