From 51d7ac1baaa409e60c9e2d2087af743edb079961 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Mar 2020 20:25:39 +0530 Subject: [PATCH] Ensure selection color does not change when iframe is de-focused --- src/pyj/read_book/settings.pyj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/settings.pyj b/src/pyj/read_book/settings.pyj index f2de15cde1..456ecb9d68 100644 --- a/src/pyj/read_book/settings.pyj +++ b/src/pyj/read_book/settings.pyj @@ -3,7 +3,8 @@ from __python__ import hash_literals from elementmaker import E -from read_book.globals import runtime + +from read_book.globals import dark_link_color, runtime from session import defaults opts = {} @@ -63,6 +64,15 @@ def apply_colors(): # priority than the override all selectors above text += f'\nhtml > body :link, html > body :link * {{ color: {c} !important }} html > body :visited, html > body :visited * {{ color: {c} !important }}' + if opts.is_dark_theme: + selbg = dark_link_color + selfg = 'black' + else: + selbg = '#3297FD' + selfg = 'white' + text += f'\n::selection {{ background-color: {selbg}; color: {selfg} }}' + text += f'\n::selection:window-inactive {{ background-color: {selbg}; color: {selfg} }}' + ss.textContent = text