[LyX/2.4.x] Adhere to semantic background color with default branches

Richard Kimberly Heck rikiheck at lyx.org
Sat Oct 5 16:53:52 UTC 2024


commit 478d59f5ddd1cda62883e4ef7ae06d5ad4ea9f72
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat Oct 5 14:15:19 2024 +0200

    Adhere to semantic background color with default branches
    
    This fixes color mismatched when "use system colors" is checked
    
    See https://marc.info/?l=lyx-users&m=172797086718347
    
    (cherry picked from commit 1f7e8d3ffeb399ec4c02285f024d51b3a695f4c7)
---
 src/BranchList.cpp         | 10 ++++++----
 src/insets/InsetBranch.cpp |  4 ++++
 status.24x                 |  2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/BranchList.cpp b/src/BranchList.cpp
index fc61065a4b..e37b255bf6 100644
--- a/src/BranchList.cpp
+++ b/src/BranchList.cpp
@@ -109,12 +109,14 @@ void Branch::setColors(string const & lmcol, string const & dmcol)
 	string lmcolor = lmcolor_;
 	string dmcolor = dmcolor_;
 	if (lmcolor == "none")
-		lmcolor = lcolor.getX11HexName(Color_background);
-	else if (lmcolor.size() != 7 || lmcolor[0] != '#')
+		lmcolor = "background";
+	// if we have background color, keep semantic value, as system colors might vary
+	else if (lmcolor != "background" && (lmcolor.size() != 7 || lmcolor[0] != '#'))
 		lmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(lmcolor));
 	if (dmcolor == "none")
-		dmcolor = lcolor.getX11HexName(Color_background, true);
-	else if (dmcolor.size() != 7 || dmcolor[0] != '#')
+		dmcolor = "background";
+	// if we have background color, keep semantic value, as system colors might vary
+	else if (dmcolor != "background" && (dmcolor.size() != 7 || dmcolor[0] != '#'))
 		dmcolor = lcolor.getX11HexName(lcolor.getFromLyXName(dmcolor), true);
 
 	// FIXME UNICODE
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 229e1bc37e..c979429984 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -156,6 +156,10 @@ ColorCode InsetBranch::backgroundColor(PainterInfo const & pi) const
 	// FIXME UNICODE
 	string const branchcol = "branch" + branch_id + to_utf8(params_.branch);
 	ColorCode c = lcolor.getFromLyXName(branchcol);
+	// if we have background color, set to semantic value, as system colors
+	// might vary
+	if (lcolor.getX11HexName(c, (theApp() && theApp()->isInDarkMode())) == "background")
+		c = Color_background;
 	if (c == Color_none)
 		c = Color_error;
 	return c;
diff --git a/status.24x b/status.24x
index f2bc03ad67..43ac7fac7c 100644
--- a/status.24x
+++ b/status.24x
@@ -66,6 +66,8 @@ What's new
 
 - Allow negative offset values in Horizontal Line dialog (bug 13102).
 
+- Adhere to semantic background color with default branches.
+
 
 * INTERNALS
 


More information about the lyx-cvs mailing list