From 77032b5c643437c286f13ecb4fcc4ff9c9419b9d Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Wed, 17 Aug 2022 20:26:02 +0800
Subject: [PATCH] fix(display):  Fix the problem that all monitors doesn't
 display because the saved enable field of all monitors is set off.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复由于保存的显示器状态全部为关闭导致显示器不显示的问题

Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
 plugins/display/display-manager.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/plugins/display/display-manager.cpp b/plugins/display/display-manager.cpp
index 5c7c5b3..bc18eb9 100644
--- a/plugins/display/display-manager.cpp
+++ b/plugins/display/display-manager.cpp
@@ -499,6 +499,13 @@ bool DisplayManager::save_config(CCErrorCode &error_code)
         this->display_config_ = std::unique_ptr<DisplayConfigInfo>(new DisplayConfigInfo());
     }
 
+    // 禁止保存没有开启任何显示器的配置，这可能会导致下次进入会话屏幕无法显示
+    if (this->get_enabled_monitors().size() == 0)
+    {
+        error_code = CCErrorCode::ERROR_DISPLAY_ONLY_ONE_ENABLED_MONITOR;
+        return false;
+    }
+
     auto monitors_uid = this->get_monitors_uid();
     auto &c_screens = this->display_config_->screen();
     bool matched = false;
-- 
2.33.0

