moonlight-qt icon indicating copy to clipboard operation
moonlight-qt copied to clipboard

Allow disabling 'minimize on focus loss' for multi-monitor setups

Open w0utert opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe. When using Moonlight as a remote-desktop client on a system with multiple screens connected, if Moonlight is running in exclusive fullscreen mode, it will minimize automatically when focus is lost.

I would assume Windows should somehow allow having an exclusive fullscreen client on one screen that is not affected by stuff on any other screens?

Describe the solution you'd like The only thing I would like is an option (in the Moonlight settings,or a keyboad combo, or an environment variable, whatever) to inhibit the auto-minimizing behavior. It does not even have to be enabled/detected automatically based on the screen setup as long as I can toggle it manually.

Describe alternatives you've considered

  • I tried 'borderless windowed', which solves this, but it also ruins input (kb & mouse) latency, to the point it is almost unusable. In exclusive fullscreen mode, kb & mouse latency is perfect
  • I tried setting the SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS environment variable to 0, hoping it would do what it does for other SDL applications (at least I think moonlight-qt is using SDL since there is libSDL.dll in the distribution?), but it does not do anything.

Additional context My setup is as follows: I have a Windows 10 machine with 2 screens attached. On one screen have moonlight-qt running in exclusive fullscreen mode, to remote into another machine that runs Linux + Sunshine. On the other screen I have other Windows stuff running. I disable confining the mouse to the fullscreen Moonlight client area using ctrl-shift-alt-L which allows me to freely move the mouse between the two screens. So far so good.

The problem is that when I click a window on the W10 desktop on the other screen, the Moonlight client automatically minimizes itself. I understand why it would do this for single-screen setups (releasing the fullscreen so the newly focused application can be displayed), but for mult-monitor setups this is not necessary and extremely annoying, it basically makes working on both screens concurrently impossible. For example, I have MS Teams on the other screen, and every time I focus it to reply to someone, the Moonlight client on the other screen minimizes itself.

w0utert avatar Jul 31 '23 11:07 w0utert

I tried 'borderless windowed', which solves this, but it also ruins input (kb & mouse) latency, to the point it is almost unusable. In exclusive fullscreen mode, kb & mouse latency is perfect

This sounds like a bug. Borderless windowed should enter the DWM Independent Flip composition mode which produces equivalent latency to full-screen exclusive mode (assuming refresh rates are the same). IIRC DWM may not enter Independent Flip mode on the non-primary display. Does the latency in borderless windowed mode differ depending on which display Moonlight is running on?

Can you try setting the DXVA2_ENABLED environment variable to 0 and see if it resolves the focus loss issue and/or you see latency differences compared to leaving that value unset?

I would assume Windows should somehow allow having an exclusive fullscreen client on one screen that is not affected by stuff on any other screens?

We are setting SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 internally, so it's the Direct3D9Ex API that's actually triggering minimize on focus loss. I believe we may be able to emulate SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 by setting D3DCREATE_NOWINDOWCHANGES but that will need some testing to ensure it doesn't break Alt+Tab, focus changes, and other things that D3D9Ex was managing for us.

cgutman avatar Aug 06 '23 03:08 cgutman

@cgutman setting DXVA_ENABLED to 0 indeed fixes the problem, switching workspaces for example does not minimize the fullscreen Moonlight window anymore. Haven't checked with multiple screens yet but I'm fairly sure that problem will also be fixed now.

What are the implications of disabling DXVA? From the short test I did I cannot say I saw any performance degration?

w0utert avatar Aug 16 '23 11:08 w0utert

DXVA2 is an older DX9-based API for hardware accelerated video decoding and rendering. DXVA2 is currently preferred over the DX11-based D3D11VA API for full-screen exclusive mode (D3D11VA is default for windowed and borderless fullscreen).

DXVA2 and D3D11VA renderers differ significantly in how they handle fullscreen exclusive mode, so I wanted to be conservative and avoid changing the default due to the possibility of performance regressions. That's why I wanted to see if you saw any performance differences.

When DXVA2_ENABLED=0 is set, D3D11VA should be used instead (assuming your GPU driver and OS supports it). Can you upload your Moonlight.log (will be in %TEMP% for non-portable versions) after running with DXVA2_ENABLED=0? I want to be sure that D3D11VA is being used.

cgutman avatar Aug 20 '23 04:08 cgutman

A little late but here's an excerpt from the log file:

00:00:00 - SDL Info (0): Compiled with SDL 2.24.0
00:00:00 - SDL Info (0): Running with SDL 2.24.0
00:00:00 - Qt Info: No translation available for "en_US"
00:00:01 - Qt Warning: qrc:/gui/main.qml:12:1: QML ApplicationWindow: ToolTip must be attached to an Item
00:00:01 - Qt Info: Found "gamecontrollerdb.txt" at "C:/Users/jbijlsma/Moonlight-4.3.1/cache/gamecontrollerdb.txt"
00:00:01 - SDL Info (0): Loaded 494 new gamepad mappings
00:00:01 - SDL Info (0): V-sync disabled
00:00:01 - SDL Info (0): DXVA2 is disabled by environment variable
00:00:01 - SDL Info (0): Detected GPU 0: Intel(R) UHD Graphics (8086:4626)
00:00:01 - Qt Info: Found "d3d11_vertex.fxc" at ":/data/d3d11_vertex.fxc"
00:00:01 - Qt Info: Found "d3d11_overlay_pixel.fxc" at ":/data/d3d11_overlay_pixel.fxc"
00:00:01 - Qt Info: Found "d3d11_genyuv_pixel.fxc" at ":/data/d3d11_genyuv_pixel.fxc"
00:00:01 - Qt Info: Found "d3d11_bt601lim_pixel.fxc" at ":/data/d3d11_bt601lim_pixel.fxc"
00:00:01 - Qt Info: Found "d3d11_bt2020lim_pixel.fxc" at ":/data/d3d11_bt2020lim_pixel.fxc"
00:00:01 - SDL Info (0): Using D3D11VA accelerated renderer
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Decoding VPS
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Main 10 profile bitstream
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Decoding SPS
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Main 10 profile bitstream
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Decoding VUI
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Decoding PPS
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Format d3d11 chosen by get_format().
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Format d3d11 requires hwaccel initialisation.
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Decoder GUIDs reported as supported:
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {ee27417f-5e28-4e65-beea-1d26b508adc9} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {bf22ad00-03ea-4690-8077-473346209b7e} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1b81bea4-a0c7-11d3-b984-00c04f2e73c5} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {e07ec519-e651-4cd6-ac84-1370cceec851} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {bcc5db6d-a2b6-4af0-ace4-adb1f787bc89} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1b81be94-a0c7-11d3-b984-00c04f2e73c5} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1b81bea2-a0c7-11d3-b984-00c04f2e73c5} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1b81be68-a0c7-11d3-b984-00c04f2e73c5} 100 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {d79be8da-0cf1-4c81-b82a-69a4e236f43d} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {f9aaccbb-c2b6-4cfc-8779-5707b1760552} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {705b9d82-76cf-49d6-b7e6-ac8872db013c} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {c528916c-c0af-4645-8cb2-372b6d4adc2a} 100 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {91cd2d6e-897b-4fa1-b0d7-51dc88010e0a} 100 103 106 107
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {97688186-56a8-4094-b543-fc9daaa49f4b} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1424d4dc-7cf5-4bb1-9cd7-b63717a72a6b} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {c346e8a3-cbed-4d27-87cc-a70eb4dc8c27} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {ffc79924-5eaf-4666-a736-06190f281443} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {464bdb3c-91c4-4e9b-896f-225496ac4ed6} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {9b31316b-f204-455d-8a8c-9345dca77c01} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {afe4285c-ab63-4b2d-8278-e6baacea2ce9} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {277de9c5-ed83-48dd-ab8f-ac2d24b22943} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {04c5ba10-4e9a-4b8e-8dbf-4f4b48afa27c} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {0acef8bc-285f-415d-ab22-7bf2527a3d2e} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {24d19fca-c5a2-4b8e-9f93-f8f6ef15c890} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {353aca91-d945-4c13-ae7e-469060fac8d8} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {28566328-f041-4466-8b14-8f5831e78f8b} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {6b4a94db-54fe-4ae1-9be4-7a7dad004600} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {b8b28e0c-ecab-4217-8c82-eaaa9755aaf0} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {8732ecfd-9747-4897-b42a-e534f9ff2b7a} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {e139b5ca-47b2-40e1-af1c-ad71a67a1836} 103 106 108
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {056a6e36-f3a8-4d00-9663-7e9430358bf9} 103 106 107
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {5415a68c-231e-46f4-878b-5e9a22e967e9} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {161be912-44c2-49c0-b61e-d946852b32a1} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {d6d6bc4f-d51a-4712-97e8-750917c860fd} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {7fef652d-3233-44df-acf7-ecfb584dab35} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {87b2ae39-c9a5-4c53-86b8-a52d7edba488} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {10e19ac8-bf39-4443-bec3-1b0cbfe4c7aa} 101 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {2dec00c7-21ee-4bf8-8f0e-773f11f126a2} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {c35153a0-23c0-4a81-b3bb-6a1326f2b76b} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {a33fd0ec-a9d3-4c21-9276-c241cc90f6c7} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {310e59d2-7ea4-47bb-b319-500e78855336} 101 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {036dff40-94a6-45b3-a0b3-71f0cdf35129} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {8c56eb1e-2b47-466f-8d33-7dbcd63f3df2} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {5b11d51b-2f4c-4452-bcc3-09f2a1160cc0} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {75fc75f7-c589-4a07-a25b-72e03b0383b3} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {107af0e0-ef1a-4d19-aba8-67a163073d13} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {e484dcb8-cac9-4859-99f5-5c0d45069089} 103 104 106 107 108
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {41a5af96-e415-4b0c-9d03-907858e23e78} 100 103 106 107
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {6a6a81ba-912a-485d-b57f-ccd2d37b8d94} 100 101 103 104 106 107 108
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {e4e3cf5b-97d2-4658-aacb-366e3ee2ceee} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {fd9d9559-0fd3-4917-a9a7-07e714ee9ef9} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {0e4bc693-5d2c-4936-b125-aefe32b16d8a} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {2f08b5b1-dbc2-4d48-883a-4e7b8174cff6} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {5467807a-295d-445d-bd2e-cba8c2457c3d} 100 103 106 107
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {ae0d4e15-2360-40a8-bf82-028e6a0dd827} 100 101 103 104 106 107 108
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {8ff8a3aa-c456-4132-b6ef-69d9dd72571d} 103 105 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {c23dd857-874b-423c-b6e0-82ceaa9b118a} 103 104 105 106 107 108 109
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {5b08e35d-0c66-4c51-a6f1-89d00cb2c197} 100 101 102 103 104 105 106 107 108 109
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {07cfaffb-5a2e-4b99-b62a-e4ca53b6d5aa} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {463707f8-a1d0-4585-876d-83aa6d60b89e} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {a4c749ef-6ecf-48aa-8448-50a7a1165ff7} 103 104 105 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {76988a52-df13-419a-8e64-ffcf4a336cf5} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {68a21c7b-d58f-4e74-9993-e4b8172b19a0} 100 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {80a3a7bd-89d8-4497-a2b8-2126af7e6eb8} 103 104 105 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {1d5c4d76-b55a-4430-904c-3383a7ae3b16} 101 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {a7f759dd-5f54-4d7f-8291-42e883c546fe} 103 104 105 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {f34fa92f-dc79-474c-b0db-b7bd4522df77} 101 102 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {b8be4ccb-cf53-46ba-8d59-d6b8a6da5d2a} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {ca44afc5-e1d0-42e6-9154-b127186d4d40} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {f9a16190-3fb4-4dc5-9846-c8751f83d6d7} 103 104 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {50925b7b-e931-4978-a12a-586630f095f9} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {b69c20e0-2508-8790-0305-875499e0a2d0} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] {49761bec-4b63-4349-a5ff-87ffdf088466} 103 106
00:00:01 - FFmpeg: [hevc @ 000001F397ECB440] Output frame with POC 3.
00:00:01 - SDL Info (0): FFmpeg-based video decoder chosen

I see the line 00:00:01 - SDL Info (0): Using D3D11VA accelerated renderer in there, so I guess that should be good?

w0utert avatar Sep 05 '23 10:09 w0utert

Thanks for this. Setting the DXVA2_ENABLED system environment variable and restarting the Windows Moonlight client solved the issue.

mfbenson avatar Jan 25 '24 16:01 mfbenson