Ignore:
Timestamp:
Nov 25, 2007, 3:11:58 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Add cucul_manage_canvas() and cucul_unmanage_canvas(). Display drivers no longer need to access the cv->refcount private member and cucul_set_canvas_size() is no longer needed.
File:
1 edited

Legend:

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

    r1462 r2055  
    4343#endif
    4444
     45static int caca_can_resize(caca_display_t *);
    4546static int caca_select_driver(caca_display_t *);
    4647#if defined(USE_PLUGINS)
     
    6263 *  \return The caca graphical context or NULL if an error occurred.
    6364 */
    64 caca_display_t * caca_create_display(cucul_canvas_t * cv)
     65caca_display_t * caca_create_display(cucul_canvas_t *cv)
    6566{
    6667    caca_display_t *dp = malloc(sizeof(caca_display_t));
     
    6970    {
    7071        seterrno(ENOMEM);
     72        return NULL;
     73    }
     74
     75    if(cucul_manage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp))
     76    {
     77        free(dp);
     78        seterrno(EBUSY);
    7179        return NULL;
    7280    }
     
    8391            dlclose(dp->plugin);
    8492#endif
     93        cucul_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp);
    8594        free(dp);
    8695        seterrno(ENODEV);
     
    94103            dlclose(dp->plugin);
    95104#endif
     105        cucul_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp);
    96106        free(dp);
    97107        seterrno(ENODEV);
    98108        return NULL;
    99109    }
    100 
    101     /* Attached! */
    102     dp->cv->refcount++;
    103110
    104111    /* Graphics stuff */
     
    128135    /* Resize events */
    129136    dp->resize.resized = 0;
     137    dp->resize.allow = 0;
    130138
    131139    return dp;
     
    150158        dlclose(dp->plugin);
    151159#endif
    152     dp->cv->refcount--;
     160    cucul_unmanage_canvas(dp->cv, (int (*)(void *))caca_can_resize, (void *)dp);
    153161    free(dp);
    154162
     
    159167 * XXX: The following functions are local.
    160168 */
     169
     170static int caca_can_resize(caca_display_t *dp)
     171{
     172    return dp->resize.allow;
     173}
    161174
    162175static int caca_select_driver(caca_display_t *dp)
Note: See TracChangeset for help on using the changeset viewer.