代码拉取完成,页面将自动刷新
From d8e6d419f0b4f4965b32e7c62281f257e0595c4b Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Mon, 13 May 2024 12:58:46 +0800
Subject: [PATCH] feature(display): perform adaptive settings when connection
status or monitor uid is changed.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 如果显示器uid和显示接口连接状态有一个发生变化,则重新进行自适应设置。
Relates #37289
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
plugins/display/display-manager.cpp | 44 +++++++++++++++++++++--------
plugins/display/display-manager.h | 18 ++++++------
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/plugins/display/display-manager.cpp b/plugins/display/display-manager.cpp
index 8cf4099..858f944 100644
--- a/plugins/display/display-manager.cpp
+++ b/plugins/display/display-manager.cpp
@@ -1,14 +1,14 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
* kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ *
* Author: tangjie02 <tangjie02@kylinos.com.cn>
*/
@@ -749,8 +749,7 @@ ModeInfoVec DisplayManager::monitors_common_modes(const DisplayMonitorVec &monit
auto iter = std::remove_if(result.begin(), result.end(), [monitor](std::shared_ptr<ModeInfo> mode) -> bool
{
auto modes = monitor->get_modes_by_size(mode->width, mode->height);
- return (modes.size() == 0);
- });
+ return (modes.size() == 0); });
result.erase(iter, result.end());
}
@@ -863,6 +862,17 @@ std::string DisplayManager::get_monitors_uid()
return StrUtils::join(result, MONITOR_JOIN_CHAR);
}
+std::string DisplayManager::get_output_names()
+{
+ std::vector<std::string> result;
+ for (const auto &iter : this->monitors_)
+ {
+ result.push_back(iter.second->name_get());
+ }
+ std::sort(result.begin(), result.end(), std::less<std::string>());
+ return StrUtils::join(result, MONITOR_JOIN_CHAR);
+}
+
std::string DisplayManager::get_c_monitors_uid(const ScreenConfigInfo::MonitorSequence &monitors)
{
std::vector<std::string> result;
@@ -907,13 +917,23 @@ bool DisplayManager::save_to_file(CCErrorCode &error_code)
void DisplayManager::resources_changed()
{
auto old_monitors_uid = this->get_monitors_uid();
+ auto old_output_names = this->get_output_names();
this->load_monitors();
auto new_monitors_uid = this->get_monitors_uid();
+ auto new_output_names = this->get_output_names();
auto screen_changed_adaptation = this->display_settings_->get_boolean(SCREEN_CHANGED_ADAPT);
- // 如果uid不相同,说明设备硬件发生了变化,此时需要重新进行设置
- if (screen_changed_adaptation && old_monitors_uid != new_monitors_uid)
+ KLOG_INFO("check display resource changed, the old monitor uid and output names is %s/%s, "
+ "the new monitor uid and names is %s/%s",
+ old_monitors_uid.c_str(),
+ old_output_names.c_str(),
+ new_monitors_uid.c_str(),
+ new_output_names.c_str());
+
+ /* 如果uid不相同且连接的接口不一样,说明设备硬件发生了变化,此时需要重新进行设置。这里不能只判断uid是否变化,因为有可能出现 */
+ if (screen_changed_adaptation &&
+ (old_monitors_uid != new_monitors_uid || old_output_names != new_output_names))
{
CCErrorCode error_code = CCErrorCode::SUCCESS;
if (!this->switch_style_and_save(this->default_style_, error_code))
diff --git a/plugins/display/display-manager.h b/plugins/display/display-manager.h
index 6348568..e6f84da 100644
--- a/plugins/display/display-manager.h
+++ b/plugins/display/display-manager.h
@@ -1,14 +1,14 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
* kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ *
* Author: tangjie02 <tangjie02@kylinos.com.cn>
*/
@@ -113,6 +113,8 @@ private:
// 将uid进行排序后拼接
std::string get_monitors_uid();
+ // 将output name进行排序后拼接
+ std::string get_output_names();
std::string get_c_monitors_uid(const ScreenConfigInfo::MonitorSequence& monitors);
// 保存配置到文件
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。