openstenoproject / plover

Open source stenotype engine
http://opensteno.org/plover
GNU General Public License v2.0
2.32k stars 281 forks source link

Mac: new windows don't grab focus correctly when main window is open on different monitor's Space #855

Open morinted opened 6 years ago

morinted commented 6 years ago

Summary

When running Plover with the main window open, spawning a new tool window on another monitor causes the main window to be focused instead of the tool window when using the Mac option "displays have separate spaces"

Mac preferences with Displays have separate spaces

Reproducing

  1. Start Plover on Mac with "displays have separate spaces" setting enabled
  2. Drag Plover main window to monitor 1
  3. Open a tool window, like LOOKUP, drag it to monitor 2
  4. Close the tool window
  5. Focus on some other application
  6. Use a stroke mapped to {PLOVER:LOOKUP}
  7. Expected: Tool window should be focused, actual: Plover main window is focused, tool window is unfocused.

Conditions:

Plover Version

All QT versions of Plover

System

Mac 10.13+

morinted commented 4 years ago

Updated the main post to clarify that this only happens when you have a separate "space" (virtual desktop) for each monitor. I wasn't able to find a specific QT bug for this, and I figure because it's not too common to be spawning QDialogs without any focus on the QApplication (which we do through the use of chords).

1: Plover is open on left monitor, focus is on an application on right monitor.

Screen Shot 2020-04-17 at 4 19 41 PM

2: Summon dictionary update with {plover:add_translation}. Notice that focus looks broken—add translation window should be focused, but focus is actually on main window. The add translation window opens, and then focus is taken by the main window all at once.

Screen Shot 2020-04-17 at 4 19 50 PM

3: Pressing {plover:add_translation} again now actually focuses the correct window.

Screen Shot 2020-04-17 at 4 20 01 PM

morinted commented 4 years ago

@benoit-pierre This issue is very annoying and I've been trying to think of a platform-specific fix.

So far, I've tried raising the main window first, or raising the pop-up, the main window, and reraising the pop-up, but it doesn't have the desired effect.

I think what might be necessary is something like

How might I accomplish this in QT? I think next I'm going to try raising the main application window, then putting the pop-up raising in a single shot.

benoit-pierre commented 4 years ago

Does changing the window activation behavior have any impact?

benoit-pierre commented 4 years ago

And just to clarify, this only happen if the main window is not minimized, right?