Re: [LyX/master] Change preedit color settings

Koji Yokota <[email protected]> Sun, 19 Jul 2026 11:35:36 +0900
Newsgroups gmane.editors.lyx.devel
Message-ID <[email protected]>
--Apple-Mail=_366EAA29-95EC-4E8F-9ED1-77C4801D72D9
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

> 2026/07/17 2:27=E3=80=81J=C3=BCrgen Spitzm=C3=BCller =
<[email protected]>=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB:
>=20
> Am Donnerstag, dem 16.07.2026 um 23:13 +0900 schrieb Koji Yokota:
>> But preview still picks up the workarea background even though =
png=E2=80=99s
>> background is transparent.
>=20
> Yes, as I wrote. This should probably be fixed in PreviewLoader or
> somewhere related.
>=20
> Note further, if this is done, the foreground color will need to be
> adapted as well to get proper contrast (as we do in the workarea).

Thanks, J=C3=BCrgen. The attached is the candidate of the fix. If there =
is no problems, I=E2=80=99m going to commit it to master.

Additional part from the previous patch is as below. Adjustment of =
foreground color is also working.

BTW, I noticed two things, which may or may not be related to the =
introduction of color themes, which I=E2=80=99m going to check:

	- Role of =E2=80=9Ctext (inverted background)=E2=80=9D is =
different between the default
	  and the other themes in the dark mode. Default picks its =
=E2=80=9CLight=E2=80=9D color,
	  whereas other themes picks up its =E2=80=9CDark=E2=80=9D =
color.
	- Text color in LyX comment stays black in the dark mode. But =
this
	  doesn=E2=80=99t seem to apply to user color themes.

Koji

------ (new change) ------
diff --git a/src/Color.cpp b/src/Color.cpp
index 5fd774afa8..1ca2c0ced3 100644
--- a/src/Color.cpp
+++ b/src/Color.cpp
@@ -299,6 +299,7 @@ ColorSet::ColorSet()
    { Color_none, N_("none"), "none", black, black, "none" },
    { Color_black, N_("black"), "black", black, black, "black" },
    { Color_white, N_("white"), "white", white, white, "white" },
+   { Color_transparent, N_("transparent"), "transparent", transparent, =
transparent, "transparent" },
    { Color_blue, N_("blue"), "blue", blue, blue, "blue" },
    { Color_brown, N_("brown"), "brown", brown, brown, "brown" },
    { Color_cyan, N_("cyan"), "cyan", cyan, cyan, "cyan" },
diff --git a/src/ColorCode.h b/src/ColorCode.h
index 3492498746..d101b43d62 100644
--- a/src/ColorCode.h
+++ b/src/ColorCode.h
@@ -21,6 +21,8 @@ enum ColorCode {
    ///
    Color_white,
    ///
+   Color_transparent,
+   ///
    Color_blue,
    ///
    Color_brown,
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 9ba086a715..96fa9a42c3 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -615,7 +615,7 @@ ColorCode InsetMathHull::backgroundColor(PainterInfo =
const & pi) const
        Dimension const dim =3D dimension(*pi.base.bv);
        if (previewTooSmall(dim))
            return Color_error;
-       return graphics::PreviewLoader::backgroundColor();
+       return Color_transparent;
    }
    return InsetMath::backgroundColor(pi);
 }


--Apple-Mail=_366EAA29-95EC-4E8F-9ED1-77C4801D72D9
Content-Disposition: attachment;
	filename=preview.candidate.patch
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="preview.candidate.patch"
Content-Transfer-Encoding: 7bit

diff --git a/lib/scripts/legacy_lyxpreview2ppm.py b/lib/scripts/legacy_lyxpreview2ppm.py
index 6be99d360e..9d232c7d01 100644
--- a/lib/scripts/legacy_lyxpreview2ppm.py
+++ b/lib/scripts/legacy_lyxpreview2ppm.py
@@ -234,10 +234,8 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
                 tmp.write(b"""
 \\usepackage{color}
 \\definecolor{lyxfg}{rgb}{%s}
-\\definecolor{lyxbg}{rgb}{%s}
-\\pagecolor{lyxbg}
 \\usepackage{polyglossia}
-""" % (fg_color_gr, bg_color_gr))
+""" % fg_color_gr)
                 polyglossia = True
                 continue
         success = 1
@@ -247,22 +245,20 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
             tmp.write(b"""
 \\usepackage{color}
 \\definecolor{lyxfg}{rgb}{%s}
-\\definecolor{lyxbg}{rgb}{%s}
-\\pagecolor{lyxbg}
 \\makeatletter
 \\def\\@tempa{cmr}
 \\ifx\\f@family\\@tempa
   \\IfFileExists{lmodern.sty}{\\usepackage{lmodern}}{\\usepackage{ae,aecompl}}
 \\fi
-""" % (fg_color_gr, bg_color_gr))
+""" % fg_color_gr)
         tmp.write(b"""
 \\usepackage[%s,tightpage]{preview}
 \\makeatletter
 \\ifdefined\\AddToHook
-  \\AddToHook{env/preview/before}{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}}
+  \\AddToHook{env/preview/before}{\\leavevmode\\begingroup\\special{ps::clippath fill}}
   \\AddToHook{env/preview/after}{\\endgroup}
 \\else
-  \\g@addto@macro\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}}
+  \\g@addto@macro\\preview{\\leavevmode\\begingroup\\special{ps::clippath fill}}
   \\g@addto@macro\\endpreview{\\endgroup}
 \\fi
 \\g@addto@macro\\preview{\\color{lyxfg}}
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index 56314356d1..1542af1663 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -393,7 +393,7 @@ def main(argv):
     bg_color = bytes(bg_color, 'ascii')
 
     fg_color_dvipng = make_texcolor(fg_color, False).decode('ascii')
-    bg_color_dvipng = make_texcolor(bg_color, False).decode('ascii')
+    bg_color_dvipng = "Transparent"
 
     # External programs used by the script.
     latex = find_exe_or_terminate(latex or latex_commands)
diff --git a/src/Color.cpp b/src/Color.cpp
index 5fd774afa8..1ca2c0ced3 100644
--- a/src/Color.cpp
+++ b/src/Color.cpp
@@ -299,6 +299,7 @@ ColorSet::ColorSet()
 	{ Color_none, N_("none"), "none", black, black, "none" },
 	{ Color_black, N_("black"), "black", black, black, "black" },
 	{ Color_white, N_("white"), "white", white, white, "white" },
+	{ Color_transparent, N_("transparent"), "transparent", transparent, transparent, "transparent" },
 	{ Color_blue, N_("blue"), "blue", blue, blue, "blue" },
 	{ Color_brown, N_("brown"), "brown", brown, brown, "brown" },
 	{ Color_cyan, N_("cyan"), "cyan", cyan, cyan, "cyan" },
diff --git a/src/ColorCode.h b/src/ColorCode.h
index 3492498746..d101b43d62 100644
--- a/src/ColorCode.h
+++ b/src/ColorCode.h
@@ -21,6 +21,8 @@ enum ColorCode {
 	///
 	Color_white,
 	///
+	Color_transparent,
+	///
 	Color_blue,
 	///
 	Color_brown,
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 9ba086a715..96fa9a42c3 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -615,7 +615,7 @@ ColorCode InsetMathHull::backgroundColor(PainterInfo const & pi) const
 		Dimension const dim = dimension(*pi.base.bv);
 		if (previewTooSmall(dim))
 			return Color_error;
-		return graphics::PreviewLoader::backgroundColor();
+		return Color_transparent;
 	}
 	return InsetMath::backgroundColor(pi);
 }

--Apple-Mail=_366EAA29-95EC-4E8F-9ED1-77C4801D72D9
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-- 
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel

--Apple-Mail=_366EAA29-95EC-4E8F-9ED1-77C4801D72D9--