Re: Hiding mouse cursor?



"Lewin A.R.W. Edwards" <larwe larwe com> writes:
I can't seem to find any related functions.. I have an application
that runs as an embedded system. No mouse on this system. I don't want
the mouse cursor in the middle of my screen; is there a Gtk API to
hide it?

Create a GdkBitmap containing a single transparent pixel, use that to
create a GdkCursor, then set the cursor to that.

Here's the code, from eel, I don't think it's been tested though:

void
eel_gdk_window_set_invisible_cursor (GdkWindow *window)
{
        GdkBitmap *empty_bitmap;
        GdkCursor *cursor;
        GdkColor useless;
        char invisible_cursor_bits[] = { 0x0 }; 
        
        useless.red = useless.green = useless.blue = 0;
        useless.pixel = 0;
        
        empty_bitmap = gdk_bitmap_create_from_data (window,
                                                    invisible_cursor_bits,
                                                    1, 1);
        
        cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
                                             empty_bitmap,
                                             &useless,
                                             &useless, 0, 0);

        gdk_window_set_cursor (window, cursor);

        gdk_cursor_unref (cursor);

        g_object_unref (G_OBJECT (empty_bitmap));
}

Havoc



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