Skip to content

Commit

Permalink
Avoid global color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Nov 18, 2023
1 parent f5285da commit 52e7179
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
6 changes: 2 additions & 4 deletions base/beamerbaseboxes.sty
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
\setkeys{beamerboxes}{#1}%
{%
\usebeamercolor{\bmb@lower}%
\globalcolorstrue%
\colorlet{lower.bg}{bg}%
\beamer@smuggle@color{bg}{lower.bg}%
}%
{%
\usebeamercolor{\bmb@upper}%
\globalcolorstrue%
\colorlet{upper.bg}{bg}%
\beamer@smuggle@color{bg}{upper.bg}%
}%
%
% Typeset head
Expand Down
30 changes: 20 additions & 10 deletions base/beamerbasecolor.sty
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@
\beamer@thc@docolor{#1}%
\ifx\beamer@thc@fg\@empty\def\beamer@thc@fg{fg}\fi%
\ifx\beamer@thc@bg\@empty\def\beamer@thc@bg{bg}\fi%
\global\let\beamer@thc@gfg\beamer@thc@fg%
\global\let\beamer@thc@gbg\beamer@thc@bg%
\globalcolorstrue%
\colorlet{#1.fg}{\beamer@thc@gfg}%
\colorlet{#1.bg}{\beamer@thc@gbg}%
\expanded{%
\noexpand\beamer@smuggle@color{\beamer@thc@fg}{#1.fg}%
\noexpand\beamer@smuggle@color{\beamer@thc@bg}{#1.bg}%
}%
\endgroup%
}

Expand Down Expand Up @@ -79,7 +78,6 @@
\fi%
}


\def\usebeamercolor{\@ifstar{\beamer@usebeamercolor[fg]{normal text}\beamer@usebeamercolor}{\beamer@usebeamercolor}}
\newcommand\beamer@usebeamercolor[2][]{%
\beamer@thc@prepcolor%
Expand All @@ -98,17 +96,29 @@
\colorlet{parent.bg}{bg}%
\colorlet{fg}{temp@fg}%
\colorlet{bg}{temp@bg}%
\globalcolorstrue
\colorlet{#2.fg}{temp@fg}%
\colorlet{#2.bg}{temp@bg}%
\globalcolorsfalse
\beamer@smuggle@color{temp@fg}{#2.fg}%
\beamer@smuggle@color{temp@bg}{#2.bg}%
\def\beamer@temp{#1}%
\ifx\beamer@temp\@empty%
\else%
\color{#1}%
\fi%
}

% 'Smuggle' color out of a group (beamer's model here is ... not great)
\newcounter{beamer@global@color@cnt}
\protected\def\beamer@smuggle@color#1#2{%
\stepcounter{beamer@global@color@cnt}%
\extractcolorspec{#1}\beamer@tmp@color
\expandafter\xdef\csname beamer@smuggle@color@\the\c@beamer@global@color@cnt\endcsname
{%
\noexpand\definecolor{#2}\beamer@tmp@color
\aftergroup\expandafter\noexpand
\csname beamer@smuggle@color@\the\c@beamer@global@color@cnt\endcsname
}%
\@nameuse{beamer@smuggle@color@\the\c@beamer@global@color@cnt}%
}

\colorlet{fg}{black}
\colorlet{bg}{white}

Expand Down
2 changes: 1 addition & 1 deletion base/beamerbaseoverlay.sty
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
\the\beamer@coveringdepth\endcsname{\beamer@colorhook}%
\expandafter\xdef\csname beamer@oldpgfextension%
\the\beamer@coveringdepth\endcsname{\beamer@pgfextension}%
{\globalcolorstrue\colorlet{beamer@freeze\the\beamer@coveringdepth}{bg}}%
{\beamer@smuggle@color{bg}{beamer@freeze\the\beamer@coveringdepth}}%
\xdef\beamer@colorhook{!##2!beamer@freeze%
\the\beamer@coveringdepth\beamer@colorhook}%
\gdef\beamer@pgfextension{!##2opaque}%
Expand Down

0 comments on commit 52e7179

Please sign in to comment.