Ignore:
Timestamp:
Dec 24, 2003, 4:35:07 PM (19 years ago)
Author:
Sam Hocevar
Message:
  • src/io.c: + Mouse support in the X11 driver.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/io.c

    r269 r273  
    129129#endif
    130130
     131    /* If it's already a special event, return it */
     132    if((keybuf[0] & ~0xff) != 0)
     133        return _pop_key();
     134
     135    /* If it's not an escape sequence, return the key */
    131136    if(keybuf[0] != '\x1b')
    132137        return CACA_EVENT_KEY_PRESS | _pop_key();
     
    248253#if defined(USE_X11)
    249254    XEvent event;
     255    static int x11_x = 0, x11_y = 0;
     256    long int event_mask = KeyPressMask | ButtonPressMask | PointerMotionMask;
    250257    char key;
    251258#endif
     
    268275#if defined(USE_X11)
    269276    case CACA_DRIVER_X11:
    270         while(XCheckWindowEvent(x11_dpy, x11_window, KeyPressMask, &event)
     277        while(XCheckWindowEvent(x11_dpy, x11_window, event_mask, &event)
    271278               == True)
    272279        {
    273280            KeySym keysym;
     281
     282            if(event.type == MotionNotify)
     283            {
     284                x11_x = event.xmotion.x;
     285                x11_y = event.xmotion.y;
     286                continue;
     287            }
     288
     289            if(event.type == ButtonPress)
     290            {
     291                unsigned int x = x11_x / x11_font_width;
     292                unsigned int y = x11_y / x11_font_height;
     293
     294                if(x >= _caca_width)
     295                    x = _caca_width - 1;
     296                if(y >= _caca_height)
     297                    y = _caca_height - 1;
     298
     299                return CACA_EVENT_MOUSE_CLICK
     300                        | (1 << 16) | (x << 8) | (y << 0);
     301            }
    274302
    275303            if(event.type != KeyPress)
Note: See TracChangeset for help on using the changeset viewer.