[gimp] Issue #4009: enables option to capture cursor in screenshot (Windows)



commit 94c7f80282e1deeaa20905b05cb336c805e022c4
Author: Nikc <nikcdc gmail com>
Date:   Wed Jan 19 01:28:47 2022 +0000

    Issue #4009: enables option to capture cursor in screenshot (Windows)

 plug-ins/screenshot/screenshot-win32.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-win32.c b/plug-ins/screenshot/screenshot-win32.c
index ddf9212c81..a88394afef 100644
--- a/plug-ins/screenshot/screenshot-win32.c
+++ b/plug-ins/screenshot/screenshot-win32.c
@@ -82,6 +82,7 @@ static MAGIMAGEHEADER  returnedSrcheader;
 static int             rectScreensCount = 0;
 
 static GimpImage     **image;
+static gboolean        capturePointer = FALSE;
 
 static void sendBMPToGimp                      (HBITMAP         hBMP,
                                                 HDC             hDC,
@@ -158,7 +159,8 @@ ScreenshotCapabilities
 screenshot_win32_get_capabilities (void)
 {
   return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
-          SCREENSHOT_CAN_SHOOT_WINDOW);
+          SCREENSHOT_CAN_SHOOT_WINDOW      |
+          SCREENSHOT_CAN_SHOOT_POINTER);
 }
 
 GimpPDBStatusType
@@ -176,6 +178,7 @@ screenshot_win32_shoot (ScreenshotValues  *shootvals,
   image = _image;
 
   winsnapvals.delay = shootvals->screenshot_delay;
+  capturePointer = shootvals->show_cursor;
 
   if (shootvals->shoot_type == SHOOT_ROOT)
     {
@@ -463,6 +466,14 @@ primDoWindowCapture (HDC  hdcWindow,
       return NULL;
     }
 
+  /* Draw mouse pointer over screenshot if option was selected */
+  if (capturePointer)
+    {
+      CURSORINFO pointer = { sizeof (pointer) };
+      GetCursorInfo (&pointer);
+      DrawIcon (hdcCompat, pointer.ptScreenPos.x, pointer.ptScreenPos.y, GetCursor());
+    }
+
   /* Restore the original object */
   SelectObject (hdcCompat, oldObject);
 
@@ -768,6 +779,7 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
   HWND            excludeWins[24];
   RECT            round4Rect;
   int             excludeWinsCount = 0;
+  int             magStyles;
 
   if (!LoadMagnificationLibrary ()) return FALSE;
 
@@ -788,9 +800,13 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
 
   SetLayeredWindowAttributes (hwndHost, (COLORREF)0, (BYTE)255, (DWORD)0x02);
 
+  magStyles = WS_CHILD;
+  if (capturePointer)
+    magStyles |= MS_SHOWMAGNIFIEDCURSOR;
+
   /* Create the mag child window inside the host window */
   hwndMag = CreateWindow (WC_MAGNIFIER, TEXT ("MagnifierWindow"),
-                          WS_CHILD /*| MS_SHOWMAGNIFIEDCURSOR*/  /*| WS_VISIBLE*/,
+                          magStyles,
                           0, 0, round4Rect.right - round4Rect.left, round4Rect.bottom - round4Rect.top,
                           hwndHost, NULL, GetModuleHandle (NULL), NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]