diff --git a/30101.patch b/30101.patch new file mode 100644 index 0000000..a7f6a09 --- /dev/null +++ b/30101.patch @@ -0,0 +1,43 @@ +From 4b8e2a011804f44233e6973697c31a97075e78d4 Mon Sep 17 00:00:00 2001 +From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> +Date: Sat, 24 May 2025 02:01:41 +0200 +Subject: [PATCH] Backport PR #30096: Fix OffsetBox custom picker + +--- + lib/matplotlib/offsetbox.py | 4 +++- + lib/matplotlib/tests/test_offsetbox.py | 10 ++++++++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py +index e987e969871a..f3b9bb7d5d2f 100644 +--- a/lib/matplotlib/offsetbox.py ++++ b/lib/matplotlib/offsetbox.py +@@ -1506,7 +1506,9 @@ def __init__(self, ref_artist, use_blit=False): + @staticmethod + def _picker(artist, mouseevent): + # A custom picker to prevent dragging on mouse scroll events +- return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {} ++ if mouseevent.name == "scroll_event": ++ return False, {} ++ return artist.contains(mouseevent) + + # A property, not an attribute, to maintain picklability. + canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas) +diff --git a/lib/matplotlib/tests/test_offsetbox.py b/lib/matplotlib/tests/test_offsetbox.py +index b23a8da7dc05..57add85b110a 100644 +--- a/lib/matplotlib/tests/test_offsetbox.py ++++ b/lib/matplotlib/tests/test_offsetbox.py +@@ -460,3 +460,13 @@ def test_draggable_in_subfigure(): + fig.canvas.draw() # Texts are non-pickable until the first draw. + MouseEvent("button_press_event", fig.canvas, 1, 1)._process() + assert ann._draggable.got_artist ++ # Stop dragging the annotation. ++ MouseEvent("button_release_event", fig.canvas, 1, 1)._process() ++ assert not ann._draggable.got_artist ++ # A scroll event should not initiate a drag. ++ MouseEvent("scroll_event", fig.canvas, 1, 1)._process() ++ assert not ann._draggable.got_artist ++ # An event outside the annotation should not initiate a drag. ++ bbox = ann.get_window_extent() ++ MouseEvent("button_press_event", fig.canvas, bbox.x1+2, bbox.y1+2)._process() ++ assert not ann._draggable.got_artist diff --git a/python-matplotlib.spec b/python-matplotlib.spec index 7ffdb8c..74d5739 100644 --- a/python-matplotlib.spec +++ b/python-matplotlib.spec @@ -68,6 +68,9 @@ Patch0002: 0005-Partially-revert-TST-Fix-minor-issues-in-interactive.patch # https://github.com/matplotlib/matplotlib/pull/29393 Patch0004: python3.14.patch +# https://github.com/matplotlib/matplotlib/pull/30096 +Patch0005: https://github.com/matplotlib/matplotlib/pull/30101.patch + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: glibc-langpack-en