winex11: Move creation of an empty cursor to a separate helper function.
This commit is contained in:
parent
9485f0b756
commit
776527f38f
|
@ -167,6 +167,30 @@ static inline void update_button_state( unsigned int state )
|
||||||
/* X-buttons are not reported from XQueryPointer */
|
/* 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
|
* get_x11_cursor
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +198,8 @@ static Cursor get_x11_cursor( HCURSOR handle )
|
||||||
{
|
{
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
|
if (!handle) return get_empty_cursor();
|
||||||
|
|
||||||
if (cursor_context && !XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
|
if (cursor_context && !XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
|
||||||
return cursor;
|
return cursor;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -596,18 +622,6 @@ static Cursor create_xcursor_cursor( Display *display, CURSORICONINFO *ptr )
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
XcursorImage *image;
|
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 );
|
image = create_cursor_image( ptr );
|
||||||
if (!image) return 0;
|
if (!image) return 0;
|
||||||
|
|
||||||
|
@ -646,24 +660,13 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
|
||||||
char *bitMask32 = NULL;
|
char *bitMask32 = NULL;
|
||||||
BOOL alpha_zero = TRUE;
|
BOOL alpha_zero = TRUE;
|
||||||
|
|
||||||
|
if (!ptr) return get_empty_cursor();
|
||||||
|
|
||||||
#ifdef SONAME_LIBXCURSOR
|
#ifdef SONAME_LIBXCURSOR
|
||||||
if (pXcursorImageLoadCursor) return create_xcursor_cursor( display, ptr );
|
if (pXcursorImageLoadCursor) return create_xcursor_cursor( display, ptr );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ptr) /* Create an empty cursor */
|
/* Create the X cursor from the bits */
|
||||||
{
|
|
||||||
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 */
|
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
GC gc;
|
GC gc;
|
||||||
|
|
Loading…
Reference in New Issue