Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving script from floating script window moves window focus back to the main editor window #78672

Closed
nyxkn opened this issue Jun 25, 2023 · 8 comments · Fixed by #83290
Closed

Comments

@nyxkn
Copy link

nyxkn commented Jun 25, 2023

Godot version

master (3710f06)

System information

Godot v4.1.beta (3710f06) - Arch Linux #1 ZEN SMP PREEMPT_DYNAMIC Sat, 10 Jun 2023 00:35:19 +0000 - Vulkan (Forward+) - dedicated AMD Radeon R9 380 Series (RADV TONGA) () - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

Issue description

Using i3wm, tiling window manager.

If I'm in the floating script window and I hit Ctrl+S to save, the window focus gets switched to the main Godot window.

I'd expect it to stay on the script window instead.

Note: this happens only when the script is associated with a scene. A standalone script does not trigger the focus switch.

Steps to reproduce

Float script window, use ctrl+s to save, see focus returned to main godot editor window.

Following screencap of this exact sequence. I switch focus to the script window, type "pass" and press ctrl+s. and you can see the blue square around the windows showing current focus move back to the main window.

bug-demo.mp4

Minimal reproduction project

You only need a scene with a script attached.

@robbertzzz
Copy link

robbertzzz commented Jul 10, 2023

Note: this happens only when the script is associated with a scene. A standalone script does not trigger the focus switch.

For me this also happens on scripts that aren't associated with a scene.

@Sauermann
Copy link
Contributor

Sauermann commented Jul 10, 2023

I have tracked on Linux, where the Main Window gets brought to the foreground, when the "Saving Scene" popup appears:

XMapWindow(x11_display, wd.x11_window);

Not sure, how to prevent this from happening.

@saikyun
Copy link

saikyun commented Jul 15, 2023

This happens for me on MacOS too.
Godot v4.1.stable - macOS 12.5.0 - Vulkan (Forward+) - integrated Apple M2 - Apple M2 (8 Threads)

@sian2005
Copy link

I can confirm on my windows machine this also occurs, and expanding this issue there is a stutter when using an undocked script and adding a breakpoint, after that when you press F10/F11 to scroll through your code, it stutters back to the main Godot window and instantly goes back to the script editor, which is also not expected behaviour.

@trollodel
Copy link
Contributor

I read this and other issues about the problem.
Given that the focus change can't be workarounded, as the OS may change focus automatically on exclusive popups as stated in this comment, I think the following are the possible solutions:

  1. Reparent the progress dialog on the currently focused window just before it appears.
    This allows to restore the focus to the right window once the progress dialog is hidden.
    Unfortunately, it seems that it's not possible to get the currently focused window without visiting the scene tree (if I'm wrong, let me know), so it's necessary to keep a list of windows somewhere to check their focus.
  2. Make the progress dialog non-exclusive. I tested this and works, but I'm not sure how many bugs I can introduce by doing this.

3. Get rid of that annoying popup and move the progress somewhere else

I'll work on solution 1 in the following days.

@Sauermann
Copy link
Contributor

Unfortunately, it seems that it's not possible to get the currently focused window

See #79261, which implements this functionality.

@trollodel
Copy link
Contributor

Unfortunately, it seems that it's not possible to get the currently focused window

See #79261, which implements this functionality.

Very nice, I'll build the solution for this issue on that PR.

@lamdevhs
Copy link

I personally just mapped 'save script' to Ctrl+S (by default it is 'Ctrl+Alt+S', but Ctrl+S seems to work as well, except it tries to save the main scene which triggers the change of focus). Then you get two actions mapped to Ctrl+S but Godot doesn't seem to mind.

I just found that solution a couple days ago. Before that I just thought this floating script window feature was unusable with window managers.

@akien-mga akien-mga unpinned this issue Oct 18, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 30, 2023
@akien-mga akien-mga modified the milestones: 4.3, 4.2 Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants