From 6a2d8f8da0becafb4b8f9e95a5747801843b58d0 Mon Sep 17 00:00:00 2001 From: nulano Date: Fri, 20 Sep 2019 17:35:08 +0200 Subject: [PATCH] rename parameter, add note to docs --- Tests/test_imagegrab.py | 2 +- docs/reference/ImageGrab.rst | 5 +++-- src/PIL/ImageGrab.py | 4 ++-- src/display.c | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 8207177a6..bea7f68b3 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -11,7 +11,7 @@ try: for im in [ ImageGrab.grab(), ImageGrab.grab(include_layered_windows=True), - ImageGrab.grab(multimonitor=True), + ImageGrab.grab(all_screens=True), ]: self.assert_image(im, im.mode, im.size) diff --git a/docs/reference/ImageGrab.rst b/docs/reference/ImageGrab.rst index 6dae63ae4..a7d7be6fe 100644 --- a/docs/reference/ImageGrab.rst +++ b/docs/reference/ImageGrab.rst @@ -11,7 +11,7 @@ or the clipboard to a PIL image memory. .. versionadded:: 1.1.3 -.. py:function:: PIL.ImageGrab.grab(bbox=None, include_layered_windows=False, multimonitor=False) +.. py:function:: PIL.ImageGrab.grab(bbox=None, include_layered_windows=False, all_screens=False) Take a snapshot of the screen. The pixels inside the bounding box are returned as an "RGB" image on Windows or "RGBA" on macOS. @@ -20,8 +20,9 @@ or the clipboard to a PIL image memory. .. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS) :param bbox: What region to copy. Default is the entire screen. + Note that on Windows OS, the top-left point may be negative if ``all_screens=True`` is used. :param include_layered_windows: Includes layered windows. Windows OS only. - :param multimonitor: Capture all monitors. Windows OS only. + :param all_screens: Capture all monitors. Windows OS only. :return: An image .. py:function:: PIL.ImageGrab.grabclipboard() diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index 0fafb3bfe..9b4413536 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -29,7 +29,7 @@ else: raise ImportError("ImageGrab is macOS and Windows only") -def grab(bbox=None, include_layered_windows=False, multimonitor=False): +def grab(bbox=None, include_layered_windows=False, all_screens=False): if sys.platform == "darwin": fh, filepath = tempfile.mkstemp(".png") os.close(fh) @@ -40,7 +40,7 @@ def grab(bbox=None, include_layered_windows=False, multimonitor=False): if bbox: im = im.crop(bbox) else: - offset, size, data = grabber(include_layered_windows, multimonitor) + offset, size, data = grabber(include_layered_windows, all_screens) im = Image.frombytes( "RGB", size, diff --git a/src/display.c b/src/display.c index 8a78b718a..67f8e546c 100644 --- a/src/display.c +++ b/src/display.c @@ -323,14 +323,14 @@ PyObject* PyImaging_GrabScreenWin32(PyObject* self, PyObject* args) { int x = 0, y = 0, width, height; - int includeLayeredWindows = 0, multimonitor = 0; + int includeLayeredWindows = 0, all_screens = 0; HBITMAP bitmap; BITMAPCOREHEADER core; HDC screen, screen_copy; DWORD rop; PyObject* buffer; - if (!PyArg_ParseTuple(args, "|ii", &includeLayeredWindows, &multimonitor)) + if (!PyArg_ParseTuple(args, "|ii", &includeLayeredWindows, &all_screens)) return NULL; /* step 1: create a memory DC large enough to hold the @@ -339,7 +339,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args) screen = CreateDC("DISPLAY", NULL, NULL, NULL); screen_copy = CreateCompatibleDC(screen); - if (multimonitor) { + if (all_screens) { x = GetSystemMetrics(SM_XVIRTUALSCREEN); y = GetSystemMetrics(SM_YVIRTUALSCREEN); width = GetSystemMetrics(SM_CXVIRTUALSCREEN);