Page MenuHome

File browser puts focus on wrong window after closing the dialog
Closed, ResolvedPublicKNOWN ISSUE

Description

System Information
Applies to all operating systems

Blender Version
Broken: 2.81a
Worked: 2.80 (Before the new file browser)

Short description of error

Closing the file browser puts the focus on the newest child window, disregarding which window was originally in focus before the file browser was opened.

Exact steps for others to reproduce the error

  1. Create a new window through Window > New Window
  2. Focus on the original main window
  3. Open a file browser dialog, e.g. through *File > Append* and close it

The focus switches to the child window, even though the dialog was started from there.

Event Timeline

Thank you for the new report, I can reproduce this behavior. The missing key fact was that you don't close the image editor window. The behavior is not exclusive to the exporting of .STLs, it affects all file browser dialogs. It seems the most recently created window, that is a child of a main window, is getting the focus afterwards.

A simpler test is to create two new windows through Window > New Window with adjusted perspective in the 3D view in order to keep track what the most recently created one is. Select the main window and open a file browser windows, e.g. through File > Append and close it by pressing Cancel. The most recently created child window always gets the focus afterwards. This does not apply to a new main window created through Window >New Main Window when there aren't any new child windows yet. When opening and closing the file browser on the new main window it will still returns to the last child window of the original main window. When a child window for the new main window is created through Window > New Window, it will jump this one as well when the test is repeated.

Ah, yes, I noticed that behavior as well (in my case, opening the user preferences will re-use other windows such as the Image Editor, if it's open)

I can reproduce the behavior using the steps described by @Robert Guetzkow (rjg).
However, before this task should be confirmed, the task title and description should be updated to reflect the actual bug better to help the developer who is going to work on this.

Robert Guetzkow (rjg) renamed this task from Export to STL pops-up Image Editor window to Focus switches to newest child window after closing file browser dialog, not the window that originally had the focus.Jan 15 2020, 9:39 PM
Robert Guetzkow (rjg) renamed this task from Focus switches to newest child window after closing file browser dialog, not the window that originally had the focus to File Browser switches focus to wrong window after closing dialog.
Robert Guetzkow (rjg) changed the task status from Needs Triage to Confirmed.
Robert Guetzkow (rjg) triaged this task as Low priority.
Robert Guetzkow (rjg) updated the task description. (Show Details)
Robert Guetzkow (rjg) renamed this task from File Browser switches focus to wrong window after closing dialog to File browser puts focus on wrong window after closing the dialog.Jan 15 2020, 9:41 PM
Julian Eisel (Severin) changed the subtype of this task from "Report" to "Known Issue".Jan 21 2020, 5:18 PM

The reported issue is caused by this workaround: https://developer.blender.org/diffusion/B/browse/master/source/blender/windowmanager/intern/wm_window.c$439

When opening the file browser, we register it in the OS as dialog window - as of now, it's the only kind of window we do that for. For that to work we also need to assign the window to a "parent" window (loosely speaking) to the OS. Now, the OS typically takes over the ordering of windows, moving other non-dialog windows like the Preferences to the back, so that the dialog window and its parent are in front. That makes it seem like the preferences got closed. The workaround is, that we just move other windows back in front when closing a dialog window (i.e. file browser).

Maybe we could workaround this issue too, i.e. by keeping a window selection history. However before too long, we should look into improving our dialog and secondary window behavior, see T69819. With that done, the window ordering workaround that causes this issue can be removed.
So I don't think it's worth the hassle of introducing a temporary workaround for this temporary workaround.
Marking this as "Known Issue".