desktop: Add fullscreen keyboard shortcut#1510
Conversation
|
Let's make it the same key to toggle in/out of fullscreen for now, because particularly Escape could be a commonly used key in games. Also probably better to use a combination like Alt+Enter or Ctrl+F (both commonly used, for example, Windows Media Player uses Alt+Enter). |
|
Split the web fullscreen to #1515, so this PR is only for the desktop fullscreen. |
|
Unfortunately on my windows 10 machine, exiting fullscreen mode seems to keep the fullscreen window size, with the border off the screen so that I can't move/resize it. So I guess we have to resize and reposition the window when exiting fullscreen. Something like: Not sure if there is a simpler way to center a window via winit. |
|
After investigating a bit, this seems to happen only when entering fullscreen with maximized window. This doesn't happen when entering fullscreen without maximizing the window. |
|
On my home PC, the problem occurs regardless of whether I was in the maximized state when entering fullscreen (i.e., if I start the app and then press Alt+Enter twice, the window size still takes up the fullscreen and is difficult to resize). Possibly related to # of monitors or desktop size. Would be good to file an issue on the winit repo. In the meantime we would have to work around it on our side. Remembering the previous position when entering fullscreen would be better, I agree. You could store the window dimensions when toggling into fullscreen. |
|
Opened rust-windowing/winit#1765. Since this feature is just QOL and is low priority, I prefer to wait and merge this PR once winit is updated. |
|
I investigated a little more because the winit fullscreen example does not have the same issue for me, where the window is not properly sized even if I Alt+Enter with a normal sized window. The issue is that I am using the dx12 wgpu backend, and DXGI (used by dx11 and 12) seems to automatically install its own built-in Alt+Enter fullscreen handler, and this interacts badly with our own Alt+Enter handler. We'd want to disable this (https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-makewindowassociation). I think this should be filed as an issue on gfx-rs. Alternatively we could just use a different key combo for now. |
|
Interesting, I see two options:
Since it would be very confusing to have two different fullscreen shortcuts, and since the fullscreen functionality is not urgent at all, I think choosing a different key combo is not the ideal solution for both short and long terms. |
|
I tossed a PR to gfx-rs (gfx-rs/gfx#3479), so we should get the Alt+Enter fix whenever wgpu bumps its gfx-rs version. |
|
@relrelb, I wonder whether a keyboard shortcut for fullscreen could be also added to web. I saw that this could be extremely useful to read the error message in rather small windows (such as the one reported in #1755). I know that there is a context menu for that, but it seems to be tricky to use with a touchpad. |
|
Even for standard presentations, having a keyboard shortcut to play them in fullscreen would be extremely helpful. |
I have updated |
|
This PR in winit should fix the issue when it's merged. |
|
This PR depends on #1927. |
|
Since rust-windowing/winit#1784 is merged, all we need is to wait for a new winit release. |
25bd6ee to
bc7af89
Compare
|
@Herschel Actually, we can merge this PR without waiting for the next winit release. I don't think winit really blocks us, and the bug will eventually be fixed, sooner or later. |
And also remove the Escape shortcut because it might interfere with games.
|
Thanks! |
This PR adds Alt+Enter as a keyboard shortcut to toggle fullscreen.
Should more or less fix #186.
The major downside here is that the player will never receive events for Alt+Enter. I see 3 alternatives: