- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 23.5k
 
Add support for embedding subwindows and dual screen GameViews #104079
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
base: master
Are you sure you want to change the base?
Add support for embedding subwindows and dual screen GameViews #104079
Conversation
628d091    to
    2fc4344      
    Compare
  
    | 
           Rebased to handle the new mute audio button. Like the other debugger controls, it works the same as before on the main game view and is hidden on the secondary view for now to prevent confusion :)  | 
    
2fc4344    to
    e8df7f1      
    Compare
  
    | 
           Rebased to handle the feature profile changes. Thanks to the update, there are less   | 
    
1378c8f    to
    8a6e130      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my end (Fedora 41 GNU/Linux), this breaks a few things:
- Clicking the "Game" tab doesn't focus the window when floating is enabled, instead it switches to it, in a blank state.
 - Running with "Custom Window" makes so that no window is embedded at all.
 
          
 Thanks for trying it out, you're right that this became broken somehow. It was working correctly when I first created the PR but somewhere along rebasing it got messed up, so it should be an easy fix! 
 You mean setting the dropdown to "Custom Window" and leaving the title blank? On Windows it results in the Main Window getting embedded: Note that I haven't implemented subwindow embedding on Linux, but this "empty title" case should give the same result because currently Linux should always embed the main window (only the displayserver signatures were changed). If this is what's happening, I might need to look into this further and get some help testing on Linux. However, if you put some string into the custom window title field then this might be the expected result on Linux until someone (probably @Hilderin ) matches the Windows implementation and verifies it in a future PR :)  | 
    
| 
           I see. Then this leaves only the empty "Game" tab then.  | 
    
8a6e130    to
    102c332      
    Compare
  
    | 
           @YeldhamDev Understood. I've updated the code to fix the tab switching issue now, and introduced a new Display Server feature called  Feel free to give a try and let me know if this looks better!  | 
    
| 
           You should probably hide the dual view option as well.  | 
    
          
 That's really nice, I support this! I'm working on window embedding on Wayland and being able to not immediately implement subwindow embedding without breaking the editor would be very nice.  | 
    
102c332    to
    bb42f95      
    Compare
  
    | 
           Apologies for the delay, I've rebased the branch now and also updated the code to disable the dual screen options if   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issues I pointed out were fixed. Still, it's better if someone on a platform where this feature is implemented would give a proper review.
| 
           Hey, love the idea of this PR and have been messing around with it, and it works well. A couple of things I wanted to open for discussion. 
 Screen.Recording.2025-05-01.214221.mp4
 I may play around with 2 and 3, but just wanted to post here just incase.  | 
    
          
 Wow, this is awesome, thank you so much! I think is really useful and had considered it a while ago but tried to keep the scope down for my initial attempt haha. Would be nice to have it in for this PR! If you'd like, I can paste in your changes to this commit and add you as a co-author? That seems the easiest path for me, or if you have another idea/want your own PR that works too. 
 Yup it was discussed in the proposal here: godotengine/godot-proposals#11091 The work needed for that is definitely something a future PR should handle, but I've got ideas on how to tackle it after this. In short, we could send a debugger signal to create a Window Node with a custom name and reuse the embedded subwindow functionality to set the intended window name to that window. Next step after that would be activating the debugger for the top view so that either can be used for debugging, but that definitely requires a new PR. We'd either need to make the game debugger code instantiable (so there can be 2 copies of it) or send the window name along with each signal so that the debugger can act depending on which view the user interacted with; either option should work from what I can tell. 
 I could see that being useful, though users have to make sure they don't confuse the Scene View with the debug view - I'm thinking eventually (hopefully) we will have a lot of the same tools for runtime editing like the transform gizmos, so it will be important to distinguish them for beginners who may expect the Scene View to also work in runtime like in Unity. Side note: if it was up to me, I'd prefer an approach different than window embedding in the first place to get the editor tools at runtime, but considering this is what we've got, I'll work with it lol. Anyways, I think the long term solution to this would be something like godotengine/godot-proposals#7233 where any viewport can be moved to any position, including the game tab views and 3D plugin so that users can make any layout they want. This is a lot of work but honestly it would probably be better to look into this than to try and figure out all the combinations of side-by-side windows that users might want. That's just my personal take though and if it's too far away, we can work with these alternatives for now  | 
    
          
 Sure, that would be awesome! 
 
 Alright, sweet. Sounds like we share the same hope that we get those debugging gizmos, etc. This PR definitely takes us one step closer. Being able to have the more modular editor would be sick, but I bet you this horizontal/vertical two window setup is what almost all users will end up using anyways (of course that could be completely false lol).  | 
    
bb42f95    to
    55992a5      
    Compare
  
    | 
           I've now added in the horizontal split feature from @jaydensipe and it works great! Thanks again for contributing 😄 Capture2025-05-02.14-59-07.movOne tiny caveat is the limited space on the top bar which locks the minimum size of the right view while in the horizontal mode, and I can only imagine that this will get worse as we add more debugging buttons. This seems to be a general problem with the Godot editor viewports (I've noticed it in other editor windows too) and I'm not exactly sure what the solution is, but that's a future concern we can reevaluate later.  | 
    
          
 Good point. I wanna say later we could maybe chop off the "multi selection" tool, since it's already a shortcut on the "selection" tool, but not sure.  | 
    
55992a5    to
    d9e3296      
    Compare
  
    | 
           @AThousandShips thanks for the review! I've updated the branch with all of your requested changes and rebased it, so feel free to let me know if this is good and if there's anything else I should adjust  | 
    
525e62d    to
    a3d47e6      
    Compare
  
    | 
           It took some trial and error with the CI but I've rebased the branch to account for the MacOS embedding that was added in #105884 . Like the other platforms, since the mac display server does not set the   | 
    
| 
           I'll have to do some additional work for multiple windows on macOS, but it is very doable. In fact, it would be easy enough to have a picker so you could switch windows  | 
    
a3d47e6    to
    f417d8b      
    Compare
  
    f417d8b    to
    358948a      
    Compare
  
    | 
           Rebased again!  | 
    
3a4b249    to
    1923d1f      
    Compare
  
    | 
           Does this PR also enable embedding two run instances of a game within the Godot Editor? Here's my usecase:I'm building a mobile game with multiplayer (using the fantastic EOSG plugin) and frequently have to debug/test with two run instances. It would be amazing if the game view provided options for displaying multiple run instances/sessions, with the horizontal/vertical splits from this PR. To be really feature complete, this would probably need to be able to handle more than two sessions as well... I wouldn't mind iterating on the PR, if that's welcome.  | 
    
| 
           @Robert-K If both instances are run from the editor, it may in fact be possible if you use the Custom Window setting and provide a unique window name for each instance. All that's really happening is Godot attaching a special flag to the build telling it that if a window spawns with the given name, it should become parented, and then the  If it doesn't work automatically then it should probably be addressed in a follow up PR as its not covered in the original proposal. This one is already a lot of changes and it's been hard to keep it up to date haha. On that note, I'll get around to rebasing it soon and hope to get more code reviews now that we're in 4.6 territory :)  | 
    
This commit allows the `GameView` to select either the "Main Window" (default view of the running game) or a subwindow to become embedded when running the project. This information is communicated to the built game via a new `--swid` (subwindow ID) command line parameter which matches the `--wid` implementation created for the original embedding feature. The subwindow is chosen by matching the name of the window to a user provided name which is given in a text box in the `GameView`. This is implemented only for Windows and a follow up PR should be able to match the functionality for Linux easily. Additionally, to utilize this new behavior, there is now the option to enable a second `GameView` that sits above the main one. The second view can embed a different window and has its own embedding controls to improve user debugging. For now, in order to keep the PR smaller, the secondary `GameView` does not utilize its own SceneDebugger, so only the main view can use the runtime selection options. A future PR can open up more functionality for parity with the main view. @jaydensipe also contributed an alternate layout option for the split game view in this commit. Co-Authored-By: Jayden Sipe <[email protected]>
1923d1f    to
    a853031      
    Compare
  
    | 
           @AThousandShips Thanks! I've implemented all of your suggestions and rebased the branch. Let me know if there's anything else I should look into  | 
    



Closes godotengine/godot-proposals#11091
Thanks to guidance from @Hilderin this PR adds two new features to the Game tab and embedding tools that were introduced in Godot 4.4. The first change extends the embedding functionality to allow embedding of "subwindows" (as they're known in
DisplayServer) when provided with a unique window name. The user can now select whether to embed the main window or a custom window that matches the name provided via a text box in the GameView:Capture2025-03-12.13-46-20.mov
This allows developers of multi-window games to embed the game window that makes the most sense for their project rather than being stuck with the main window. This is accomplished through modifications to the display server so that a subwindow can be parented much the same as the main window. In order to send the parenting data to the built game, a new
--swid(subwindow ID) command line parameter was created that matches the--widimplementation for the main window. Then, when theGameViewmodifies the instance parameters, it can optionally send the--swidwith the user provided window name.As suggested by @Hilderin , I took the next step in the proposal to better utilize subwindow embedding here by adding an option to split the Game tab into two GameViews for better visibility while debugging. This was largely done by splitting out functionality that used to be handled by the
GameViewinto theGameViewPluginand having the plugin manage two instances, but all together it works pretty cleanly! A button in the embed options popup lets you split the view and the layout is saved as project metadata, with the default setting being the regular single view that people are familiar with:Capture2025-03-12.13-58-35.mov
Since this PR was already looking like a lot to review, one step I left for a future PR was getting the secondary view's game debugger working properly. This proved challenging to do immediately because we would either need to make the RuntimeSelect stuff not a singleton or we'd need to pass window data through every message sent via the debugger, but I'm certain that one of these solutions will be easier to work out when this initial PR is wrapped up. Besides that, the regular debugger controls for the main GameView are still fully functional:
Capture2025-03-12.14-02-01.mov
Note: This PR only implements subwindow embedding for the Windows display server. Sadly I don't have a Linux machine to test on but Hilderin said it was fine to leave it like this so that a follow up PR can tackle the Linux/Android support which I believe shouldn't be too tough to match from Windows.
Thank you to everyone who offered ideas about the future of embedding in #99010 and I hope this new functionality proves to be helpful for developers looking for more debugging options! Let me know if there's anything I've missed and I'll be happy to make adjustments :)