From 6c7baf08de6b40b89de40a950c94f50f6011d5cf Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Wed, 27 Apr 2022 19:11:21 -0600 Subject: [PATCH] ENH: Add option to disable raising the window for macosx This enables the rcParam "figure.raise_window" to control whether the macosx backend raises the window to the foreground or not. --- lib/matplotlib/backends/backend_macosx.py | 8 ++++++++ src/_macosx.m | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index 4700e28e48cc..9564bdbb3e78 100644 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -140,6 +140,7 @@ class FigureManagerMac(_macosx.FigureManager, FigureManagerBase): _toolbar2_class = NavigationToolbar2Mac def __init__(self, canvas, num): + self._shown = False _macosx.FigureManager.__init__(self, canvas) icon_path = str(cbook._get_data_path('images/matplotlib.pdf')) _macosx.FigureManager.set_icon(icon_path) @@ -154,6 +155,13 @@ def close(self): Gcf.destroy(self) self.canvas.flush_events() + def show(self): + if not self._shown: + self._show() + self._shown = True + if mpl.rcParams["figure.raise_window"]: + self._raise() + @_Backend.export class _BackendMac(_Backend): diff --git a/src/_macosx.m b/src/_macosx.m index b0da1fb84f4d..ce5bb51d9e76 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -586,9 +586,15 @@ static CGFloat _get_device_scale(CGContextRef cr) } static PyObject* -FigureManager_show(FigureManager* self) +FigureManager__show(FigureManager* self) { [self->window makeKeyAndOrderFront: nil]; + Py_RETURN_NONE; +} + +static PyObject* +FigureManager__raise(FigureManager* self) +{ [self->window orderFrontRegardless]; Py_RETURN_NONE; } @@ -695,8 +701,11 @@ static CGFloat _get_device_scale(CGContextRef cr) .tp_new = (newfunc)FigureManager_new, .tp_doc = "A FigureManager object wraps a Cocoa NSWindow object.", .tp_methods = (PyMethodDef[]){ // All docstrings are inherited. - {"show", - (PyCFunction)FigureManager_show, + {"_show", + (PyCFunction)FigureManager__show, + METH_NOARGS}, + {"_raise", + (PyCFunction)FigureManager__raise, METH_NOARGS}, {"destroy", (PyCFunction)FigureManager_destroy, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy