Ignore:
Timestamp:
Mar 24, 2006, 5:25:39 PM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Fixed bug in show/hide cursor, implemented X11 cursor
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_x11.c

    r687 r688  
    540540static void x11_show_cursor(caca_t *kk)
    541541{
    542 
     542    XDefineCursor(kk->drv.p->dpy,kk->drv.p->window, 0);
    543543}
    544544
    545545static void x11_hide_cursor(caca_t *kk)
    546546{
    547     XFreeCursor( kk->drv.p->dpy, kk->drv.p->pointer );
    548     kk->drv.p->pointer = None;
    549     XUndefineCursor( kk->drv.p->dpy, kk->drv.p->window );
    550     XSync( kk->drv.p->dpy, False ); /* optional */
     547    Cursor no_ptr;
     548    Pixmap bm_no;
     549    XColor black, dummy;
     550    Colormap colormap;
     551    static char empty[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     552
     553    colormap = DefaultColormap(kk->drv.p->dpy, DefaultScreen(kk->drv.p->dpy));
     554    if ( !XAllocNamedColor(kk->drv.p->dpy, colormap, "black", &black, &dummy) )
     555    {
     556      return;
     557    }
     558    bm_no = XCreateBitmapFromData(kk->drv.p->dpy, kk->drv.p->window, empty, 8, 8);
     559    no_ptr = XCreatePixmapCursor(kk->drv.p->dpy, bm_no, bm_no, &black, &black, 0, 0);
     560    XDefineCursor(kk->drv.p->dpy,  kk->drv.p->window, no_ptr);
     561    XFreeCursor(kk->drv.p->dpy, no_ptr);
     562    if (bm_no != None)
     563        XFreePixmap(kk->drv.p->dpy, bm_no);
     564    XFreeColors(kk->drv.p->dpy,colormap,&black.pixel,1,0);
     565
     566    XSync(kk->drv.p->dpy, False);
    551567
    552568}
Note: See TracChangeset for help on using the changeset viewer.