Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/windows/include/display_device/windows/settings_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,20 @@ namespace display_device {
* @param modified_state Modified state data to revert.
* @param guard_fn Reference to the guard function which will be set to restore the current state if needed.
* @param system_settings_touched Indicates whether a "write" operation could have been performed on the OS.
* @param query_failed [Optional] Flag set to true when querying current HDR states returned an empty map.
* @returns Result enum indicating success or failure.
*/
[[nodiscard]] RevertResult revertModifiedHdrStates(const SingleDisplayConfigState::Modified &modified_state, DdGuardFn &guard_fn, bool &system_settings_touched);
[[nodiscard]] RevertResult revertModifiedHdrStates(const SingleDisplayConfigState::Modified &modified_state, DdGuardFn &guard_fn, bool &system_settings_touched, bool *query_failed = nullptr);

/**
* @brief Revert display mode changes tracked in the modified settings state.
* @param modified_state Modified state data to revert.
* @param guard_fn Reference to the guard function which will be set to restore the current state if needed.
* @param system_settings_touched Indicates whether a "write" operation could have been performed on the OS.
* @param query_failed [Optional] Flag set to true when querying current display modes returned an empty map.
* @returns Result enum indicating success or failure.
*/
[[nodiscard]] RevertResult revertModifiedDisplayModes(const SingleDisplayConfigState::Modified &modified_state, DdGuardFn &guard_fn, bool &system_settings_touched);
[[nodiscard]] RevertResult revertModifiedDisplayModes(const SingleDisplayConfigState::Modified &modified_state, DdGuardFn &guard_fn, bool &system_settings_touched, bool *query_failed = nullptr);

/**
* @brief Revert primary device changes tracked in the modified settings state.
Expand Down
2 changes: 2 additions & 0 deletions src/windows/include/display_device/windows/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ namespace display_device {
HdrStateMap m_original_hdr_states {}; ///< Original HDR states before modification.
std::string m_original_primary_device {}; ///< Original primary device before modification.
std::string m_interim_primary_device {}; ///< Primary device to restore while the original one is unavailable.
StringSet m_pending_topology_devices {}; ///< Original devices whose saved Windows database topology still needs to be restored once they return.
StringSet m_activated_devices {}; ///< Stream-only devices excluded when pending topology recovery runs later.

/**
* @brief Check if the changed topology has any other modifications.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ namespace display_device {
*/
[[nodiscard]] bool isApiAccessAvailable() const override;

/**
* @copydoc WinDisplayDeviceInterface::savesToDatabase
*/
[[nodiscard]] bool savesToDatabase() const override;

/**
* @copydoc WinDisplayDeviceInterface::enumAvailableDevices
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ namespace display_device {
*/
[[nodiscard]] virtual bool isApiAccessAvailable() const = 0;

/**
* @brief Check whether topology and mode changes are saved to Windows' display database.
* @returns True if writes update Windows' display database, false if writes are session-only.
*/
[[nodiscard]] virtual bool savesToDatabase() const {
return false;
}

/**
* @brief Enumerate the available (active and inactive) devices.
* @returns A list of available devices.
Expand Down
12 changes: 10 additions & 2 deletions src/windows/json_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace display_device {
DD_JSON_DEFINE_SERIALIZE_STRUCT(SingleDisplayConfigState::Initial, topology, primary_devices)

/**
* @brief Serialize the modified state, including the interim primary device when there is one.
* @brief Serialize the modified state, including optional recovery metadata when present.
* @param nlohmann_json_j JSON output object.
* @param nlohmann_json_t Modified state to serialize.
*/
Expand All @@ -27,10 +27,16 @@ namespace display_device {
if (!nlohmann_json_t.m_interim_primary_device.empty()) {
DD_JSON_TO(interim_primary_device)
}
if (!nlohmann_json_t.m_pending_topology_devices.empty()) {
DD_JSON_TO(pending_topology_devices)
}
if (!nlohmann_json_t.m_activated_devices.empty()) {
DD_JSON_TO(activated_devices)
}
}

/**
* @brief Deserialize the modified state, treating a missing interim primary device as none.
* @brief Deserialize the modified state, treating missing optional recovery fields as empty.
* @param nlohmann_json_j JSON input object.
* @param nlohmann_json_t Modified state to populate.
*/
Expand All @@ -40,6 +46,8 @@ namespace display_device {
DD_JSON_FROM(original_hdr_states)
DD_JSON_FROM(original_primary_device)
nlohmann_json_t.m_interim_primary_device = nlohmann_json_j.value("interim_primary_device", std::string {});
nlohmann_json_t.m_pending_topology_devices = nlohmann_json_j.value("pending_topology_devices", StringSet {});
nlohmann_json_t.m_activated_devices = nlohmann_json_j.value("activated_devices", StringSet {});
}

DD_JSON_DEFINE_SERIALIZE_STRUCT(SingleDisplayConfigState, initial, modified)
Expand Down
4 changes: 4 additions & 0 deletions src/windows/settings_manager_apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ namespace display_device {
release_context = m_dd_api->isTopologyTheSame(new_state.m_initial.m_topology, new_topology) && audio_is_captured;
}

if (cached_state) {
new_state.m_modified.m_pending_topology_devices = cached_state->m_modified.m_pending_topology_devices;
new_state.m_modified.m_activated_devices = cached_state->m_modified.m_activated_devices;
}
new_state.m_modified.m_topology = new_topology;
return std::make_tuple(new_state, device_to_configure, additional_devices_to_configure);
}
Expand Down
Loading