Changeset 799


Ignore:
Timestamp:
Apr 17, 2006, 10:09:42 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Implemented CACA_EVENT_QUIT. Unused yet.
Location:
libcaca/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/TODO

    r793 r799  
    5353   o text edit widget with cursor support (I'm unsure about this, it
    5454     seems pretty difficult)
    55 
    56    o add a CACA_QUIT event, or add a way to map the "close window" or other
    57      nasty program killing events to a key or series of keys
    5855
    5956
  • libcaca/trunk/caca/caca.h

    r777 r799  
    121121 *      the \e libcucul canvas attached to \e libcaca.
    122122 *
     123 *  \li \b CACA_EVENT_QUIT: no other field is valid.
     124 *
    123125 *  The result of accessing data members outside the above conditions is
    124126 *  undefined.
     
    136138        CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
    137139        CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
     140        CACA_EVENT_QUIT =          0x0040, /**< The user requested to quit. */
    138141
    139142        CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
  • libcaca/trunk/caca/driver_gl.c

    r780 r799  
    5252static void gl_handle_mouse(int, int, int, int);
    5353static void gl_handle_mouse_motion(int, int);
     54#ifdef HAVE_GLUTCLOSEFUNC
     55static void gl_handle_close(void);
     56#endif
    5457static void _display(void);
    5558
     
    6265    float incx, incy;
    6366    int id[128 - 32];
     67    unsigned char close;
    6468    unsigned char bit;
    6569    unsigned char mouse_changed, mouse_clicked;
     
    101105    kk->drv.p->height = kk->qq->height * kk->drv.p->font_height;
    102106
     107#ifdef HAVE_GLUTCLOSEFUNC
     108    kk->drv.p->close = 0;
     109#endif
    103110    kk->drv.p->bit = 0;
    104111
     
    128135    glutDisplayFunc(_display);
    129136
     137#ifdef HAVE_GLUTCLOSEFUNC
     138    glutCloseFunc(gl_handle_close);
     139#endif
    130140
    131141    glutMouseFunc(gl_handle_mouse);
     
    208218    return kk->drv.p->height;
    209219}
    210 
    211220
    212221static void gl_display(caca_t *kk)
     
    311320#else
    312321    glutMainLoopEvent();
     322#endif
     323
     324#ifdef HAVE_GLUTCLOSEFUNC
     325    if(kk->drv.p->close)
     326    {
     327        kk->drv.p->close = 0;
     328        ev->type = CACA_EVENT_QUIT;
     329        return 1;
     330    }
    313331#endif
    314332
     
    454472}
    455473
    456 
     474#ifdef HAVE_GLUTCLOSEFUNC
     475static void gl_handle_close(void)
     476{
     477    caca_t *kk = gl_kk;
     478    kk->drv.p->close = 1;
     479}
     480#endif
    457481
    458482static void _display(void)
  • libcaca/trunk/caca/driver_x11.c

    r780 r799  
    5353    int font_offset;
    5454    Cursor pointer;
     55    Atom wm_protocols;
     56    Atom wm_delete_window;
    5557#if defined(HAVE_X11_XKBLIB_H)
    5658    Bool autorepeat;
     
    148150                      CWBackingStore | CWBackPixel | CWEventMask,
    149151                      &x11_winattr);
     152
     153    kk->drv.p->wm_protocols =
     154        XInternAtom(kk->drv.p->dpy, "WM_PROTOCOLS", True);
     155    kk->drv.p->wm_delete_window =
     156        XInternAtom(kk->drv.p->dpy, "WM_DELETE_WINDOW", True);
     157
     158    if(p_win->wm_protocols != None && p_win->wm_delete_window != None)
     159        XSetWMProtocols(kk->drv.p->dpy, kk->drv.p->window,
     160                        &kk->drv.p->wm_delete_window, 1);
    150161
    151162    XStoreName(kk->drv.p->dpy, kk->drv.p->window, "caca for X");
     
    509520    }
    510521
     522    while(XCheckTypedEvent(kk->drv.p->dpy, ClientMessage, &xevent))
     523    {
     524        if(xevent.xclient.message_type != kk->drv.p->wm_protocols)
     525            continue;
     526
     527        if((Atom)xevent.xclient.data.l[0] == kk->drv.p->wm_delete_window)
     528        {
     529            ev->type = CACA_EVENT_QUIT;
     530            return 1;
     531        }
     532    }
     533
    511534    ev->type = CACA_EVENT_NONE;
    512535    return 0;
  • libcaca/trunk/configure.ac

    r781 r799  
    172172  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
    173173   [AC_CHECK_HEADERS(GL/glut.h,
    174      [AC_CHECK_LIB(glut, glutMainLoopEvent,
    175        [ac_cv_my_have_gl="yes"])]
    176      [AC_CHECK_LIB(glut, glutCheckLoop,
     174     [AC_CHECK_LIB(glut, glutCloseFunc,
     175       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
     176      AC_CHECK_LIB(glut, glutMainLoopEvent,
     177       [ac_cv_my_have_gl="yes"])
     178      AC_CHECK_LIB(glut, glutCheckLoop,
    177179       [ac_cv_my_have_gl="yes"
    178180        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
Note: See TracChangeset for help on using the changeset viewer.