that we have one function less. * Fixed coding style. * Removed FUCKING TABS. ____.------.___ _______.----'`` ``` `` ``` ``-. _.--' ` ```` ` ` ` ``` `` `` ``. _.-' ' ` `` ``` `` ` `' `. _ .-'' ` H A H A H A `' M A I S \/.) . . .-' / ` ` ` `` || |`-.(``-. ` ` ` ' ` ` ``` |\ `. '\```\ `` ` V I E U X ' ' `` `-`` -|\\ `/''````) `` ` - - ````` ' '.' |\_) |`'_._` ``` ''` P O R C . . ```` / // @) \ ` `` ''' . ``` '/ /''''' | ` \).`.'-. ''' _ _ .`` ` '/ .''''- `-'`. . // )-- '/,,',,' ,,,,''__,._`' ' / .' ` `- ` ' .' / ' /,;;;, ,___.---' \ '' / \ (`. .'` __',`''''.--'/ ' /'-----' | ' / )) `'-'/ `'''_.---' \;;|- '/ ,,, | ''|`- | `'--'---' |;| / ,,,,;;;;;;;;;;,,,,, |-' /` | |;|-'| ,;;;;;;;;;;;;;;;; ;;;/ /|`''' ''',,,''',,,,,,,,,,,,,,,' /,,''' ''''tags/v0.99.beta14
@@ -244,8 +244,7 @@ int caca_get_event(caca_t *kk, unsigned int, struct caca_event *); | |||||
int caca_wait_event(caca_t *kk, unsigned int, struct caca_event *); | int caca_wait_event(caca_t *kk, unsigned int, struct caca_event *); | ||||
unsigned int caca_get_mouse_x(caca_t *kk); | unsigned int caca_get_mouse_x(caca_t *kk); | ||||
unsigned int caca_get_mouse_y(caca_t *kk); | unsigned int caca_get_mouse_y(caca_t *kk); | ||||
void caca_hide_cursor(caca_t *kk); | |||||
void caca_show_cursor(caca_t *kk); | |||||
void caca_set_mouse(caca_t *kk, int); | |||||
/* @} */ | /* @} */ | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
@@ -117,8 +117,7 @@ struct caca_context | |||||
void (* display) (caca_t *); | void (* display) (caca_t *); | ||||
void (* handle_resize) (caca_t *); | void (* handle_resize) (caca_t *); | ||||
int (* get_event) (caca_t *, struct caca_event *); | int (* get_event) (caca_t *, struct caca_event *); | ||||
void (* show_cursor) (caca_t *); | |||||
void (* hide_cursor) (caca_t *); | |||||
void (* set_mouse) (caca_t *, int); | |||||
} drv; | } drv; | ||||
/* Mouse position */ | /* Mouse position */ | ||||
@@ -163,8 +163,7 @@ int conio_install(caca_t *kk) | |||||
kk->drv.display = conio_display; | kk->drv.display = conio_display; | ||||
kk->drv.handle_resize = conio_handle_resize; | kk->drv.handle_resize = conio_handle_resize; | ||||
kk->drv.get_event = conio_get_event; | kk->drv.get_event = conio_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -387,18 +387,14 @@ static int gl_get_event(caca_t *kk, struct caca_event *ev) | |||||
} | } | ||||
static void gl_show_cursor(caca_t *kk) | |||||
static void gl_set_mouse(caca_t *kk, int flag) | |||||
{ | { | ||||
glutSetCursor(GLUT_CURSOR_RIGHT_ARROW); | |||||
} | |||||
static void gl_hide_cursor(caca_t *kk) | |||||
{ | |||||
glutSetCursor(GLUT_CURSOR_NONE); | |||||
if(flag) | |||||
glutSetCursor(GLUT_CURSOR_RIGHT_ARROW); | |||||
else | |||||
glutSetCursor(GLUT_CURSOR_NONE); | |||||
} | } | ||||
/* | /* | ||||
* XXX: following functions are local | * XXX: following functions are local | ||||
*/ | */ | ||||
@@ -477,8 +473,8 @@ int gl_install(caca_t *kk) | |||||
kk->drv.display = gl_display; | kk->drv.display = gl_display; | ||||
kk->drv.handle_resize = gl_handle_resize; | kk->drv.handle_resize = gl_handle_resize; | ||||
kk->drv.get_event = gl_get_event; | kk->drv.get_event = gl_get_event; | ||||
kk->drv.show_cursor = gl_show_cursor; | |||||
kk->drv.hide_cursor = gl_hide_cursor; | |||||
kk->drv.set_mouse = gl_set_mouse; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -542,8 +542,8 @@ int ncurses_install(caca_t *kk) | |||||
kk->drv.display = ncurses_display; | kk->drv.display = ncurses_display; | ||||
kk->drv.handle_resize = ncurses_handle_resize; | kk->drv.handle_resize = ncurses_handle_resize; | ||||
kk->drv.get_event = ncurses_get_event; | kk->drv.get_event = ncurses_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -562,12 +562,10 @@ int network_install(caca_t *kk) | |||||
kk->drv.display = network_display; | kk->drv.display = network_display; | ||||
kk->drv.handle_resize = network_handle_resize; | kk->drv.handle_resize = network_handle_resize; | ||||
kk->drv.get_event = network_get_event; | kk->drv.get_event = network_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
#endif /* USE_NETWORK */ | #endif /* USE_NETWORK */ | ||||
@@ -480,8 +480,7 @@ int slang_install(caca_t *kk) | |||||
kk->drv.display = slang_display; | kk->drv.display = slang_display; | ||||
kk->drv.handle_resize = slang_handle_resize; | kk->drv.handle_resize = slang_handle_resize; | ||||
kk->drv.get_event = slang_get_event; | kk->drv.get_event = slang_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -157,8 +157,7 @@ int vga_install(caca_t *kk) | |||||
kk->drv.display = vga_display; | kk->drv.display = vga_display; | ||||
kk->drv.handle_resize = vga_handle_resize; | kk->drv.handle_resize = vga_handle_resize; | ||||
kk->drv.get_event = vga_get_event; | kk->drv.get_event = vga_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -345,8 +345,7 @@ int win32_install(caca_t *kk) | |||||
kk->drv.display = win32_display; | kk->drv.display = win32_display; | ||||
kk->drv.handle_resize = win32_handle_resize; | kk->drv.handle_resize = win32_handle_resize; | ||||
kk->drv.get_event = win32_get_event; | kk->drv.get_event = win32_get_event; | ||||
kk->drv.show_cursor = NULL; | |||||
kk->drv.hide_cursor = NULL; | |||||
kk->drv.set_mouse = NULL; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -209,8 +209,6 @@ static int x11_init_graphics(caca_t *kk) | |||||
kk->qq->height * kk->drv.p->font_height, | kk->qq->height * kk->drv.p->font_height, | ||||
DefaultDepth(kk->drv.p->dpy, | DefaultDepth(kk->drv.p->dpy, | ||||
DefaultScreen(kk->drv.p->dpy))); | DefaultScreen(kk->drv.p->dpy))); | ||||
kk->drv.p->pointer = None; | kk->drv.p->pointer = None; | ||||
return 0; | return 0; | ||||
@@ -537,37 +535,38 @@ static int x11_get_event(caca_t *kk, struct caca_event *ev) | |||||
return 0; | return 0; | ||||
} | } | ||||
static void x11_show_cursor(caca_t *kk) | |||||
{ | |||||
XDefineCursor(kk->drv.p->dpy,kk->drv.p->window, 0); | |||||
} | |||||
static void x11_hide_cursor(caca_t *kk) | |||||
static void x11_set_mouse(caca_t *kk, int flags) | |||||
{ | { | ||||
Cursor no_ptr; | Cursor no_ptr; | ||||
Pixmap bm_no; | Pixmap bm_no; | ||||
XColor black, dummy; | XColor black, dummy; | ||||
Colormap colormap; | Colormap colormap; | ||||
static char empty[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |||||
static char const empty[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |||||
if(flags) | |||||
{ | |||||
XDefineCursor(kk->drv.p->dpy,kk->drv.p->window, 0); | |||||
return; | |||||
} | |||||
colormap = DefaultColormap(kk->drv.p->dpy, DefaultScreen(kk->drv.p->dpy)); | colormap = DefaultColormap(kk->drv.p->dpy, DefaultScreen(kk->drv.p->dpy)); | ||||
if ( !XAllocNamedColor(kk->drv.p->dpy, colormap, "black", &black, &dummy) ) | |||||
if(!XAllocNamedColor(kk->drv.p->dpy, colormap, "black", &black, &dummy)) | |||||
{ | { | ||||
return; | |||||
return; | |||||
} | } | ||||
bm_no = XCreateBitmapFromData(kk->drv.p->dpy, kk->drv.p->window, empty, 8, 8); | |||||
no_ptr = XCreatePixmapCursor(kk->drv.p->dpy, bm_no, bm_no, &black, &black, 0, 0); | |||||
XDefineCursor(kk->drv.p->dpy, kk->drv.p->window, no_ptr); | |||||
bm_no = XCreateBitmapFromData(kk->drv.p->dpy, kk->drv.p->window, | |||||
empty, 8, 8); | |||||
no_ptr = XCreatePixmapCursor(kk->drv.p->dpy, bm_no, bm_no, | |||||
&black, &black, 0, 0); | |||||
XDefineCursor(kk->drv.p->dpy, kk->drv.p->window, no_ptr); | |||||
XFreeCursor(kk->drv.p->dpy, no_ptr); | XFreeCursor(kk->drv.p->dpy, no_ptr); | ||||
if (bm_no != None) | |||||
if(bm_no != None) | |||||
XFreePixmap(kk->drv.p->dpy, bm_no); | XFreePixmap(kk->drv.p->dpy, bm_no); | ||||
XFreeColors(kk->drv.p->dpy,colormap,&black.pixel,1,0); | |||||
XFreeColors(kk->drv.p->dpy, colormap, &black.pixel, 1, 0); | |||||
XSync(kk->drv.p->dpy, False); | XSync(kk->drv.p->dpy, False); | ||||
} | } | ||||
/* | /* | ||||
* XXX: following functions are local | * XXX: following functions are local | ||||
*/ | */ | ||||
@@ -599,8 +598,7 @@ int x11_install(caca_t *kk) | |||||
kk->drv.display = x11_display; | kk->drv.display = x11_display; | ||||
kk->drv.handle_resize = x11_handle_resize; | kk->drv.handle_resize = x11_handle_resize; | ||||
kk->drv.get_event = x11_get_event; | kk->drv.get_event = x11_get_event; | ||||
kk->drv.show_cursor = x11_show_cursor; | |||||
kk->drv.hide_cursor = x11_hide_cursor; | |||||
kk->drv.set_mouse = x11_set_mouse; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -143,29 +143,20 @@ void caca_display(caca_t *kk) | |||||
kk->lastticks = 0; | kk->lastticks = 0; | ||||
} | } | ||||
/** \brief Show cursor on capable drivers | |||||
/** \brief Show or hide the mouse pointer. | |||||
* | * | ||||
* This function shows the cursor on drivers permitting it. | |||||
* This function shows or hides the mouse pointer, for devices that | |||||
* support it. | |||||
* | * | ||||
* \param flag 0 hides the pointer, 1 shows the system's default pointer | |||||
* (usually an arrow). Other values are reserved for future use. | |||||
*/ | */ | ||||
void caca_show_cursor(caca_t *kk) | |||||
void caca_set_mouse(caca_t *kk, int flag) | |||||
{ | { | ||||
if(kk->drv.show_cursor) | |||||
kk->drv.show_cursor(kk); | |||||
if(kk->drv.set_mouse) | |||||
kk->drv.set_mouse(kk, flag); | |||||
} | } | ||||
/** \brief Hide cursor on capable drivers | |||||
* | |||||
* This function hides the cursor on drivers permitting it. | |||||
* | |||||
*/ | |||||
void caca_hide_cursor(caca_t *kk) | |||||
{ | |||||
if(kk->drv.hide_cursor) | |||||
kk->drv.hide_cursor(kk); | |||||
} | |||||
/* | /* | ||||
* XXX: following functions are local | * XXX: following functions are local | ||||
*/ | */ | ||||
@@ -62,7 +62,7 @@ int main(int argc, char **argv) | |||||
sprite = cucul_load_sprite(qq, "examples/caca.txt"); | sprite = cucul_load_sprite(qq, "examples/caca.txt"); | ||||
/* Disable cursor */ | /* Disable cursor */ | ||||
caca_hide_cursor(kk); | |||||
caca_set_mouse(kk, 0); | |||||
/* Main menu */ | /* Main menu */ | ||||
display_menu(); | display_menu(); | ||||