godot icon indicating copy to clipboard operation
godot copied to clipboard

Toggle fullscreen mode when pressing Alt + Enter by default

Open Calinou opened this issue 5 years ago • 16 comments

Alt + Enter is a widely followed convention to toggle fullscreen. This adds support for it both in the editor and projects, as long as the window is configured to be resizable.

The rationale for providing this feature in all projects is that many developers don't bother about adding a fullscreen toggle, especially for smaller/gamejam games. Yet, this convention is followed by many popular games out there, including AAA games.

The shortcut can be modified or disabled by editing the Input Map in the Project Settings.

This closes https://github.com/godotengine/godot-proposals/issues/1983. See discussion in https://github.com/godotengine/godot-proposals/issues/1087.

Calinou avatar Jun 20 '20 13:06 Calinou

In my experience, F11 is a more common keyboard shortcut for this (ex: web browsers, Minecraft). If this feature is added, F11 should also be a keybind to do this.

aaronfranke avatar Jun 21 '20 03:06 aaronfranke

@aaronfranke It makes sense to bind F11 as well, but it's more likely to conflict with a key already used in the project. That said, since it can easily be removed, it should be safe to do.

Calinou avatar Jun 21 '20 11:06 Calinou

@aaronfranke F11 is more common in applications (browsers, text editors etc.). Most games use Alt + Enter.

KoBeWi avatar Jun 24 '20 23:06 KoBeWi

Needs rebase.

akien-mga avatar Nov 16 '20 12:11 akien-mga

@aaronfranke The issue with adding F11 as a shortcut is that it conflicts with the editor's distraction-free toggle, which defaults to Ctrl + Shift + F11. It no longer works if I add F11 as a key for ui_toggle_fullscreen.

Anyway, I fixed the issue with the ui_ prefix not being present for the default automatically-created input map.

Calinou avatar Nov 21 '20 00:11 Calinou

For F11: Understandable, if there's a reason to not have it then that's fine.

Tested this again. When exiting fullscreen on Linux, the window's title bar is gone.

This might be unrelated to this PR though, since this is just binding a key.

aaronfranke avatar Nov 21 '20 01:11 aaronfranke

Tested this again. When exiting fullscreen on Linux, the window's title bar is gone.

I can reproduce this on Linux too. It's most likely a regression from DisplayServer.

Calinou avatar Nov 21 '20 13:11 Calinou

Absolutely do not use F11 for full screen toggle of games.

Definitely do use ALT+Enter for full screen toggle of games.

Or use both for the sake of people who learned gaming with minecraft or Roblox (Shift+F11) but ALT+Enter should be the priority for the sake of any other gamer.

If I'm not mistaken, there is conversation about having the same key combo for Godot editor and games made in Godot? If that is correct: Both F11 and ALT+Enter do nothing in Unity editor, neither should be expected to do anything. Full-screening a game and a game editor are entirely different things - like full-screening a video to watch, vs full-screening a video editor application.

If there is some need to fullscreen toggle godot editor, I'd suggest to use F11 (based on most applications that have fullscreen mode).

iwanPlays avatar Dec 14 '20 13:12 iwanPlays

@iwanPlays The Godot editor already provides Shift + F11 to toggle fullscreen. We could perhaps change this to just F11 in a future pull request.

Calinou avatar Dec 14 '20 13:12 Calinou

Absolutely do not use F11 for full screen toggle of games.

@iwanPlays I think both should be enabled by default. Personally, I learned about the Alt + Enter combination much later than about the F11 key.

dalexeev avatar Dec 14 '20 13:12 dalexeev

@Calinou Now that we have exact matching for input events (#44355), can we add F11 as a shortcut?

aaronfranke avatar Aug 16 '21 19:08 aaronfranke

I think the feature and the implementation look good, but the PR needs a rebase.

groud avatar Sep 01 '21 07:09 groud

Not necessarily against this, but you should check that the window is resizable/borderless before making this happen. Also I do not think the implementation is good. The aciton is OK, but you should check/do/this at Window level and make this a Window property (disabled by default, and the one in root set by SceneTree by checking a project setting, which I guess its ok if its on by default).

reduz avatar Jul 28 '22 14:07 reduz

Rebased against master and reimplemented, but not functional yet.

The aciton is OK, but you should check/do/this at Window level and make this a Window property (disabled by default, and the one in root set by SceneTree by checking a project setting, which I guess its ok if its on by default).

I've looked into adding a flag to Window (also tried adding a property), but I don't know how I can avoid having to add code to the set_flag() override in each DisplayServer implementation. The shortcut does not need OS-specific handling after all.

Calinou avatar May 12 '23 01:05 Calinou

I'm guessing this is a no-op on Android?

m4gr3d avatar May 12 '23 01:05 m4gr3d

I'm guessing this is a no-op on Android?

It could work if you have a hardware keyboard connected and floating windows are used, but otherwise I generally expect it to be a no-op on mobile platforms.

Calinou avatar May 12 '23 02:05 Calinou

Seems great! Would like to see this in Godot 4.5. I will test this when I get the time to.

It doesn't work yet (and I don't know how to make it work given the above requirements). Also, it's too late for this to be merged in 4.5 since it's entering feature freeze very soon.

Calinou avatar Jun 12 '25 17:06 Calinou

I don't know how I can avoid having to add code to the set_flag() override in each DisplayServer implementation

Why would you need to do that? A property does not involve adding any flag.

KoBeWi avatar Jun 12 '25 17:06 KoBeWi

Why would you need to do that? A property does not involve adding any flag.

Indeed, I realized I only need to modify Window, not DisplayServer.

The PR is now ready for review – I've tested it on my end and it works as expected.

One quirk is that if you maximize the window by pressing the Maximize button in the window border, its window mode won't change to Maximized in Godot. This means that if you press the fullscreen toggle twice (to exit fullscreen mode), the window will be in standard mode again, instead of being maximized. This also happens the other way around. For example, if you move around a window while it's maximized, it will no longer be maximized but Godot won't be aware of that.

This is probably a more general DisplayServer issue (which may be reported elsewhere already).

Calinou avatar Jun 13 '25 00:06 Calinou