From 6817e9d085345ac6b26a5c7b90d963c3d4bf630d Mon Sep 17 00:00:00 2001
From: "(quasar) nebula" <qznebula@protonmail.com>
Date: Fri, 29 Mar 2024 14:23:59 -0300
Subject: client: whenTooltipShows, whenTooltipHides

---
 src/static/client3.js | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/static/client3.js b/src/static/client3.js
index 1554e321..5738b46f 100644
--- a/src/static/client3.js
+++ b/src/static/client3.js
@@ -1075,6 +1075,11 @@ const hoverableTooltipInfo = initInfo('hoverableTooltipInfo', {
     currentTouchIdentifiers: new Set(),
     touchIdentifiersBanishedByScrolling: new Set(),
   },
+
+  event: {
+    whenTooltipShows: [],
+    whenTooltipHides: [],
+  },
 });
 
 // Adds DOM event listeners, so must be called during addPageListeners step.
@@ -1476,7 +1481,7 @@ function endTransitioningTooltipHidden() {
 }
 
 function hideCurrentlyShownTooltip(intendingToReplace = false) {
-  const {settings, state} = hoverableTooltipInfo;
+  const {settings, state, event} = hoverableTooltipInfo;
   const {currentlyShownTooltip: tooltip} = state;
 
   // If there was no tooltip to begin with, we're functionally in the desired
@@ -1516,11 +1521,15 @@ function hideCurrentlyShownTooltip(intendingToReplace = false) {
     state.tooltipWasJustHidden = false;
   });
 
+  dispatchInternalEvent(event, 'whenTooltipHides', {
+    tooltip,
+  });
+
   return true;
 }
 
 function showTooltipFromHoverable(hoverable) {
-  const {state} = hoverableTooltipInfo;
+  const {state, event} = hoverableTooltipInfo;
   const {tooltip} = state.registeredHoverables.get(hoverable);
 
   if (!hideCurrentlyShownTooltip(true)) return false;
@@ -1541,6 +1550,10 @@ function showTooltipFromHoverable(hoverable) {
 
   state.tooltipWasJustHidden = false;
 
+  dispatchInternalEvent(event, 'whenTooltipShows', {
+    tooltip,
+  });
+
   return true;
 }
 
-- 
cgit 1.3.0-6-gf8a5