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

This commit is contained in:
Alexandre Julliard 2010-04-20 21:23:00 +02:00
parent 9485f0b756
commit 776527f38f
1 changed files with 29 additions and 26 deletions

View File

@ -167,6 +167,30 @@ static inline void update_button_state( unsigned int state )
/* X-buttons are not reported from XQueryPointer */
}
/***********************************************************************
* 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
*/
@ -174,6 +198,8 @@ 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;