Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a42861

Browse files
VMFortressc2vi
authored andcommitted
feat(display): Add revert display config on disconnect option (LizardByte#3613)
1 parent 17606d8 commit 3a42861

File tree

7 files changed

+46
-0
lines changed

7 files changed

+46
-0
lines changed

docs/configuration.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,31 @@ editing the `conf` file in a text editor. Use the examples as reference.
12031203
</tr>
12041204
</table>
12051205

1206+
1207+
### dd_config_revert_on_disconnect
1208+
1209+
<table>
1210+
<tr>
1211+
<td>Description</td>
1212+
<td colspan="2">
1213+
When enabled, display configuration is reverted upon disconnect of all clients instead of app close or last session termination.
1214+
This can be useful for returning to physical usage of the host machine without closing the active app.
1215+
@warning{Some applications may not function properly when display configuration is changed while active.}
1216+
@note{Applies to Windows only.}
1217+
</td>
1218+
</tr>
1219+
<tr>
1220+
<td>Default</td>
1221+
<td colspan="2">@code{}disabled@endcode</td>
1222+
</tr>
1223+
<tr>
1224+
<td>Example</td>
1225+
<td colspan="2">@code{}
1226+
dd_config_revert_on_disconnect = enabled
1227+
@endcode</td>
1228+
</tr>
1229+
</table>
1230+
12061231
### dd_mode_remapping
12071232

12081233
<table>

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ namespace config {
504504
{}, // manual_refresh_rate
505505
video_t::dd_t::hdr_option_e::automatic, // hdr_option
506506
3s, // config_revert_delay
507+
{}, // config_revert_on_disconnect
507508
{}, // mode_remapping
508509
{} // wa
509510
}, // display_device
@@ -1132,6 +1133,7 @@ namespace config {
11321133
video.dd.config_revert_delay = std::chrono::milliseconds {value};
11331134
}
11341135
}
1136+
bool_f(vars, "dd_config_revert_on_disconnect", video.dd.config_revert_on_disconnect);
11351137
generic_f(vars, "dd_mode_remapping", video.dd.mode_remapping, dd::mode_remapping_from_view);
11361138
bool_f(vars, "dd_wa_hdr_toggle", video.dd.wa.hdr_toggle);
11371139

src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ namespace config {
132132
std::string manual_refresh_rate; ///< Manual refresh rate in case `refresh_rate_option == refresh_rate_option_e::manual`.
133133
hdr_option_e hdr_option;
134134
std::chrono::milliseconds config_revert_delay; ///< Time to wait until settings are reverted (after stream ends/app exists).
135+
bool config_revert_on_disconnect; ///< Specify whether to revert display configuration on client disconnect.
135136
mode_remapping_t mode_remapping;
136137
workarounds_t wa;
137138
} dd;

src/stream.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,11 +1882,17 @@ namespace stream {
18821882

18831883
// If this is the last session, invoke the platform callbacks
18841884
if (--running_sessions == 0) {
1885+
bool revert_display_config {config::video.dd.config_revert_on_disconnect};
18851886
if (proc::proc.running()) {
18861887
#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
18871888
system_tray::update_tray_pausing(proc::proc.get_last_run_app_name());
18881889
#endif
18891890
} else {
1891+
// We have no app running and also no clients anymore.
1892+
revert_display_config = true;
1893+
}
1894+
1895+
if (revert_display_config) {
18901896
display_device::revert_configuration();
18911897
}
18921898

src_assets/common/assets/web/config.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ <h1 class="my-4">{{ $t('config.configuration') }}</h1>
175175
"dd_manual_refresh_rate": "",
176176
"dd_hdr_option": "auto",
177177
"dd_config_revert_delay": 3000,
178+
"dd_config_revert_on_disconnect": "disabled",
178179
"dd_mode_remapping": {"mixed": [], "resolution_only": [], "refresh_rate_only": []},
179180
"dd_wa_hdr_toggle": "disabled",
180181
"min_fps_factor": 1,

src_assets/common/assets/web/configs/tabs/audiovideo/DisplayDeviceOptions.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ function addRemappingEntry() {
151151
</div>
152152
</div>
153153

154+
<!-- Config revert on disconnect -->
155+
<div class="mb-3" v-if="config.dd_configuration_option !== 'disabled'">
156+
<Checkbox id="dd_config_revert_on_disconnect"
157+
locale-prefix="config"
158+
v-model="config.dd_config_revert_on_disconnect"
159+
default="false"
160+
></Checkbox>
161+
</div>
162+
154163
<!-- Display mode remapping -->
155164
<div class="mb-3" v-if="canBeRemapped()">
156165
<label for="dd_mode_remapping" class="form-label">

src_assets/common/assets/web/public/assets/locale/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
"dd_config_label": "Device configuration",
159159
"dd_config_revert_delay": "Config revert delay",
160160
"dd_config_revert_delay_desc": "Additional delay in milliseconds to wait before reverting configuration when the app has been closed or the last session terminated. Main purpose is to provide a smoother transition when quickly switching between apps.",
161+
"dd_config_revert_on_disconnect": "Config revert on disconnect",
162+
"dd_config_revert_on_disconnect_desc": "Revert configuration upon disconnect of all clients instead of app close or last session termination.",
161163
"dd_config_verify_only": "Verify that the display is enabled (default)",
162164
"dd_hdr_option": "HDR",
163165
"dd_hdr_option_auto": "Switch on/off the HDR mode as requested by the client (default)",

0 commit comments

Comments
 (0)