Focus stealing when using QT graphics toolkit

Problem description

When using the QT graphics toolkit, the plot windows steals focus whenever the plot is updated. This is really annoying when I run a script that plots out a time series at regular intervals to show the progress of the algorithm. This does not happen when using the gnuplot of fltk toolkits. I much prefer the look of the QT toolkit. Is there a way to stop the focus stealing?

My system

  • OS: Kubuntu 20.04 (Plasma 5.18.5)
  • Octave version: native version 5.2.0 & snap version 6.4.0
  • Installation method: native version from Ubuntu repository, snap version via “snap install octave”

The figure function transfers the focus to the respective figure. That is how it is supposed to work (but might not work correctly with the gnuplot or fltk graphics toolkits).

You could maybe avoid calling the figure function by storing and re-using the respective figure handles when updating the plots.

Markus, many thanks for quick response.

** The figure function transfers the focus to the respective figure. That is how it is supposed to work

Fair enough but personally I’d vote for this to be changed. At the moment I can’t even use another program whilst my octave script is running since the other program keeps loosing focus.

I have used this plotting technique in quite a lot of scripts so changing to using handles is going take some effort. :slightly_frowning_face:

Thanks again for the help.

I don’t think this will be changed. You’d need to make the effort and properly fix this in your code.

In most cases (except figure creation) changing figure (N) to set (0, "currentfigure", N) should be enough.

1 Like

Internally, it is the __show_figure__ function that is responsible for giving the focus to the figure. If you define your own function, this will prevent the built-in one from being invoked. E.g.

function __show_figure__ (h)
  ## Do nothing
endfunction

This workaround should be enough to recover the old behavior.

Pantxo, many thanks for your useful suggestions.