FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: Add option to disable raising the window for macosx by greglucas · Pull Request #22928 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/backend_macosx.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
15 changes: 12 additions & 3 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down

Back | FazBrowse Home | New Git URL