]> git.lyx.org Git - lyx.git/commitdiff
Adhere to semantic background color with default branches
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 5 Oct 2024 12:15:19 +0000 (14:15 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 5 Oct 2024 12:15:19 +0000 (14:15 +0200)
This fixes color mismatched when "use system colors" is checked

See https://marc.info/?l=lyx-users&m=172797086718347

src/BranchList.cpp
src/insets/InsetBranch.cpp

index 37e746293d2c7c5fb720a82524059660176bc1a8..d9409c80f1049a5ccd23e43896101121a9832cfb 100644 (file)
@@ -114,12 +114,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
index 16ac8f9237914afa7bee7a511ff1f4ff5dd6653f..1eb1f265d53f4ed0312a8b87160fa899c640f99a 100644 (file)
@@ -154,6 +154,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;