Browse Source

* Merged caca_show_cursor() and caca_hide_cursor() into caca_set_mouse() so

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
Sam Hocevar sam 18 years ago
parent
commit
5696329b86
12 changed files with 43 additions and 66 deletions
  1. +1
    -2
      caca/caca.h
  2. +1
    -2
      caca/caca_internals.h
  3. +1
    -2
      caca/driver_conio.c
  4. +7
    -11
      caca/driver_gl.c
  5. +2
    -2
      caca/driver_ncurses.c
  6. +1
    -3
      caca/driver_network.c
  7. +1
    -2
      caca/driver_slang.c
  8. +1
    -2
      caca/driver_vga.c
  9. +1
    -2
      caca/driver_win32.c
  10. +18
    -20
      caca/driver_x11.c
  11. +8
    -17
      caca/graphics.c
  12. +1
    -1
      test/demo.c

+ 1
- 2
caca/caca.h View File

@@ -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 *);
unsigned int caca_get_mouse_x(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


+ 1
- 2
caca/caca_internals.h View File

@@ -117,8 +117,7 @@ struct caca_context
void (* display) (caca_t *);
void (* handle_resize) (caca_t *);
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;

/* Mouse position */


+ 1
- 2
caca/driver_conio.c View File

@@ -163,8 +163,7 @@ int conio_install(caca_t *kk)
kk->drv.display = conio_display;
kk->drv.handle_resize = conio_handle_resize;
kk->drv.get_event = conio_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;

return 0;
}


+ 7
- 11
caca/driver_gl.c View File

@@ -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
*/
@@ -477,8 +473,8 @@ int gl_install(caca_t *kk)
kk->drv.display = gl_display;
kk->drv.handle_resize = gl_handle_resize;
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;
}



+ 2
- 2
caca/driver_ncurses.c View File

@@ -542,8 +542,8 @@ int ncurses_install(caca_t *kk)
kk->drv.display = ncurses_display;
kk->drv.handle_resize = ncurses_handle_resize;
kk->drv.get_event = ncurses_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;
return 0;
}



+ 1
- 3
caca/driver_network.c View File

@@ -562,12 +562,10 @@ int network_install(caca_t *kk)
kk->drv.display = network_display;
kk->drv.handle_resize = network_handle_resize;
kk->drv.get_event = network_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;

return 0;
}


#endif /* USE_NETWORK */


+ 1
- 2
caca/driver_slang.c View File

@@ -480,8 +480,7 @@ int slang_install(caca_t *kk)
kk->drv.display = slang_display;
kk->drv.handle_resize = slang_handle_resize;
kk->drv.get_event = slang_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;

return 0;
}


+ 1
- 2
caca/driver_vga.c View File

@@ -157,8 +157,7 @@ int vga_install(caca_t *kk)
kk->drv.display = vga_display;
kk->drv.handle_resize = vga_handle_resize;
kk->drv.get_event = vga_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;

return 0;
}


+ 1
- 2
caca/driver_win32.c View File

@@ -345,8 +345,7 @@ int win32_install(caca_t *kk)
kk->drv.display = win32_display;
kk->drv.handle_resize = win32_handle_resize;
kk->drv.get_event = win32_get_event;
kk->drv.show_cursor = NULL;
kk->drv.hide_cursor = NULL;
kk->drv.set_mouse = NULL;

return 0;
}


+ 18
- 20
caca/driver_x11.c View File

@@ -209,8 +209,6 @@ static int x11_init_graphics(caca_t *kk)
kk->qq->height * kk->drv.p->font_height,
DefaultDepth(kk->drv.p->dpy,
DefaultScreen(kk->drv.p->dpy)));


kk->drv.p->pointer = None;

return 0;
@@ -537,37 +535,38 @@ static int x11_get_event(caca_t *kk, struct caca_event *ev)
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;
Pixmap bm_no;
XColor black, dummy;
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));
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);
if (bm_no != None)
if(bm_no != None)
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);

}


/*
* XXX: following functions are local
*/
@@ -599,8 +598,7 @@ int x11_install(caca_t *kk)
kk->drv.display = x11_display;
kk->drv.handle_resize = x11_handle_resize;
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;
}


+ 8
- 17
caca/graphics.c View File

@@ -143,29 +143,20 @@ void caca_display(caca_t *kk)
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
*/


+ 1
- 1
test/demo.c View File

@@ -62,7 +62,7 @@ int main(int argc, char **argv)
sprite = cucul_load_sprite(qq, "examples/caca.txt");

/* Disable cursor */
caca_hide_cursor(kk);
caca_set_mouse(kk, 0);

/* Main menu */
display_menu();


Loading…
Cancel
Save