summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2021-04-05 12:30:58 +0100
committerMichael Lutz <michi@icosahedron.de>2021-04-08 19:34:45 +0200
commit3ede756d23b09f52a8099736d9a78abc966448b8 (patch)
treefc2ae1c2fd3744fc4c1d182dfe9bb0afd49458b6
parentae94b2d29695d46813e93d26e05abb436f2bf396 (diff)
downloadopenttd-3ede756d23b09f52a8099736d9a78abc966448b8.tar.xz
Fix: Viewport drag tooltips not being removed when dragging over other windows
-rw-r--r--src/misc_gui.cpp6
-rw-r--r--src/viewport.cpp2
-rw-r--r--src/window_gui.h1
3 files changed, 8 insertions, 1 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 65f98b365..2f538f2af 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -766,6 +766,12 @@ struct TooltipsWindow : public Window
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
case TCC_NONE: break;
+
+ case TCC_EXIT_VIEWPORT: {
+ Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
+ if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) delete this;
+ break;
+ }
}
}
};
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 2a3f9b32d..aae659d53 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2637,7 +2637,7 @@ void UpdateTileSelection()
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
* @param close_cond Condition for closing this tooltip.
*/
-static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_NONE)
+static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_EXIT_VIEWPORT)
{
if (!_settings_client.gui.measure_tooltip) return;
GuiShowTooltips(_thd.GetCallbackWnd(), str, paramcount, params, close_cond);
diff --git a/src/window_gui.h b/src/window_gui.h
index c792a6b28..aca7f4486 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -268,6 +268,7 @@ enum TooltipCloseCondition {
TCC_RIGHT_CLICK,
TCC_HOVER,
TCC_NONE,
+ TCC_EXIT_VIEWPORT,
};
/**