Alexandre Julliard : winex11: Load a monochrome cursor instead of converting a color one when possible.

Alexandre Julliard julliard at winehq.org
Mon Jul 10 15:52:46 CDT 2017


Module: wine
Branch: master
Commit: 2e0a1cfd8355ee0328838eb56b283494103fcd3b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2e0a1cfd8355ee0328838eb56b283494103fcd3b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul 10 11:42:08 2017 +0200

winex11: Load a monochrome cursor instead of converting a color one when possible.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/mouse.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 259263d..5ace405 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -1160,6 +1160,43 @@ done:
 }
 
 /***********************************************************************
+ *		create_xlib_load_mono_cursor
+ *
+ * Create a monochrome X cursor from a color Windows one by trying to load the monochrome resource.
+ */
+static Cursor create_xlib_load_mono_cursor( HDC hdc, HANDLE handle, int width, int height )
+{
+    Cursor cursor = None;
+    HANDLE mono;
+    ICONINFOEXW info;
+    BITMAP bm;
+
+    if (!(mono = CopyImage( handle, IMAGE_CURSOR, width, height, LR_MONOCHROME | LR_COPYFROMRESOURCE )))
+        return None;
+
+    info.cbSize = sizeof(info);
+    if (GetIconInfoExW( mono, &info ))
+    {
+        if (!info.hbmColor)
+        {
+            GetObjectW( info.hbmMask, sizeof(bm), &bm );
+            bm.bmHeight = max( 1, bm.bmHeight / 2 );
+            /* make sure hotspot is valid */
+            if (info.xHotspot >= bm.bmWidth || info.yHotspot >= bm.bmHeight)
+            {
+                info.xHotspot = bm.bmWidth / 2;
+                info.yHotspot = bm.bmHeight / 2;
+            }
+            cursor = create_xlib_monochrome_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
+        }
+        else DeleteObject( info.hbmColor );
+        DeleteObject( info.hbmMask );
+    }
+    DestroyCursor( mono );
+    return cursor;
+}
+
+/***********************************************************************
  *		create_xlib_color_cursor
  *
  * Create a color X cursor from a Windows one.
@@ -1334,6 +1371,7 @@ static Cursor create_cursor( HANDLE handle )
         if (pXcursorImagesLoadCursor)
             cursor = create_xcursor_cursor( hdc, &info, handle, bm.bmWidth, bm.bmHeight );
 #endif
+        if (!cursor) cursor = create_xlib_load_mono_cursor( hdc, handle, bm.bmWidth, bm.bmHeight );
         if (!cursor) cursor = create_xlib_color_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
         DeleteObject( info.hbmColor );
     }




More information about the wine-cvs mailing list