From e7f8ee5cd6ef78d3b652ac08a6d91ff99a7a5c58 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Jun 2023 09:28:24 +0530 Subject: [PATCH] E-book viewer: Fix selection popup not showing for some books on some platforms when the selection is in the top line. Fixes #2024375 [Private bug](https://bugs.launchpad.net/calibre/+bug/2024375) --- src/pyj/select.pyj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pyj/select.pyj b/src/pyj/select.pyj index 0a149436fb..1763f3b179 100644 --- a/src/pyj/select.pyj +++ b/src/pyj/select.pyj @@ -95,7 +95,10 @@ def range_extents(q, in_flow_mode): end = q.cloneRange() def rect_onscreen(r): - if r.right <= window.innerWidth and r.bottom <= window.innerHeight and r.left >= 0 and r.top >= 0: + # we use -1 rather than zero for the top limit because on some + # platforms the browser engine returns that for top line selections. + # See https://bugs.launchpad.net/calibre/+bug/2024375/ for a test case. + if r.right <= window.innerWidth and r.bottom <= window.innerHeight and r.left >= 0 and r.top >= -1: return True return False