Skip to content

Commit

Permalink
Fix all display being enabled when virtual display quits
Browse files Browse the repository at this point in the history
The inclusion of libdisplaydevice further complicated the already messy display configuration thing...
  • Loading branch information
ClassicOldSong committed Jan 20, 2025
1 parent 0b2ca07 commit a63b089
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,42 @@ namespace proc {
launch_session->display_guid
);

BOOST_LOG(info) << "Virtual Display created at " << vdisplayName;
if (!vdisplayName.empty()) {
BOOST_LOG(info) << "Virtual Display created at " << vdisplayName;

// Don't change display settings when no params are given
if (launch_session->width && launch_session->height && launch_session->fps) {
// Apply display settings
VDISPLAY::changeDisplaySettings(vdisplayName.c_str(), render_width, render_height, launch_session->fps);
}
// Set virtual_display to true when everything went fine
this->virtual_display = true;
this->display_name = platf::to_utf8(vdisplayName);
// Don't change display settings when no params are given
if (launch_session->width && launch_session->height && launch_session->fps) {
// Apply display settings
VDISPLAY::changeDisplaySettings(vdisplayName.c_str(), render_width, render_height, launch_session->fps);
}
// Set virtual_display to true when everything went fine
this->virtual_display = true;
this->display_name = platf::to_utf8(vdisplayName);

// When using virtual display, we don't care which display user configured to use.
// So we always set output_name to the newly created virtual display as a workaround for
// empty name when probing graphics cards.
// When using virtual display, we don't care which display user configured to use.
// So we always set output_name to the newly created virtual display as a workaround for
// empty name when probing graphics cards.

config::video.output_name = display_device::map_display_name(this->display_name);
config::video.output_name = display_device::map_display_name(this->display_name);
} else {
BOOST_LOG(warning) << "Virtual Display creation failed!";
}
}
}
#endif

display_device::configure_display(config::video, *launch_session);

// We should not preserve display state when using virtual display.
// It is already handled by Windows properly.
if (this->virtual_display) {
display_device::reset_persistence();
}

#else

display_device::configure_display(config::video, *launch_session);

#endif

// Probe encoders again before streaming to ensure our chosen
// encoder matches the active GPU (which could have changed
Expand Down Expand Up @@ -543,7 +557,7 @@ namespace proc {

// Load the configured output_name first
// to prevent the value being write to empty when the initial terminate happens
if (proc.initial_display.empty()) {
if (!has_run && proc.initial_display.empty()) {
proc.initial_display = config::video.output_name;
} else {
// Restore output name to its original value
Expand Down

0 comments on commit a63b089

Please sign in to comment.