Changeset 1006
- Timestamp:
- Aug 2, 2006, 3:12:43 PM (16 years ago)
- Location:
- libcaca/trunk/caca
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca.c
r984 r1006 24 24 # include <stdlib.h> 25 25 # include <string.h> 26 # if defined(HAVE_ERRNO_H) 27 # include <errno.h> 28 # endif 26 29 #endif 27 30 … … 31 34 #include "caca_internals.h" 32 35 33 static int caca_ init_driver(caca_display_t *dp);36 static int caca_select_driver(caca_display_t *dp); 34 37 35 38 /** \brief Attach a caca graphical context to a cucul canvas. … … 40 43 * then be displayed by the libcaca driver. 41 44 * 45 * If an error occurs, NULL is returned and \b errno is set accordingly: 46 * - \c ENOMEM Not enough memory. 47 * - \c ENODEV Graphical device could not be initialised. 48 * 42 49 * \param cv The cucul cavas. 43 50 * \return The caca graphical context or NULL if an error occurred. … … 47 54 caca_display_t *dp = malloc(sizeof(caca_display_t)); 48 55 56 if(!dp) 57 { 58 #if defined(HAVE_ERRNO_H) 59 errno = ENOMEM; 60 #endif 61 return NULL; 62 } 63 49 64 dp->cv = cv; 50 65 51 if(caca_ init_driver(dp))66 if(caca_select_driver(dp)) 52 67 { 53 68 free(dp); 69 #if defined(HAVE_ERRNO_H) 70 errno = ENODEV; 71 #endif 54 72 return NULL; 55 73 } … … 58 76 { 59 77 free(dp); 78 #if defined(HAVE_ERRNO_H) 79 errno = ENODEV; 80 #endif 60 81 return NULL; 61 82 } … … 100 121 * attached to it afterwards. 101 122 * 123 * This function never fails. 124 * 102 125 * \param dp The libcaca graphical context. 103 */ 104 void caca_free_display(caca_display_t *dp) 126 * \return This function always returns 0. 127 */ 128 int caca_free_display(caca_display_t *dp) 105 129 { 106 130 dp->drv.end_graphics(dp); 107 131 dp->cv->refcount--; 108 132 free(dp); 133 134 return 0; 109 135 } 110 136 … … 113 139 */ 114 140 115 static int caca_ init_driver(caca_display_t *dp)141 static int caca_select_driver(caca_display_t *dp) 116 142 { 117 143 #if defined(HAVE_GETENV) && defined(HAVE_STRCASECMP) -
libcaca/trunk/caca/caca.h
r969 r1006 151 151 * @{ */ 152 152 caca_display_t * caca_create_display(cucul_canvas_t *); 153 voidcaca_free_display(caca_display_t *);154 voidcaca_refresh_display(caca_display_t *);155 voidcaca_set_display_time(caca_display_t *, unsigned int);153 int caca_free_display(caca_display_t *); 154 int caca_refresh_display(caca_display_t *); 155 int caca_set_display_time(caca_display_t *, unsigned int); 156 156 unsigned int caca_get_display_time(caca_display_t *); 157 157 unsigned int caca_get_display_width(caca_display_t *); … … 169 169 unsigned int caca_get_mouse_x(caca_display_t *); 170 170 unsigned int caca_get_mouse_y(caca_display_t *); 171 voidcaca_set_mouse(caca_display_t *, int);171 int caca_set_mouse(caca_display_t *, int); 172 172 /* @} */ 173 173 -
libcaca/trunk/caca/driver_conio.c
r979 r1006 80 80 static int conio_set_display_title(caca_display_t *dp, char const *title) 81 81 { 82 return 0;82 return -1; 83 83 } 84 84 -
libcaca/trunk/caca/driver_ncurses.c
r986 r1006 179 179 static int ncurses_set_display_title(caca_display_t *dp, char const *title) 180 180 { 181 return 0;181 return -1; 182 182 } 183 183 -
libcaca/trunk/caca/driver_raw.c
r859 r1006 40 40 static int raw_set_display_title(caca_display_t *dp, char const *title) 41 41 { 42 return 0;42 return -1; 43 43 } 44 44 -
libcaca/trunk/caca/driver_slang.c
r986 r1006 184 184 { 185 185 /* FIXME */ 186 return 0;186 return -1; 187 187 } 188 188 -
libcaca/trunk/caca/driver_vga.c
r859 r1006 98 98 { 99 99 /* Unsupported, of course. */ 100 return 0;100 return -1; 101 101 } 102 102 -
libcaca/trunk/caca/event.c
r969 r1006 45 45 * This function polls the event queue for mouse or keyboard events matching 46 46 * the event mask and returns the first matching event. Non-matching events 47 * are discarded. \c event_mask must have a non-zero value.47 * are discarded. If \c event_mask is zero, the function returns immediately. 48 48 * 49 49 * The timeout value tells how long this function needs to wait for an … … 55 55 * received. If null, the function will return but no information about 56 56 * the event will be sent. 57 * 58 * This function never fails. 57 59 * 58 60 * \param dp The libcaca graphical context. … … 118 120 * the mouse is clicked. Other drivers such as X11 work well. 119 121 * 122 * This function never fails. 123 * 120 124 * \param dp The libcaca graphical context. 121 125 * \return The X mouse coordinate. … … 135 139 * drivers are being used, because mouse position is only detected when 136 140 * the mouse is clicked. Other drivers such as X11 work well. 141 * 142 * This function never fails. 137 143 * 138 144 * \param dp The libcaca graphical context. -
libcaca/trunk/caca/graphics.c
r985 r1006 19 19 #include "common.h" 20 20 21 #if !defined(__KERNEL__) 22 # if defined(HAVE_ERRNO_H) 23 # include <errno.h> 24 # endif 25 #endif 26 21 27 #include "caca.h" 22 28 #include "caca_internals.h" … … 27 33 * 28 34 * If libcaca runs in a window, try to change its title. This works with 29 * the X11 and Win32 drivers. 35 * the OpenGL, X11 and Win32 drivers. 36 * 37 * If an error occurs, -1 is returned and \b errno is set accordingly: 38 * - \c ENOSYS Display driver does not support setting the window title. 30 39 * 31 40 * \param dp The libcaca display context. 32 41 * \param title The desired display title. 33 * \return 0 upon success, a non-zero value if an error occurs.42 * \return 0 upon success, -1 if an error occurred. 34 43 */ 35 44 int caca_set_display_title(caca_display_t *dp, char const *title) 36 45 { 37 return dp->drv.set_display_title(dp, title); 46 int ret = dp->drv.set_display_title(dp, title); 47 48 #if defined(HAVE_ERRNO_H) 49 if(ret) 50 errno = ENOSYS; 51 #endif 52 53 return ret; 38 54 } 39 55 … … 45 61 * 6x10 font is being used. Note that the units are not necessarily pixels. 46 62 * 63 * This function never fails. 64 * 47 65 * \param dp The libcaca display context. 48 66 * \return The display width. … … 60 78 * used. Note that the units are not necessarily pixels. 61 79 * 80 * This function never fails. 81 * 62 82 * \param dp The libcaca display context. 63 83 * \return The display height. … … 77 97 * default behaviour. 78 98 * 99 * This function never fails. 100 * 79 101 * \param dp The libcaca display context. 80 102 * \param usec The refresh delay in microseconds. 81 */ 82 void caca_set_display_time(caca_display_t *dp, unsigned int usec) 103 * \return This function always returns 0. 104 */ 105 int caca_set_display_time(caca_display_t *dp, unsigned int usec) 83 106 { 84 107 dp->delay = usec; 108 return 0; 85 109 } 86 110 … … 93 117 * delay even if the real rendering time was shorter. 94 118 * 119 * This function never fails. 120 * 95 121 * \param dp The libcaca display context. 96 122 * \return The render time in microseconds. … … 113 139 * the second call will be delayed before performing the screen refresh. 114 140 * 115 * \param dp The libcaca display context. 116 */ 117 void caca_refresh_display(caca_display_t *dp) 141 * This function never fails. 142 * 143 * \param dp The libcaca display context. 144 * \return This function always returns 0. 145 */ 146 int caca_refresh_display(caca_display_t *dp) 118 147 { 119 148 #if !defined(_DOXYGEN_SKIP_ME) … … 148 177 if(dp->lastticks > (int)dp->delay) 149 178 dp->lastticks = 0; 179 180 return 0; 150 181 } 151 182 … … 155 186 * support it. 156 187 * 188 * If an error occurs, -1 is returned and \b errno is set accordingly: 189 * - \c ENOSYS Display driver does not support hiding the mouse pointer. 190 * 157 191 * \param dp The libcaca display context. 158 192 * \param flag 0 hides the pointer, 1 shows the system's default pointer 159 193 * (usually an arrow). Other values are reserved for future use. 160 */ 161 void caca_set_mouse(caca_display_t *dp, int flag) 162 { 163 if(dp->drv.set_mouse) 164 dp->drv.set_mouse(dp, flag); 194 * \return 0 upon success, -1 if an error occurred. 195 */ 196 int caca_set_mouse(caca_display_t *dp, int flag) 197 { 198 if(!dp->drv.set_mouse) 199 { 200 #if defined(HAVE_ERRNO_H) 201 errno = ENOSYS; 202 #endif 203 return -1; 204 } 205 206 dp->drv.set_mouse(dp, flag); 207 return 0; 165 208 } 166 209
Note: See TracChangeset
for help on using the changeset viewer.