Alexandre Julliard : winex11: Move creation of an empty cursor to a separate helper function.

Alexandre Julliard julliard at winehq.org
Wed Apr 21 10:40:18 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Apr 20 21:23:00 2010 +0200

winex11: Move creation of an empty cursor to a separate helper function.

---

 dlls/winex11.drv/mouse.c |   55 ++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index e8f96c4..c140ca3 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -168,12 +168,38 @@ static inline void update_button_state( unsigned int state )
 }
 
 /***********************************************************************
+ *		get_empty_cursor
+ */
+static Cursor get_empty_cursor(void)
+{
+    static Cursor cursor;
+    static const char data[] = { 0 };
+
+    if (!cursor)
+    {
+        XColor bg;
+        Pixmap pixmap;
+
+        bg.red = bg.green = bg.blue = 0x0000;
+        pixmap = XCreateBitmapFromData( gdi_display, root_window, data, 1, 1 );
+        if (pixmap)
+        {
+            cursor = XCreatePixmapCursor( gdi_display, pixmap, pixmap, &bg, &bg, 0, 0 );
+            XFreePixmap( gdi_display, pixmap );
+        }
+    }
+    return cursor;
+}
+
+/***********************************************************************
  *		get_x11_cursor
  */
 static Cursor get_x11_cursor( HCURSOR handle )
 {
     Cursor cursor;
 
+    if (!handle) return get_empty_cursor();
+
     if (cursor_context && !XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
         return cursor;
     return 0;
@@ -596,18 +622,6 @@ static Cursor create_xcursor_cursor( Display *display, CURSORICONINFO *ptr )
     Cursor cursor;
     XcursorImage *image;
 
-    if (!ptr) /* Create an empty cursor */
-    {
-        image = pXcursorImageCreate( 1, 1 );
-        image->xhot = 0;
-        image->yhot = 0;
-        *(image->pixels) = 0;
-        cursor = pXcursorImageLoadCursor( display, image );
-        pXcursorImageDestroy( image );
-
-        return cursor;
-    }
-
     image = create_cursor_image( ptr );
     if (!image) return 0;
 
@@ -646,24 +660,13 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
     char *bitMask32 = NULL;
     BOOL alpha_zero = TRUE;
 
+    if (!ptr) return get_empty_cursor();
+
 #ifdef SONAME_LIBXCURSOR
     if (pXcursorImageLoadCursor) return create_xcursor_cursor( display, ptr );
 #endif
 
-    if (!ptr)  /* Create an empty cursor */
-    {
-        static const char data[] = { 0 };
-
-        bg.red = bg.green = bg.blue = 0x0000;
-        pixmapBits = XCreateBitmapFromData( display, root_window, data, 1, 1 );
-        if (pixmapBits)
-        {
-            cursor = XCreatePixmapCursor( display, pixmapBits, pixmapBits,
-                                          &bg, &bg, 0, 0 );
-            XFreePixmap( display, pixmapBits );
-        }
-    }
-    else  /* Create the X cursor from the bits */
+    /* Create the X cursor from the bits */
     {
         XImage *image;
         GC gc;




More information about the wine-cvs mailing list